Cattle Logic

Cattle Logic — Building the Operating System for American Ranching
A Benmore Technologies case study, in partnership with Meridian Cattle (Kansas).
Client: Trevin Koehn FDE: Arkash Jain
Behind The Build: How We Helped Meridian Cattle Modernize How Feedlot Operations Are Managed
1. Introduction
Overview:
Cattle Logic is a full-lifecycle operating system for American cattle feedlots — covering intake, feed, health, inventory, risk management, and invoicing — designed to work offline in places with no cell signal. Built in close partnership with Trevin Koehn of Meridian Cattle (Kansas) and advisor Richard Buehling, the platform gives small-to-mid feedlot operators the same data infrastructure that the largest commercial yards have spent decades and millions of dollars building.
Available on the App Store, Google Play, and at cattlelogicapp.com, Cattle Logic replaces spiral notebooks, kitchen-table math, and whiteboards in feed trucks with a phone-first system of record.
▶ Walkthrough video: Watch on YouTube
Challenge:
Building a financially-authoritative cattle management platform that works offline in dead zones, supports multi-tenant ownership, integrates CME futures and options data for hedging, and gets every cost-of-gain calculation right to the cent — all while remaining usable by a foreman entering treatments on a phone in the back of a feed truck.
2. The Problem
Background:
The U.S. beef cattle industry is a $95B market with ~500,000 operating businesses and no operator holding more than 5% share. 55% of U.S. beef-cow farms run fewer than 20 head; fewer than 1% run 1,000+. Software has historically existed only for the top 7% — the large commercial yards that can absorb six- and seven-figure deployments of legacy mainframe-era tooling.
Everyone else runs the operation out of spiral notebooks, an Excel sheet from 2011, a whiteboard in the feed truck, and a memory of what last week's corn delivery cost. Meridian Cattle was operating exactly that way — Trevin tracking head counts on paper, calculating cost-of-gain by hand at the kitchen table, and reconciling pen-level mortality from memory.
Pain Points:
- Cost-of-gain was a guess — Feed prices are FIFO by load and ration composition shifts when commodities change. Doing this on paper means billing customers and pricing risk on numbers that are weeks stale and structurally wrong.
- Hedging was inaccessible — CME futures, options, and LRP policies are how big operators de-risk price exposure. Small ranchers had neither the data feeds nor the tooling, so "bailout" had become the de facto risk-management strategy for the bottom 93% of the market.
- Multi-tenant ownership was unmodelable — Cattle in a single pen are often co-owned by multiple partners. Generating a per-customer invoice that allocates feed, yardage, treatment, and interest by ownership share is a non-starter on paper.
- Connectivity was a binding constraint — Most ranches sit in cell coverage that ranges from spotty to none. Any system requiring a network round-trip to record a treatment event will be abandoned within a week.
- Compliance ate hours — Withdrawal periods, FDA-mandated treatment audit trails, and operating-loan documentation all lived somewhere between "in Trevin's head" and "in a binder Trevin hopes he can find."
The downstream impact was real. Customers couldn't audit their invoices. Banks lent against numbers that were directionally right at best. And families have lost farms because the math wasn't tight enough to catch the slow bleed in time.
3. Our Solution
Discovery Process:
Trevin's ask was direct: intake-to-invoice on a phone, with a real risk-management layer — the capabilities legacy yard software offers, without the legacy price tag. We narrowed the platform around one principle: the system has to be authoritatively right about head count, cost, and ownership at every moment, even offline, even mid-shipment. Everything else could iterate. Getting the financial spine wrong would burn the trust the product was built to earn.
Core Value Proposition:
Give the long tail of American ranchers the same data infrastructure and hedging tooling as the top 7% — on a phone, in their truck, with no signal.
Proposed Solution:
- Intake Pipeline — Weigh, RFID-tag, and video-capture each animal at arrival. Two-step verify flow lets a foreman record arrival on a tablet and an admin verify pricing later. Sort/merge between lots auto-generates outbound and inbound receipts with a full audit trail.
- Feed, Lot & Pen Management — Versioned rations with composition snapshots, pen-level head-count truth, automatic dry-matter calculations, and a single
HeadCountServiceas the only authority for head count mutations. - Health, Mortality & Pharmaceuticals — Treatment protocols with multi-drug tiers, withdrawal-period tracking, hospital-pen workflow that keeps cattle in their original lot's count, and FIFO pharmaceutical batch deduction with expiration tracking.
- Inventory with FIFO Pricing — Feed loads and pharma batches deplete oldest-first. The pricing display reflects the front of the FIFO queue, so what you see in inventory is what you'll actually pay on the next pound consumed.
- CME-Integrated Risk Management — Daily settlement prices from Databento, futures + options + LRP position tracking, live mark-to-market P&L, and a buy-sheet projection tool with a three-iteration breakeven calculator.
- Multi-Tenant Invoicing — A single aggregation service pulls from six modules and allocates by ownership percentage when a lot has partners. Feed and drug costs use historical FIFO records, not current averages, so invoices match closeouts exactly.
- Lot Closeout Reports — Full P&L, cost-of-gain breakdown, recovery-based breakeven, proportional realized/unrealized split for partially-sold lots, and ACT CONV with death-day correction.
- Offline-First Sync — SQLite cache, queued operations with deduplication, temp-ID resolution, proactive conflict detection with side-by-side resolution UI, and exponential-backoff retry.
- Three-Layer RBAC — Role defaults, per-membership overrides, and per-view restrictions for owners, senior employees, employees, and viewers.
- Stripe-Billed Subscriptions — Both flat-rate and per-head-day pricing, trial expiry handling, webhook-driven status sync, and a recovery flow for deleted Stripe customers.
Technology Stack:
- Backend: Django 5.2.11, Django REST Framework, Celery + Redis, PostgreSQL, SimpleJWT
- Mobile: React Native 0.76.9, Expo 52, Expo Router, native FCM/APNS push
- Hosting: Heroku (backend with release-step migrations and post-deploy smoke tests), App Store + Google Play, EAS Update for OTA hotfixes
- Database: PostgreSQL (production), SQLite (mobile cache)
- Payments: Stripe (subscriptions + per-head-day billing)
- Market Data: Databento (CME futures + options)
- Notifications: SendGrid (email), Firebase Cloud Messaging + APNS (push)
- Monitoring: Sentry with cron-monitor coverage on all 11 Celery beat tasks
4. Implementation
Backend & Infrastructure:
- Django REST API serving iOS, Android, and the web admin from a single codebase
- PostgreSQL on Heroku with branch-protected deployments and CI-gated migrations
- Celery + Redis for asynchronous background work (price feeds, scheduled treatments, invoicing)
- Sentry instrumentation on every Celery task and every API endpoint
Mobile Application Development:
- Built cross-platform in React Native with Expo, delivering a consistent experience on both iOS and Android
- Designed UI around the daily workflows of feedlot foremen and pen riders — minimum taps to record a treatment, mortality, or feed event
- Integrated SQLite for offline-first persistence with a custom sync engine layered on top
Key Features Implemented:
- Frozen Snapshot Pattern — Every FeedEvent stores
head_count_at_event,lbs_dm_per_head, andlot_average_weight_at_eventimmutably at save time. Historical reports stay accurate even when current values change. - Versioned Rations — Each ration carries dated composition snapshots, so a feed event always references the ration as it existed on that date.
- Offline Conflict Resolution — Two foremen on two trucks can edit the same record offline. The system detects the conflict, shows side-by-side comparisons, and offers three resolution paths — never silently overwriting.
- Recovery-Based Breakeven — Subtracts net sales revenue from costs before dividing by remaining head. Not a textbook formula, but the one that matches how ranchers actually recover cost in the back half of a feeding period.
- CI-Gated Migrations — A GitHub Actions workflow replays PR migrations against a committed
prod_schema.sqlbaseline and blocks any destructive operation lacking a documented# CI_ALLOW_DESTRUCTIVEcomment.
Technical Challenges Addressed:
- Head Count Truth Across Hospital & Shipments — Originally hospital moves decremented
lot.current_head_count, causing a known divergence (e.g. "100 arrive, 5 to hospital, 2 die, 3 return = lot count 96, actual alive 98"). v1.7.21 redesigned the model so hospital cattle stay in lot count, with a data migration to backfill existing lots and FIFO discharge logic for shipping from hospital pens. - FIFO Pricing Mismatch Between Invoices & Closeouts — Closeouts used a weighted-average ration price; invoices used per-load FIFO records. Same lot, two different feed costs. v1.7.19 made
FeedCommodity.average_costreturn the oldest active load's price and pointed cost-of-gain at the same audit records the invoicer used. Same numbers everywhere. - Two-Day-Stale CME Prices — CME settlements publish at ~7 PM CT, which is 1 AM UTC the next day. Naive Python
dateobjects use UTC-midnight boundaries, silently chopping off the settlement we wanted. The fix was small (tzinfo=ZoneInfo("America/Chicago")) but the symptom had persisted for months. - Invoice/Closeout Audit Reconciliation — A serializer was recalculating dry-matter from raw
amount_fed_lbsinstead of using the frozenlbs_dm_per_headsnapshot, silently producing 9.96 conversion ratios — physically impossible — until we audited it.
5. Results
Product Outcomes:
- Live on iOS and Google Play, with Django backend on Heroku, branch protection, CI migration gating, post-deploy smoke tests, and full Sentry coverage
- Meridian Cattle runs day-to-day on the platform — intake, feed events, treatments, mortality, partner invoicing, and closeouts
- Adopted by additional feedlots beyond the original design partner
What Operators Are Saying:


