Design a Train Ticket Booking System
Company: Nielsen
Role: Backend Engineer
Category: Software Engineering Fundamentals
Interview Round: Technical Screen
Machine-coding exercise, 90 minutes.
Design and implement a train ticket booking system. The implementation should be close to working code and should follow object-oriented design, SOLID principles, and clean API boundaries.
Core requirements:
1. Search trains between two stations.
2. Check seat availability for a train, date, origin station, and destination station.
3. Book tickets for one or more passengers.
4. Bonus: Cancel a booking and process a refund.
Your solution should include:
- Public APIs or service methods for search, availability, booking, and cancellation.
- A data model or database schema based on the chosen datastore.
- Clear domain objects, services, and repositories.
- Handling of basic validation, errors, and concurrency issues such as two users trying to book the same seat at the same time.
Quick Answer: This question evaluates a backend engineer's competency in object-oriented design, SOLID principles, API and service design, data modeling, concurrency control, and transactional reservation handling.