DGIS — delivery district planning
Livesince 2026 · first prototype 2023
My own multi-tenant SaaS for newspaper delivery organisations: draw a district on the map, and DGIS computes the real walking route and a fully itemised delivery time, with a solver that proves the route is the shortest.
Publishers pay delivery staff by the hour, so the time a district takes is a cost question — and the usual estimates are rough. DGIS models delivery as what it actually is: walking streets, not visiting points. Python and geodata on the backend, React and MapLibre on the frontend, shipped through a blue-green pipeline with zero-downtime switches.
Context
Newspaper publishers and delivery organisations plan hundreds of delivery districts, and every one of them is paid by time. Their operational systems store the districts, but cannot answer the planning questions: how long does this district really take, what changes if I move its boundary, which variant is cheaper overall? DGIS is the decision-support layer next to those systems — it does not replace them. A first prototype dates from 2023; the current product is a complete rebuild started in 2026.
What I built
- Routing as a Rural Postman Problem rather than a TSP: the tour must cover every street segment with deliveries, using any other path as a connector. Construction via Frederickson's heuristic (matching odd-degree nodes, Euler tour), followed by redundancy pruning.
- An exact integer-programming solver (HiGHS via SciPy, LP relaxation with min-cut connectivity cuts) checks every route in the background and proposes shorter ones with the saving in metres and minutes.
- Geodata pipeline: footpath networks from OpenStreetMap (OSMnx, NetworkX, pyosmium), address points within a polygon, elevation from the Copernicus DEM with a Tobler walking-speed surcharge, automatic district splitting.
- A transparent time model: every minute is attributed to an adjustable line item (walking, connectors, slopes, mailboxes, reloading). Backend (Python) and frontend (TypeScript) compute identically, verified against shared golden files, so parameters can be changed live without a recompute.
- Outputs for daily work: route sheets and a verifiable time-evidence PDF (ReportLab), a playable tour simulation with MP4 export, share links with QR code, and a separate mobile app for delivery staff.
- Platform: multi-tenancy, roles and per-module licences, cookie sessions with Argon2 hashes, CSRF protection and login throttling, an audit log, Excel import hardened with defusedxml, Claude-based data extraction.
- Operations: Docker Compose and Caddy on Hetzner Cloud, GitHub Actions CI/CD to GHCR and rollout over SSH, blue-green with a password-protected pre-prod colour, a database backup before every deploy, and expand/contract migrations that are checked automatically.
- Built AI-assisted with Claude Code: I own the domain model, the architecture and every review; the agent works inside the same tests, linters and CI gates as any other change.
Outcome
Live as a prototype and in use for demos. Over 600 backend tests plus Vitest and Playwright on the frontend. Next up: making costs visible per district and courier, then scenarios that compare whole assignments of districts to couriers — every proposal backed by numbers, never just asserted.
Architecture
Two React 19 apps (planning and courier) and a shared package in an npm-workspaces monorepo, built with Vite. A FastAPI backend with SQLAlchemy 2 and Alembic on PostgreSQL + PostGIS. Caddy serves the frontends and terminates TLS. Two backend colours run side by side on one database; a push only reaches the inactive colour, and going live is an explicit swap — which is why every migration must stay backwards-compatible for one release.
Stack
- Python
- FastAPI
- PostGIS
- Graph algorithms
- React
- MapLibre
- Docker
- Blue-green deploy