
Software Engineer, Christian ✝️
Dar es Salaam, Tanzania
Joined September 2018
- Tweets279
- Following331
- Followers51
- Likes2.8K
Repo: [github.com/nelsonfrank/city-…](github.com/nelsonfrank/city-…)
Following along? I’ll share what breaks.
#buildinpublic #SystemDesign #Golang
22
Transit routing isn’t classic shortest-path.
Schedules are time-dependent and delays change everything.
5
My fix:
• Namespace every ID (agency1:1, agency2:1)
• Keep shared stops separate
• Link them with a near-zero-cost transfer edge
• Then route with RAPTOR
9
Interesting architecture problem I hit.
Two transit agencies both use stop ID “1” , but they mean two completely different places.
5
Stack:
• Go → routing, search, realtime (latency-critical paths)
• Python → GTFS ingestion (messy feed parsing)
• Kong + Postgres + Redis, all on Kubernetes
Why polyglot? Use each language where it’s strongest.
21
Ingestion Service, Part 5: Most transit apps fail before the first route is calculated.
They fail at ingestion.
Here’s how the ingestion service in City Connector, our multi-agency routing platform, keeps bad data away from the router. 🧵
5
25
Schedule updates: the Routing Service builds the new in-memory timetable in the background, then swaps it in atomically.
In-flight queries finish on the old version. Zero downtime, no dropped requests.
2
Shared transit hubs: we don’t merge stops across agencies. Merging risks false matches and corrupted schedules.
They stay separate, joined by a near-zero-cost transfer edge. Riders still switch operators smoothly.
1
The pipeline:
1. Validate structure and references in staging
2. Namespace every ID as {agency}:{id}
3. Load into PostgreSQL + PostGIS with version tags
4. Precompute walking footpaths
Routing never does spatial math at query time.
5
The problem: every agency publishes its own GTFS feed, and IDs are only unique within that feed.
Agency A’s stop “1001” and agency B’s stop “1001” can be different places. One collision and the router sends riders to the wrong stop.
17
Stop And Search Service, Part 4: Transit apps live or die on how fast the map shows nearby stops. Here’s how I designed the search service for City Connector 🧵
Co-located stops from different agencies are never merged. A derived hub ID groups them in the UI without touching the data model.
3
The sneaky bug: Routing hot-swaps its timetable, but Search reads Postgres directly. Without a shared active-version pointer, riders can tap stops the router doesn’t know. Version goes in every cache key too.
3
Nearby stops use a two-stage PostGIS query: ST_DWithin bounds the candidates, then KNN ordering ranks them. Short statement timeouts keep slow queries from draining the pool.
3
Why a separate service? Journey planning is CPU-bound (RAPTOR). Stop discovery is I/O-bound (spatial queries). Split them so a rush-hour routing spike can’t freeze the map.
12
How do you find the fastest route across a city when 5 agencies publish 5 different timetables?
Here's how our transit routing service works 🧵
5
24
New schedule? Build a fresh snapshot in the background, then swap one pointer.
In-flight queries finish on the old copy. Zero downtime, zero dropped requests.
3