Real-time BMTC. Ambulance alerts. One app.
A production-grade commuter app for Bangalore — live bus tracking from real BMTC APIs, ML crowd prediction, emergency ambulance corridor awareness, community safety reports, and offline-first route caching. Bilingual in English and Kannada.
The problem
Bangalore has one of India's largest public bus networks — over 6,500 BMTC buses on 2,500+ routes serving millions of daily commuters. Yet most commuters rely on guesswork: no reliable app tells you whether your bus is on time, how crowded it will be, or whether you should leave now or wait.
The brief went beyond basic tracking. Bangalore traffic has a genuine emergency vehicle problem — ambulances routinely get stuck in gridlock because drivers don't know they're approaching. And for women commuting late at night, safety visibility matters as much as arrival times.
The challenge was building something that worked offline too — Bangalore's mobile data coverage is inconsistent across the city.
What we built
The backend integrates with BMTC's API across 25+ endpoints, with a fallback chain through GTFS-RT → NammaBMTC → Transitland → mock data. PostGIS handles all geo queries with sub-metre accuracy. Redis 7 manages ETA caching, real-time pub/sub, and rate limiting. Socket.IO pushes live updates to connected clients with exponential backoff and an offline event queue.
The ambulance corridor alert system calculates bearing and distance in real time — when an emergency vehicle comes within 600 m, every app in that corridor gets a push notification with direction and estimated intercept time. This required sub-second pub/sub latency and precise geo-fencing, both handled through PostGIS + Redis geospatial indexes.
Community safety reports use a trust scoring system with duplicate detection. Reports auto-expire after 2 hours. Rate limiting is per-user per-endpoint (100 req/min normal, 10 req/min for reports) to prevent abuse.
The Expo app is offline-first using TanStack Query v5 with AsyncStorage persistence. Saved commute routes trigger smart leave-now notifications 5 minutes before the calculated departure window. Mappls SDK powers maps, routing, and nearby POI discovery with India-specific geocoding.
Architecture highlights
The server runs Node.js 22 + Express 5 in PM2 cluster mode behind Nginx, with TLS termination and WebSocket proxying configured for zero-downtime deploys. Docker Compose wires everything — API, PostgreSQL, Redis, and Nginx — in a single command for both dev and production.
GTFS static data import populated 1,000+ real BMTC stops. Google OAuth via expo-auth-session handles login. Twilio sends OTP and SOS SMS alerts to trusted contacts when a user triggers the emergency mode.