Agriculture / dairy
PastureDesk
Paddock 16 is under water and Saturday's pasture walk was wrong — here is the new grazing plan, and what it costs.
In the demo you run Monday 06:30 on a fictional Waikato dairy farm: new files arrive, a paddock is under water, and Saturday's plan turns out to be 7.9 t DM short. You compare four candidate plans and apply one. Underneath: INSERT-only observation versions and a feed budget reproducible to the kilogram and the cent.
- My role
- Sole engineer: spec to deployment
- Walkthrough
- 90-second guided scenario
- Focus
- Versioned data and plans compared before they apply
Launch guided demo (opens in a new tab)Engineering evidence
Stack: React · TypeScript · PHP/Symfony · PostgreSQL · Playwright + axe
Independently built portfolio showcase · simulated data

The business problem
A dairy farm manager plans the week's grazing from pasture covers measured by a plate meter, estimated visually or from satellites. The sources disagree, arrive late and get corrected, and paddocks get blocked: waterlogged, sprayed, regrassed or stood down after effluent. On Monday the question is whether 320 cows can still be fed this week, and at what cost.
Try the workflow
Step 1

Monday 06:30: the files arrive. Conflicts are listed, never averaged; a paddock without recent data adds no feed. Step 2

P12's corrected walk is a new version at revision 50; Saturday's reading at revision 46 stays. Step 3

With P16 blocked, Saturday's plan is 7.9 t DM short. Four candidates, one budget function, compared before apply.

Engineering invariants
Rules the system enforces whatever the user does, and where each one is proven.
| Invariant | Why it matters | Evidence |
|---|---|---|
| An observation is never overwritten. A correction is a new version at a higher data revision, and the old one stays. | "As of Saturday" and "as of Monday" are two reproducible answers. | Versioned observations (ADR 0009) (opens in a new tab)Integration/PastureDeskEngineTest.php :: testTheCorrectedWalkWinsOverTheOriginalAndKeepsIt |
| Plate meter beats visual, visual beats satellite, and the newer reading wins within a source. A disagreement is shown as a conflict, never averaged. | The budget uses the most trusted number, and disagreements stay visible. | Source precedence (opens in a new tab)Integration/PastureDeskEngineTest.php :: testConflictsAreShownNotAveraged |
| A paddock with no usable observation for 10 days is stale: it adds no feed and is never grazed. A restricted paddock is never allocated. | Missing data removes feed instead of assuming it. | Stale and restricted paddocks (opens in a new tab)Integration/PastureDeskEngineTest.php :: testStaleOrMissingDataNeverAddsFeed |
| Every herd is in exactly one place each day. An applied plan supersedes the previous revision, which the database refuses to UPDATE or DELETE. | Every plan the farm ran can be read back exactly as it was. | Invariants on every candidate (opens in a new tab)Integration/PastureDeskEngineTest.php :: testEveryCandidateKeepsTheInvariants |
System architecture
Key decisions
Version the observations and publish data revisions. The ledger moved into the shared core for its second user.
Why: Every budget and plan records the revision it used, so any past answer can be recalculated. EnergyDesk was the first user of this ledger; the second use was the point to extract it.
Rejected: Overwriting a cover when a correction arrives, which would lose the reading Saturday's plan was made from.
ADR 0009 · versioned observations and publication revisions (from EnergyDesk)
One feed-budget function and a finite, rule-generated set of candidate plans instead of an optimiser.
Why: Four candidates, each explainable line by line, compared before apply; a stale compare returns 409.
Rejected: A general optimiser (LP/MIP): it answers a different question, less transparently, and adds a dependency.
ADR 0011 · feed budget and finite candidate planning
Paddocks as GeoJSON with the area computed once.
Why: The farm map needs polygons to draw and an area per paddock, nothing spatial at runtime.
Rejected: PostGIS: the platform runs plain PostgreSQL, and the product makes no spatial query.
docs/specifications/015-pasturedesk.md
Engineering evidence
Tests
Golden file of the seeded week
Saturday's plan is fine on Saturday's data and 7.9 t DM short on Monday's. Re-planning with the silage in stock leaves 1.6 t short, and so does a shorter rotation: it does not grow grass. Buying silage closes the gap for $2,974.78; the dry cows on the run-off block close it for $2,564.08, including a $1,190 grazing fee, with no feed bought.
Conditions: Seeded fictional Waikato farm: 38 paddocks, 160.8 ha, 320 milking cows, 40 dry cows, 60 young stock; 90 days of history (1,230 reference observations, data revisions 1–47); a 7-day plan from Monday 12 October 2026
Tests
Invariant and contract tests
Invariant tests on every candidate plan, a generator that reproduces the dataset byte for byte, and an OpenAPI-validated contract test of the whole Monday.
End-to-end
Playwright smoke with axe
The whole Monday from the files to the applied plan, plus the farm worker's phone view at 390×844.
Engineering page
“How it's engineered” in the live demo (opens in a new tab)
The full detail: rules, data model, tests and measurements, next to the running product.
I use AI-assisted development for implementation, exploration and review. I remain responsible for architecture, business rules, code quality and deployment. Critical behaviour is verified with deterministic tests, static analysis and reproducible benchmarks.
Trade-offs and limits
- Synthetic, fictional farm
- Simplified planning model: monthly growth rates, and grazed paddocks do not regrow within the week
- No devices, collars, virtual fences, satellites or herd-recording integrations
- Not farm, veterinary or agronomic advice
My contribution
I built PastureDesk as an independent engineering showcase in one working day on my Industry Demo Kit platform: product specification, domain model, backend, frontend, data generator, automated tests and deployment.
Want to discuss the engineering behind this?
Launch demo (opens in a new tab)Get in touch
Source-code walkthroughs available on request.