Inspiration
Millions of livestock farmers across Africa manage their operations with paper notebooks and memory. When a batch of 500 broilers starts dying, there's no data to explain why — no mortality trends, no feed conversion history, no weather correlation. The farm management tools that do exist assume reliable internet, desktop computers, and English literacy. None of that maps to a farmer checking on fish ponds with a cracked Android phone and spotty 3G in rural Nigeria.
We wanted to build something that works where farming actually happens — offline, on mobile, in local languages.
What it does
LivestockAI manages 6 livestock species (poultry, fish, cattle, goats, sheep, bees) with three AI systems powered by Google Gemini:
Sentinel — An autonomous farm monitor that correlates mortality, feed, growth, and weather data to detect problems early. It auto-creates tasks and alerts, and farmers can revert any AI action. Vision — Farmers photograph sick animals or walk through a symptom decision tree. The system triages urgency, suggests diagnoses, and can escalate to a vet. Optimizer — Analyzes historical batch performance to recommend feed strategies, stocking densities, and timing with verifiable metrics. Beyond AI, the platform handles batch lifecycle tracking, financial management (sales, expenses, invoicing in 20+ currencies), feed inventory, vaccination schedules, growth forecasting, IoT sensor integration, and a Credit Passport that generates cryptographically signed reports farmers can show to lenders.
Everything works offline and syncs when connectivity returns. Available in 15 languages including Hausa, Yoruba, Igbo, Swahili, and Amharic.
How we built it
Full-stack TypeScript from database to UI:
Frontend: React 19 + TanStack Router + TanStack Query Backend: TanStack Start with server functions in a three-layer architecture (Server → Service → Repository) Database: PostgreSQL on Neon (serverless) with Kysely ORM for type-safe queries — 116 tables across 33 migrations AI: Google Gemini API for Sentinel monitoring, Vision diagnosis, and Optimizer recommendations Deployment: Cloudflare Workers at the edge via Hyperdrive for full transaction support Offline: Service Worker + IndexedDB + TanStack Query persistence We used spec-driven development throughout — defining requirements upfront, breaking them into tasks, and implementing systematically. Business logic correctness is validated through property-based testing with fast-check:
FCR= Weight Gain (kg) Total Feed (kg) ≥0Mortality%= Initial Qty Deaths ×100
These properties hold for any valid input, not just hand-picked test cases. The project has 1,900+ tests across 124 test files.
Challenges we ran into
Cloudflare Workers compatibility was the biggest hurdle. Static database imports break at runtime because Workers don't have process.env. Every server function needed async dynamic imports through a custom getDb() function that detects the runtime environment — this took real debugging to discover and required refactoring the entire data access layer.
Designing for the field meant rethinking every UI assumption. Touch targets are minimum 48px (farmers wear gloves). Action grids use 64×64px cells. Data tables transform to cards on mobile. We test against 3G connection speeds and assume screens might be cracked or in direct sunlight.
AI trust — Sentinel takes autonomous actions like creating emergency tasks and adjusting feed schedules. Farmers need to trust it but also stay in control. We built a full revert system and expose reasoning chains for every decision so it's never a black box.
Offline-first with financial data — Recording sales offline while another user does the same for the same batch creates conflicts. We use last-write-wins with comprehensive audit trails so nothing is silently lost.
Accomplishments that we're proud of
116 database tables supporting 6 species with species-specific metrics, IoT sensors, AI memory, and a full extension worker system for government agricultural agents 15 languages, 15,075 translation keys — not machine-translated placeholders, but structured translations covering farming terminology in Hausa, Yoruba, Igbo, Swahili, Hindi, and 10 more Three AI systems that work together — Sentinel detects a mortality spike, Vision helps diagnose the cause, Optimizer adjusts the strategy for next cycle Credit Passport — Cryptographically signed farm performance reports with QR verification, giving farmers without traditional credit history a way to prove their track record to lenders 1,900+ tests including property-based tests that validate mathematical invariants across every financial calculation The whole thing works offline. A farmer can run their entire operation for 30+ days without internet and sync everything when they get to town
What we learned
Spec-driven development works — Planning features as structured specs before coding cut implementation time dramatically and prevented costly rewrites Property-based testing catches what unit tests miss — fast-check found edge cases with currency rounding, duplicate navigation items, and boundary conditions that hand-written tests never would have Offline-first must be built in from day one — Bolting it on later would have been an order of magnitude harder Farmers are power users — They don't want simplified tools; they want powerful tools with simple interfaces. The distinction matters enormously for design decisions
What's next for LiveStockAI
Zoonotic disease flagging — When Vision detects symptoms consistent with diseases transmissible to humans (avian flu, brucellosis), show prominent safety warnings Regional disease variations — Make the diagnostic decision tree region-aware using farm GPS coordinates, so a farmer in humid southern Nigeria gets different guidance than one in the arid north Shareable PDF diagnosis reports — Let farmers share diagnosis history with vets who don't use the app, bridging the gap between our platform and the real veterinary world Extension worker integration — Agricultural extension workers visit 50+ farms; giving them district-level diagnosis dashboards turns them into early warning systems for outbreaks Real pilot deployment — Partner with farming cooperatives in northern Nigeria to get LivestockAI into the hands of real farmers and iterate based on field feedback
Built With
- gemini
- kysely
- postgresql
- tanstack
- typescript
Log in or sign up for Devpost to join the conversation.