Project 04 · 2026
OpenRail
Your journey, unreserved — every boardable train between two stations.
Project details
OpenRail answers two questions with one data source: which unreserved trains run directly between two stations, and how to build a whole multi-leg journey out of them — General (II) class, MEMU, locals and passengers. A thin Flask API on Vercel serves station lists and pair timetables scraped from eRail (cached 7 days per pair, 30 for stations, with 700+ pairs committed so cold starts never scrape); the real planning runs in the browser — Dijkstra over a 140-junction corridor graph, then a greedy earliest-arrival simulation that respects running days and change buffers. No booking, no waitlist, no tension.
Built with
- Python
- Flask
- Vanilla JS
- Vercel
The problem, in structure
- Booking-first tools skip the unreserved. Journey planners assume a reservation exists — General (II) class, MEMU and locals never show up.
- millions ride them daily
- no ticket needed to board
- “Trains between stations” stops at one hop. No direct train means a dead end, even when two locals get you there.
- Timetables live locked in apps. No open API — the data exists on rendered pages only.
- Serverless punishes heavy planners. A 30-second function cap and a read-only filesystem kill naive designs.
- Repeat searches re-fetch everything. Without caching, every query scrapes from scratch.
How it answers each one
- Unreserved is the filter, not an afterthought. Class bitmaps (bit 8 = II/General) and type strings keep only boardable trains.
- Multi-leg by design. Corridor routes from a 140-junction graph feed a earliest-arrival simulation that chains locals end to end.
- Parse the pages, serve the data. eRail’s timetable rows are parsed into clean JSON behind three small endpoints.
- Thin server, fat browser. Flask only serves pairs; Dijkstra and the simulator run client-side, well inside the 30-second cap.
- Cache everywhere. 7-day pair JSON, 30-day station mirror, 700+ committed pairs, and localStorage memoisation — the second search is instant.
Architecture
Next phase
- Live running status layered onto the planner.
- Real fares instead of the ₹30 + ₹0.20/km estimate.
- Holiday and special-train patterns in the simulation.
- More committed pairs for colder corridors.
- An offline-ready PWA for stations with weak signal.