Navigation

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

PastureDesk plan review for "Dry cows to the run-off block": the deficit going from 7.9 t DM to 0.0 t DM, 4.3 t DM of supplement from stock, a cost of $2,564.08, the dry cows on the run-off block all week, and an explanation drafted from computed facts under an AI suggestion notice.

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

  1. Step 1

    PastureDesk Monday morning after the files arrive: six open exceptions, including the farm worker's note that P16 is a swamp, satellite and plate-meter disagreements on P03, P27 and P35, no usable observation on P09 for 12 days, and the current plan already 4.4 t DM short.
    Monday 06:30: the files arrive. Conflicts are listed, never averaged; a paddock without recent data adds no feed.
  2. Step 2

    PastureDesk farm map of 38 paddocks shaded by cover, with blocked, stale and conflict markers, and paddock P12 open beside it: "Corrected: Saturday's walk read 2280" and every observation version with its source, cover, data revision and time received.
    P12's corrected walk is a new version at revision 50; Saturday's reading at revision 46 stays.
  3. Step 3

    PastureDesk plan comparison as of data revision 52: the current plan 7.9 t DM short, then four candidates. Dry cows to the run-off block (recommended) at $2,564.08 with no deficit, Buy silage at $2,974.78 with no deficit, and Re-plan the rotation and Shorten the rotation to 21 days, both still 1.6 t DM short.
    With P16 blocked, Saturday's plan is 7.9 t DM short. Four candidates, one budget function, compared before apply.
PastureDesk farm worker view on a phone for Monday 12 October, plan revision 2: the milking herd grazes P18 then P08, young stock P10, dry cows on the run-off block, and a Do not graze list with P31 regrassing, P22 withholding, P05 effluent and P16 waterlogged.
The farm worker's day on a phone (390 × 844), after the new plan is applied.

Engineering invariants

Rules the system enforces whatever the user does, and where each one is proven.

InvariantWhy it mattersEvidence
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

PastureDesk system architectureBrowser, then a React and TypeScript single-page app, then a Symfony modular monolith with the Pasture module, then PostgreSQL: row-level security isolates every demo session. The backend calls an AI adapter: AI structures the farm worker's note into restrictions with a quote for every value (there is no field for a cover) and drafts the plan explanation from computed facts only. It never calculates feed, lifts a restriction or chooses a plan.BrowserAnonymous demo session · guided scenarioReact + TypeScriptSingle-page app · Playwright end-to-end + axeJSON · RFC 9457 problem detailsSymfony modular monolithPasture moduleobservation versions · feed budget · candidate planstransactions · constraintsPostgreSQLRow-level security isolates every demo sessionAI adapterJSON schema + semanticvalidation · fixture modeby default · no AI numbersDocker + Caddy on a shared 4-vCPU host · synthetic data only
AI structures the farm worker's note into restrictions with a quote for every value (there is no field for a cover) and drafts the plan explanation from computed facts only. It never calculates feed, lifts a restriction or chooses a plan.

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.