Mileage Cache

Route mileage cache — powers Pricing Brain confidence scores

Provider Resolution Order

1. Cache — Any prior resolved mileage (90-day TTL). Fastest, inherits original confidence.

2. Historical lane data — Average of recorded mileage from PricingHistory rows for this lane pair (≥3 rows required, MEDIUM confidence).

3. OpenRouteService — Real road routing via state centroids (HIGH confidence). Requires OPENROUTESERVICE_API_KEY env var.

4. Haversine fallback — Straight-line × 1.20 road factor (MEDIUM confidence). Lowers overall pricing confidence to LOW when used without history.

To plug in a new routing provider: add a _provider_route() function in backend/app/services/routing.py and insert it between tiers 2 and 4.

0 entries shown
Loading…