A clean and modular Train Ticket Booking System built in Java using a file-based JSON persistence layer. Designed to demonstrate strong fundamentals in OOP, file handling, CLI-based interaction, password encryption, and service-layer design — all without any external database or UI.
- ✅ User Sign-up & Login (with password hashing using BCrypt)
- ✅ Search trains by source and destination
- ✅ Live seat selection and booking
- ✅ View all personal bookings
- ✅ Cancel ticket by Ticket ID
- ✅ File-based JSON persistence
- ✅ Clean Low-Level Design (LLD) structure with modular services
name(String)password(String, stored hashed)hashedPassword(String)ticketsBooked(List<Ticket>)userId(UUID)
ticketId(UUID)userId(UUID)source(String)destination(String)dateOfTravel(ZonedDateTime)train(Train)
trainId(String)trainNo(String)seats(List<List<Integer>> - 2D layout)stations(List<String>)stationTimes(Map<StationName, Time>)
| Component | Technology |
|---|---|
| Language | Java 21 |
| Build Tool | Gradle |
| JSON Handling | Jackson + jsr310 (for time) |
| Password Hash | BCrypt (secure authentication) |
| Boilerplate | Lombok (getter/setter cleanup) |
| Data Storage | JSON (no external DB used) |
- Users sign up with a password (hashed before saving).
- On login, password is verified using
BCrypt.checkpw().
- Trains are filtered by matching source and destination (in correct order).
- Available seats are shown in a 2D matrix.
- Seat is marked
1when booked.
- Bookings are saved in
users.json. - Seat availability updates in
trains.json.
- User enters ticket ID to cancel.
- Ticket is removed from their booking list.
git clone https://github.com/yourusername/train-booking-java.git
cd train-booking-java