This is the interview experience for round 2 for SDE2 at Zepto.
Round 1 : https://leetcode.com/discuss/interview-experience/5711152/zepto-sde-2-round-1/2601252
Design LLD of IRCTC train ticket booking system
Functional Requirements:
- Users should be able to search trains by train number and via source, destination and date.
- Users should be able to see the number of available seats, given the train, source, and destination and date
- Users should be able to book tickets (The system should be able to handle concurrent booking requests in a fair manner).
- Seat Reusability of booked seats IS allowed. (User A books a seat S1 from station1 to station2 then UserB should be able to book the same seat S1 from station3 onwards).
- Users should be able to cancel a booked ticket.
Assumptions:
- A train will run from source to destination once a day. In the case of the reverse journey, the ID of the train will change and it will be treated as a new train itself.
- To keep things simple, we will not consider the berth and coach preference in this article.
- There will be only one coach in a train.
- We will also only book tickets that are confirmed, waitlisting is not supported.
Discussed the solution step wise.
- Flow
- Actors and Actions
- Entities and Relationship
- DB Design
Interview was more interested on DB design. Explained the DB design using SQL. Started with these entities -
- User
- Train
- Seat
- Booking
For seat reusablity, introduced a new entity segement. Interviewer was focussed on design more than actual implementation
Please feel free to post the solutions for above in the comments :)