Farmstack
- Published on
- Status
- Production - live in the field
- Role
- Full-stack Developer
- Platform
- Mobile & Web
- Industry
- Agriculture Technology
- Modules
- Farmers · Collection · Maps & Farm Geodata · Change Management



+8
Live Preview
Project Description
Farmstack is a farm management platform for organisations that collect produce such as tea, coffee and milk from farmers, from smallholders to large-scale growers: tea and coffee factories, dairy processors and milk collection centres, farmer co-operatives and SACCOs, and other agribusinesses running outgrower schemes.
The whole system is built with sustainability certification such as Rainforest Alliance in mind. The data a certification audit asks for, from farmer details and farm boundaries to production records and field visits, is collected as part of everyday registration, collection and field extension work. Moving into certification becomes a matter of reviewing records the organisation already holds, not a separate data-gathering exercise.
The name is literal - it is built as a stack of modules covering the relationship between a processor and the farmers supplying it, each one sitting on the same records rather than beside them in a separate system.
Live today: farmer management, an offline-first collection app running on field devices, maps and GIS, farm boundary geodata, and change management with farmer notifications. Next in line: payroll, then field extension and farm visits.
The Solution
An outgrower operation runs on things it usually keeps on paper or in someone's head, and Farmstack treats each as its own problem:
- Records - who the farmers are. A verified register with an approval trail, not a form that writes straight to a table.
- Connectivity - what they delivered. Collection happens at roadside stations with no signal, so the device is the source of truth until it can sync.
- Location - where it all happens. Routes, stations, farms and every receipt sit on a map.
- Accountability - who changed what, and who approved it. Records that decide money or eligibility change only through a reviewed request.
What holds the modules together is a shared data model. One schema definition generates both the on-device and the server database, with validation derived from it, so adding a module means extending the model rather than integrating another system.
Farmer Management
- Recruitment & registration - field officers register outgrowers digitally: particulars, payment accounts, documents, farm units, route and collection station.
- Two-stage approval - a verifier checks the data and an admin decides; queried records go back to the officer with notes rather than being rejected outright.
- Register exports - filter-aware XLSX downloads: what you filtered on screen is what lands in the file.
Field Collection - Live on Devices
- Offline-first capture - clerks look up farmers, weigh, and close batches with no network, against an encrypted on-device database.
- Bluetooth scales & thermal printers - weights stream straight from the scale and a weighment is only accepted once the reading is valid; receipts print on the spot, with a scannable QR on the batch receipt.
- GPS on every receipt - high-accuracy location captured with each collection.
- Automatic two-way sync - uploads run in the background with per-record status, and reference data (farmers, routes, stations, approved devices) flows back down so office decisions reach every handset.
Collections Admin
Batches, receipts and weighments are browsable on the web with stats, drawers and exports. Totals reflect approved corrections, and late uploads and flagged weighments are visible rather than buried.
Maps & GIS
- Network map - regions, routes and collection stations, with each route drawn as its real collection path to the factory for route planning.
- Coverage layers - route and region coverage derived from the mapped stations, for planning where the network reaches.
- Station mapping from the field - officers pin stations from a phone browser.
- Collection maps - receipts plotted by GPS with daily volumes by route and region, judged against route and region coverage.
Farm Geodata & Certification Readiness
Certification starts with knowing exactly where each farm is. Farm boundary polygons from sustainability-certification inspections (Rainforest Alliance) are imported into a review area before they touch a farm record. Each polygon is checked on satellite imagery against the inspection location, neighbouring farms and overlaps, and the farmer's own record. Reviewers approve, reject or correct polygons one by one or in bulk, with a reviewer-activity log, and approved boundaries become the farm unit's mapped area.
Collection Integrity
Fraud prevention is built into the collection workflow rather than bolted on afterwards:
- Approved equipment only - scales are registered centrally, and unregistered equipment cannot be used to collect.
- Tamper-resistant time - captures are protected against device clock manipulation.
- Yield limits - a farmer can only supply volumes consistent with their registered farm unit, enforced as a block or a warning per organisation.
- Location audit trail - every weighment carries GPS, making unusual collection patterns visible.
- Analytics & audit views - flagged weighments, late uploads and per-route activity, with every correction going through change management.
Governed Changes & Audit Trail
Records that decide money or eligibility - farm units, collections, payment accounts and farmer details, phone and status - change through a raise → verify → approve request, never a direct edit.
- Separation of duties - the person who raises a change never approves it, and higher-risk changes such as a pay-point switch need three different people.
- Safe to apply - approval applies the change in one transaction and is refused if the record moved since the request was raised.
- Collections corrections - reassign a receipt to the right farmer, reject a receipt or individual weighments, and restore them, with farmer totals corrected automatically.
- Complete audit trail - every request keeps its before and after values, who acted in which role, and when; farmers carry a pay-point history.
Change Notifications
When an approved change touches a farmer - a pay-point switched or corrected, a receipt rejected or moved - they are told by SMS. Which events notify, and whom, is a setting rather than code. Every message is logged per recipient and shown on the request and the farmer's page, with a resend option. WhatsApp and email are next.
Shared Foundations
- One schema, everywhere - Drizzle exported as SQLite (mobile) and PostgreSQL (server), Zod validators derived from it, and tRPC carrying the types end to end.
- Background jobs - a dedicated worker on BullMQ and Redis for SMS, scheduled work and retries.
- Access control - Better Auth with attribute-based permissions enforced at the API, one set of rules across every module.
Technology
- Mobile: React Native, Expo, SQLite (encrypted, local-first), Bluetooth (BLE & Classic) scales, ESC/POS printing
- Web: Next.js, React, TypeScript, TanStack Query, TanStack Table, Recharts, MapLibre
- API: Hono and tRPC, with REST endpoints for device sync, exports and webhooks
- Database & GIS: PostgreSQL with PostGIS, Drizzle ORM, Zod validation, and a routing engine for route planning
- Authentication: Better Auth with attribute-based permission checks
- Background Jobs: BullMQ and Redis on a dedicated worker service
- Storage: Cloudflare R2
- Monorepo: Turborepo, Bun
- Deployment: Docker - API server and worker under Compose, the web client as its own image, with automated releases