Design a Train Ticket Booking System
Problem Description
Design and implement a train ticket booking system. The solution should be close to working code, adhering to object-oriented design principles, SOLID principles, and clean API boundaries. The exercise is expected to take approximately 90 minutes.
Core Requirements
- Search Trains: Enable users to search for trains operating between a specified origin and destination station.
- Check Seat Availability: Provide functionality to check the availability of seats for a given train, date, origin station, and destination station.
- Book Tickets: Allow users to book tickets for one or more passengers.
- Cancel Booking (Bonus): Implement the ability to cancel an existing booking and process a refund.
Solution Components
Your implementation should include:
- Public APIs or service methods for all core functionalities: search, availability, booking, and cancellation.
- A data model or database schema, based on your chosen datastore, to represent the system's entities and relationships.
- Clear separation of concerns through well-defined domain objects, services, and repositories.
- Robust handling of basic validation, error conditions, and concurrency issues, specifically addressing scenarios like multiple users attempting to book the same seat simultaneously.
AI interview prep
Core dilemma
Balancing robust concurrency control for critical resources (like seat availability) with a clean, extensible object-oriented design within a constrained implementation timeframe.
3 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design a Train Ticket Booking System
Problem Description
Design and implement a train ticket booking system. The solution should be close to working code, adhering to object-oriented design principles, SOLID principles, and clean API boundaries. The exercise is expected to take approximately 90 minutes.
Core Requirements
- Search Trains: Enable users to search for trains operating between a specified origin and destination station.
- Check Seat Availability: Provide functionality to check the availability of seats for a given train, date, origin station, and destination station.
- Book Tickets: Allow users to book tickets for one or more passengers.
- Cancel Booking (Bonus): Implement the ability to cancel an existing booking and process a refund.
Solution Components
Your implementation should include:
- Public APIs or service methods for all core functionalities: search, availability, booking, and cancellation.
- A data model or database schema, based on your chosen datastore, to represent the system's entities and relationships.
- Clear separation of concerns through well-defined domain objects, services, and repositories.
- Robust handling of basic validation, error conditions, and concurrency issues, specifically addressing scenarios like multiple users attempting to book the same seat simultaneously.