// real-time transit tracking

locate-my-bus

Halifax Transit — live vehicle positions on a map

A C++ daemon fetches GTFS-RT vehicle position data from Halifax Transit every 30 seconds, upserts it into PostgreSQL, and serves it to a Leaflet.js map in the browser. No duplicates. No page reloads. Just buses.

locate-my-bus map screenshot

C++ daemon

Downloads the GTFS-RT protobuf feed from Halifax Transit every 30 seconds, deduplicates by vehicle ID, and upserts positions into PostgreSQL.

PostgreSQL

Stores one row per vehicle — ON CONFLICT (vehicle_id) DO UPDATE keeps only the latest position, no duplicates ever.

Node.js / Express

Exposes GET /:route_id which queries the DB and returns JSON. Also serves the static frontend.

Leaflet.js map

Polls the API every 30 seconds, clears old markers, and re-renders updated vehicle positions. Click any marker for route, speed, and timestamp details.

C++17 protobuf libcurl libpqxx PostgreSQL Node.js Express Leaflet.js Dev Containers

$ 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

make run

Daemon starts polling Halifax Transit and writing to the DB.

$ 05

npm run dev

Open http://localhost:3000 to see the live map.