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.

A truck loaded with sacks of onions on a dusty rural highway at golden hour
Distance is not a cost line. It is a decay curve with a cost line attached.

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:

  1. Gross value — quantity × destination rate for the crop, adjusted for the assessed grade.
  2. 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.
  3. Transport cost — vehicle class and route, quoted per option rather than assumed.
  4. Timing penalty — value lost to arriving after the morning auction window, or gained by storing and selling into a rising rate.
  5. 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.

freshroute.app/chat · scenarios

Market scenarios — 800 kg tomato, Grade A, Multan

Prices dated 31 Aug 2026

MarketRateSpoilageTransportNet revenue
LahoreRs 400/kg6%Rs 18,000Rs 302,000Recommended
IslamabadRs 412/kg11%Rs 31,000Rs 262,300Spoilage risk
FaisalabadRs 388/kg5%Rs 14,500Rs 280,400
Multan (local)Rs 355/kg1%Rs 2,500Rs 278,700Lowest risk
KarachiRs 430/kg17%Rs 46,000Rs 239,700Spoilage 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.

Spoilage-adjusted comparison across five markets. Karachi has the highest rate per kilo and the lowest net revenue.

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.