Skip to content
All work

Realtime · 2026

Private

JUTC Live

Real-time bus tracking built for prepaid data and patchy signal.

Overview

Live tracking for Jamaica's public bus service. Driver phones run a PWA that queues GPS pings offline and uploads them in batches; riders poll a compact live view that shows where the bus is and how stale that answer is.

The hard part

Deriving a bus route from the buses themselves

There was no route geometry to work from, so the corridors are derived from the traces. Nightly, each route's recent shifts are cleaned, projected into UTM 18N so the maths is metric, and the consensus route is taken as the medoid — the trace with the lowest mean Hausdorff distance to all the others. It is robust at tens-of-traces scale without any clustering machinery. Segments that escape a 150m buffer around the consensus and run at least 300m are kept as offshoots with a support count, and drawn thinner on the rider map. I also chose HTTP polling over WebSockets deliberately: driver uploads are batched every 30 to 60 seconds anyway, so polling matches the real freshness with far less machinery and behaves better on prepaid data.

What it does

  • Crash-safe IndexedDB ping queue that preserves the original recording time
  • Server-side plausibility filter: Jamaica bounds, timestamp windows, accuracy ceiling, teleport rejection against a max plausible speed
  • Live store in Redis holding latest position plus a ten-point trail, ageing out at ten minutes
  • Compact array payloads with an explicit staleness value, so markers fade honestly instead of lying
  • Every architectural decision logged with its reasoning in a decision changelog

What it proves

  • Choosing boring technology on purpose, and being able to justify it
  • Geospatial analysis with PostGIS beyond storing a point
  • Designing honestly for degraded conditions rather than the happy path

Stack

  • Next.js 16
  • TypeScript
  • PostgreSQL
  • PostGIS
  • Redis
  • Google Maps
  • Web Push
  • PWA

Related