// real-time transit tracking
locate-my-bus
Any GTFS-RT agency — live vehicle positions on a map
Onboard any GTFS-compatible transit agency, and a C++ daemon fetches live vehicle positions every 15 seconds, stores them in PostgreSQL, and serves them to an Azure Maps browser client. Your location is tracked in real-time — the nearest bus is automatically pinned and its route drawn with animated SVG overlay. The pinned bus animates smoothly along the route between polls. Dynamic agency and route selectors, pinnable markers, light/dark theme, and a built-in poll monitor dashboard.
preview
how it works
Agency onboarding
Provide a GTFS static zip URL and a GTFS-RT feed URL. The server downloads the zip, parses agency.txt and routes.txt, and inserts them into PostgreSQL in a single transaction.
C++ daemon
Reads all onboarded agencies from the DB every 15 seconds. Groups them by unique feed URL, downloads each distinct feed in parallel (bounded by CPU core count), then replaces live vehicle positions in PostgreSQL. Per-poll metrics are recorded for the monitoring dashboard.
PostgreSQL
Stores agencies, routes, shapes, trips, and live positions. ON DELETE CASCADE keeps everything consistent when an agency is removed.
Node.js / Express
Exposes GET /live/:agency_id/:route_id for live positions, GET /routes/:agency_id for route lists, and a CRUD API for agencies. Write operations require an x-access-key header.
Azure Maps (SDK v3)
Dynamic agency and route selectors populate from the API. Polls every 15 seconds. The browser Geolocation API tracks your position as a pulsing blue dot — the nearest bus is auto-pinned each poll and its route drawn as an animated SVG overlay. The pinned bus animates smoothly along the route shape between polls. Every bus popup shows its distance from you. Click a marker to manually pin it; click the map background to return to auto-pin. Light/dark theme and zoom position persist across sessions.
built with
getting started
$ 01
git clone git@github.com:ranjitp16/locate-my-bus.git && cd locate-my-bus
$ 02
make get-protobuf-headers && make build
Or open in a Dev Container to skip local dependencies entirely.
$ 03
psql -U postgres -d locate_my_bus -f db/schema/init.sql
$ 04
npm run dev
Open http://localhost:3000 and use Manage Agencies to onboard a GTFS agency.
$ 05
make run
Daemon polls all onboarded agencies every 15 s and writes live positions to the DB.
$ 06
http://localhost:3000/view-map
Select an agency and route — buses appear within 15 seconds.