Inspiration
Pakistan's smallholder farmers grow roughly a quarter of the country's GDP, yet only about one in ten receives regular advice from an agricultural extension worker — and the advice that exists is rarely in the language they speak. A farmer in Faisalabad does not need a generic tip. He needs to know, for his field, his crop, this week: when do I irrigate, what will my yield be, and what is the mandi paying today?
What it does
AgriYield Advisor is an Urdu-first AI data agent. A farmer asks a question in Urdu script, Roman Urdu, or English — for example, "Is haftay gandum ko pani kab dun?" — and the agent answers with real numbers and real sources: a live 7-day Open-Meteo forecast with irrigation advice computed from it, ISRIC SoilGrids soil data, AMIS Punjab mandi prices, and a yield forecast from a trend model fitted on the real FAO Pakistan yield series (1961–2024), ending in a dated sowing and irrigation plan. New in this build: the forecast's ET0 is turned into a concrete irrigation water need (net mm, litres per acre/hectare); the yield model is backtested out-of-sample on 2020–2024 with two baselines shown; a gross revenue estimate (before costs) is computed from forecast yield × dated reference price; a one-click panel compares wheat, rice and maize side by side for the sowing decision; and a microphone button lets farmers who cannot type ask by voice (Urdu speech recognition, ur-PK). Every answer cites its numbers. The agent is read-only: it queries data, it never writes anything.
How we built it
Next.js 16 + TypeScript on Vercel (Hobby, $0). All logic in Next.js API routes. Live data: Open-Meteo (no key) and ISRIC SoilGrids (no key). Market prices are a curated reference dataset from published AMIS Punjab reports (2–3 Nov 2026), always labelled REFERENCE with its date — never presented as live. The yield model is a transparent linear trend on the real FAO/OWID Pakistan series, national average only, with measured RMSE shown — and now with an honest out-of-sample backtest: fitted excluding 2020–2024 and scored against the real held-out yields (wheat trend MAE 0.090 t/ha vs naive 0.228 and 5-year average 0.207; maize 0.412 vs 0.491 and 1.250; rice 0.168 vs naive 0.182 — but the 5-year average beats the trend for rice at 0.121, reported as measured, not hidden). The water need is net ET0 minus rain over the 7-day forecast (1 mm = 10,000 L/ha = 4,046.86 L/acre), reference demand only — no crop coefficient applied. Gross revenue is forecast yield × reference price per tonne, labelled BEFORE costs; rice gets no revenue estimate because its reference dataset lists three varieties and no variety was picked. The agent is Gemini-primary (gemini-3.8-flash, retry on 503/429) with a deterministic fallback built from the same tool results, always labelled. Tests: 63/63 pass (vitest); production build clean; lint clean.
Challenges we ran into
Two upstream services fought us. Open-Meteo rate-limited our shared VM egress IP, so the live forecast path had to be proven on the deployed site instead. SoilGrids returns null values service-wide right now — the app says so honestly instead of inventing soil numbers. And the ask endpoint was slow (26–35s, sometimes over 90s), so we added an 8-second cap on every upstream fetch and bounded Gemini retries; worst case is now ~25s and live asks measure ~10.7s.
Accomplishments we're proud of
A complete, honest, working product: 63/63 tests, live deployment, every feature verified on the production URL — including the ask pipeline in all three languages — with every number traceable to a named source. Nothing is faked: no invented accuracy, no invented prices, no invented soil — and where the model loses (rice backtest vs the 5-year average), the loss is shown, not hidden.
What we learned
That honesty is a feature, not a limitation: saying "this source is unavailable right now" earns more trust than a plausible-looking invented number. And that latency is a product feature too — a farmer will not wait 90 seconds for an answer.
What's next
Refresh the market reference dataset from the newest AMIS reports, add a second soil depth (5–15 cm) once SoilGrids is stable again, and run the planned 3-farmer pilot to measure real usefulness in the field. (Voice input, added in this build, is already live.)
Built With
- gemini
- isric
- next.js
- open-meteo
- soilgrids
- typescript
- vercel
- vitest