Route Orchestrator
Route optimization (TSP) · 70+ daily stops · real driving distances
Overview
Route Orchestrator solves one hard constraint: turning 70+ raw daily delivery stops into the shortest real-world driving sequence. My wife runs daily deliveries in Araxá, MG; Google Maps and Waze route between points you already ordered, but they don't optimize the sequence of dozens of stops, which left her doing wasteful back-and-forth through the same neighborhoods.
I built it end-to-end as a solo project. It started as a Python CLI that geocodes raw CEPs/addresses and solves the Travelling Salesman Problem using real driving distances (not straight-line), respecting one-way streets, grouping nearby houses, and following a pre-configured neighborhood order. It then evolved into a full Next.js 15 PWA with an interactive map, drag-and-drop stop reordering, live route tracking, route history, a cost calculator and per-route profit tracking.
Key technical decisions
- TSP on real driving distances: optimize the stop order against an actual road-distance matrix, not haversine, so the sequence respects one-way streets and real travel time.
- Automatic geocoding pipeline: paste a raw list of addresses/CEPs; the system geocodes each, clusters nearby houses into a single stop, and keeps a reusable catalog of people and houses.
- Offline-first PWA: built with Next.js 15 + Serwist so the driver can run the route on a flaky mobile connection in the field.
- Interactive ops UI: MapLibre GL map with numbered optimized markers, dnd-kit drag-and-drop manual overrides, and TanStack Query for data sync.
Results
In daily production use it plans routes of 70+ stops, tracks completion (95%+ of stops completed), distance, duration and per-route gross/net with profit margin. It replaced spreadsheets and manual ordering with a single tool that turns a raw address dump into an optimized, trackable route in seconds.
Stack: Next.js 15, TypeScript, React, MapLibre GL, dnd-kit, TanStack Query, Serwist (PWA), Tailwind, and a Python geocoding/TSP engine.