Engineering
Why the highest price is usually the wrong price
Comparing mandi rates across cities is easy and almost always misleading. The comparison that matters nets out spoilage, transport, and time — and it reorders the ranking more often than not.
Five markets, five rates. The naive answer is to take the highest number and drive. The engine behind FreshRoute Agent exists because that answer is wrong often enough to be expensive.
The calculation, in order
For each destination the engine builds a scenario:
- Gross value — quantity × destination rate for the crop, adjusted for the assessed grade.
- Spoilage deduction — an expected loss percentage derived from crop perishability, distance and transit hours, ambient conditions, and whether cold storage is in the path. Tomatoes and leafy vegetables decay steeply; potatoes and onions barely notice the same trip.
- Transport cost — vehicle class and route, quoted per option rather than assumed.
- Timing penalty — value lost to arriving after the morning auction window, or gained by storing and selling into a rising rate.
- Net revenue and a rank — scored on net earnings, risk exposure, and urgency, so a marginally lower but far safer option can win.
A 12% better headline rate 400 km away loses to the local buyer the moment expected spoilage crosses about 9% — and for ripe tomatoes in August it crosses that easily.
Market scenarios — 800 kg tomato, Grade A, Multan
Prices dated 31 Aug 2026
| Market | Rate | Spoilage | Transport | Net revenue | |
|---|---|---|---|---|---|
| Lahore | Rs 400/kg | 6% | Rs 18,000 | Rs 302,000 | Recommended |
| Islamabad | Rs 412/kg | 11% | Rs 31,000 | Rs 262,300 | Spoilage risk |
| Faisalabad | Rs 388/kg | 5% | Rs 14,500 | Rs 280,400 | |
| Multan (local) | Rs 355/kg | 1% | Rs 2,500 | Rs 278,700 | Lowest risk |
| Karachi | Rs 430/kg | 17% | Rs 46,000 | Rs 239,700 | Spoilage risk |
Swipe the table sideways to see net revenue →
Karachi pays the highest rate per kilo and returns the least money. Net revenue is gross value minus expected spoilage, transport and timing loss.
Deterministic on purpose
None of this arithmetic is done by the language model. The model's job is narrow: turn messy human text into structured fields, and turn photos into a grade. Once the lot is structured, a plain, testable calculation engine takes over.
That split matters. Model outputs vary between calls; a price comparison must not. It also means the app stays useful in DEMO mode — if the model is unreachable, the seller still gets a correct spoilage-adjusted ranking, just with less forgiving text parsing.
What the seller actually sees
Not a spreadsheet. Each scenario is a card: destination, expected net, the spoilage assumption stated in plain language, transport cost, and the arrival window. Ranked, with the reasoning shown rather than hidden behind a score. If the recommendation is to sell locally at a lower rate, the card explains that the difference would have decayed on the road.
Where it's still weak
Our price table is static and timestamped, not a live feed — the honest limitation of building without an official rate API. Spoilage coefficients are literature-derived starting points, not measurements from thousands of shipments. Both improve with usage data, and both are visible in the interface rather than presented as certainty.