Back to Programming

Case study

Route Optimization Planner

Turns client visits into optimized weekly routes for a field-service company. Built solo.

Oct 2025 — Nov 2026 Client anonymized · screenshots use seeded test data
React 19
TypeScript
Hono
TanStack Query
Cloudflare Workers
Cloudflare D1
Cloudflare Access
Google Route Optimization API
Google Maps
Workbox PWA
Download PDF

Weekly plan

Weekly planning modeled as a Vehicle Routing Problem: each day is a vehicle, each client a visit, with arrival times and daily distance.

Weekly plan with five day columns listing client visits, arrival times and daily distance (opens full-size image in a new tab)
Tap to open full size

Week map

All routes of the week on one map, with per-day client count, distance and drive time.

Map with color-coded routes for each weekday and a weekly summary panel (opens full-size image in a new tab)
Tap to open full size

Day route

Day view with manual adjustments, pinned visits and a one-click navigation deep link to Google Maps.

Day view with an ordered list of visits next to a map showing the route between them (opens full-size image in a new tab)
Tap to open full size

Under the hood

  • Vehicle Routing Problem solved on Cloudflare Workers with the Google Route Optimization API
  • When the owner reported shorter manual routes, built a result-explanation panel and a route comparison; the diagnosis pinpointed a solver penalty that added 11% distance in a test
  • Server-side roles with Cloudflare Access JWTs and an employee panel synced with Access
  • Workbox PWA with offline field preview and data clearing on logout
  • API cost guards below free-tier limits, a pnpm monorepo with 168 tests and GitHub Actions running migrations before deploy

Technical details

Modeling the week as a routing problem

Each working day is a vehicle and each client is a visit, so one solver call plans the whole week: it assigns visits to days and orders them into routes. Pinned visits keep their day and time, and the planner UI (React 19, TanStack Query, Google Maps, Hono RPC) lets the owner adjust the result by hand.

Explaining the solver instead of trusting it

The owner reported that his manual routes were shorter. Instead of tuning blindly, I built a result-explanation panel and a side-by-side route comparison. That made the cause visible: a solver penalty that added 11% distance in a test.

Access, offline use and costs

Roles are enforced server-side from Cloudflare Access JWTs, with an employee panel synced with Access. A Workbox PWA gives field staff an offline preview and clears data on logout. Custom guards keep API usage below free-tier limits (D1, Cloud Monitoring).

© 2026 Oskar T.T