Technical Achievements:
- Math That Matches — Closeout cost-of-gain, invoice feed cost, and inventory display all read from the same FIFO source records. ACT CONV reconciles to physical reality.
- Hedging on a Phone — Daily Databento price feed, futures + options + LRP position tracking, mark-to-market P&L on the closeout, and three-iteration breakeven on the buy sheet — the same class of risk tooling commercial yards use.
- Offline That Actually Works — A pen rider can record a full day of treatments in a dead zone, and the queue reconciles on the drive back to the office. Conflict resolution is a feature, not an excuse.
- Compliance Artifacts on Demand — Treatment audit trail with withdrawal-period tracking, FIFO pharma batch deduction with expiration, soft-delete that preserves full lot history, and closeout PDFs an auditor or lender can read.
Business Impact:
- From Guessing to Knowing — Meridian moved from "we think the lot is profitable" to actually knowing — to the cent.
- One-Click Bank-Ready Reports — Closeout PDFs replace the Friday scramble to compile numbers for the lender.
- New Customer Capacity — Per-partner invoicing unlocks partial-ownership customers that were previously impossible to bill.
- Asymmetric Access — Operators who spent careers as price-takers into the packer layer now hold, on a phone, the same data infrastructure that's been gatekept behind six-figure software contracts.
6. Lessons Learned
Key Takeaways:
- The Financial Spine Is the Product — UI can be ugly and ship. A one-cent-off cost-of-gain cannot. Each rewrite of the FIFO pricing layer, the head-count service, and the breakeven formula earned more operator trust than any new feature shipped on top of them.
- Offline Isn't a Feature, It's the Architecture — Bolting offline onto an online-first app produces sync bugs that destroy data. Designing optimistic responses, temp-ID resolution, deduplication, and conflict resolution from the first commit is what made the mobile app usable at all.
- Audit Your Own Math Against Reality — The ACT CONV bug sat in production silently producing physically-impossible conversion ratios until we ran the audit. Never trust a calculation you haven't reconciled against a known input.
- Listen to the Operator Harder Than to the Spec — Trevin's reformulation of breakeven wasn't in any textbook. It was, however, the formula that matches how a rancher actually recovers cost. Domain expertise beats algorithm purity.
- Ship Migration Safety Before You Need It — The CI migration gate was added after we'd already burned ourselves on risky deploys. The right time to add it was the day we shipped multi-tenant. The second-best time was when we did.
7. Conclusion
Summary:
Cattle Logic transforms one of the most consequential daily operations in American agriculture — running a cattle feedlot — from kitchen-table math into a phone-first, financially-authoritative, offline-capable system of record. By covering intake-to-invoice with the same FIFO source records driving every cost calculation, and layering CME-integrated hedging on top, the platform gives small operators tooling that previously cost hundreds of thousands of dollars to deploy.
The project demonstrates how disciplined attention to a financial spine, offline-first architecture, and direct operator partnership can deliver enterprise-grade infrastructure to an underserved 93% of an industry — and lays the foundation for adoption far beyond the first yard in Kansas.
⭐ A Note on the Mission
We can call ourselves a software factory, position ourselves as consultants, brand ourselves as Claude Code evangelists. At the end of the day, what we are actually doing is building people's dreams in software — making the same infrastructure that the top 7% of an industry takes for granted accessible to the 93% who were told it would cost hundreds of thousands or millions of dollars to ever have it.
Trevin Koehn's story, and the families who have lost farms recently because the margins finally caught up to the math, are why this project exists. Richard Buehling's framing of what Benmore should be doing in the world is what this project tries to be an example of.
Cattle Logic is one yard, in Kansas, today. The thesis is that the long tail of American ranching deserves the same toolkit the consolidators have — and that the operator who builds the system of record for an industry everyone else wrote off as too messy to index ends up holding the asymmetric returns.
We are excited to keep building for American farmers.


