RailBook
Train ticket booking as microservices, on Kubernetes
M.Tech coursework, BITS Pilani (Scalable Services)
The problem
Two people press Book on the last seat at the same moment. Exactly one of them should get it, even with several replicas of each service and a network that drops calls.
What I built
- Two FastAPI services, inventory and booking, each owning its own PostgreSQL deployed as a StatefulSet.
- A booking saga: hold seats, take payment, confirm; on any failure, compensate by releasing the seats.
- No overbooking: seat holds lock the schedule row (SELECT … FOR UPDATE), so concurrent requests on any replica can't sell the same seat twice.
- Resilient calls: 3-second timeouts and 3 retries with exponential backoff, made safe by using the PNR as an idempotency key.
- Probes, resource limits, ConfigMaps and Secrets; an HPA scales inventory from 2 to 5 pods under load.
- GitHub Actions tests each service and pushes its image to Docker Hub.
- Kubernetes
- FastAPI
- PostgreSQL
- Docker
- GitHub Actions
- HPA