Case study 04 / 042026
Jatri
- My part
- All of it: product, design, API, worker, deploy
- Used by
- Friends and family, by invite
- Try it
- demo.railway.silverfish.dev, no invite needed
- Built with
- Next.js 16, Hono, SQLite, web push, passkeys
- Also
- A Firefox add-on and an Android app
- Tests
- Over 200, with node:test
Every direct train sold out? There's often still a way.
A seat finder for Bangladesh Railway. The real one is invite-only, for friends and family; anyone can try the demo. It watches a route and sends a push the moment a seat opens. When the direct trains are full it looks for what the railway would still sell: a longer ticket on the same train, two tickets split along the way, a change at a real junction, or, in a deep search, the whole line ticket by ticket.
Where it stood
Bangladesh Railway sells tickets online, and on the routes people actually travel the direct trains are often sold out. Seats do come back when someone cancels, but only to whoever happens to be refreshing at that moment.
And sold out isn't the whole story. The railway sells its seats in quotas for each stretch of the line, so a longer ticket on the same train, or two tickets split at a station on the way, can have seats when the direct one doesn't. Nobody checks all of those by hand.
What I decided
A push the moment a seat opens
A watch is a route, the days and the classes you'd take. A worker checks it on a jittered interval, one request per login, route and day however many watches share it, and alerts once per opening, not every time it looks.
Find a way, planned from the public timetables
When the direct trains are full, the planner works out from the free timetables which other tickets could work: a longer ticket on the same train, two tickets split at its busiest stops, or a change at a real junction, never a detour much slower than the fastest way. Then it asks the railway only about those, at most 24 searches, 1.5 seconds apart.
A deep search, the line ticket by ticket
From every station a chain of tickets with seats can reach, it tries every ticket onward, destination first. It learns which stretches each train doesn't sell online and doesn't ask about them again for three weeks. When nothing gets all the way, it shows the closest chains and what could cover each gap.
Your railway login, kept to a minimum
Jatri needs your login to the railway's site to search. A small add-on hands it over after you log in on the railway's own page, so your password never reaches me. Sign-in to Jatri itself is passkeys only, and every personal value in the database (routes, dates, seats, the railway login) is sealed with AES-256-GCM, backups too.
What changed
| Measure | Before | After |
|---|---|---|
| When a seat comes back | Refresh and hope | A pushonce per opening |
| When the direct trains are full | Give up | Other wayschecked for you |
| Tickets checked in a deep search | One at a time, by hand | Up to 3501.5 s apart |
Before is checking the railway's own site by hand. The screens on this page run on sample seats over the real timetable, so they don't show anyone's journey.
What I'd do next
A signed build of the Firefox add-on, so installing it is one tap instead of a developer's detour, and Bangla names for every station on the map.