🚆

System Design for IRCTC Booking Platform

Mar 23, 2025

System Design Mock Interview: Designing IRCTC

Introduction

  • Interview conducted by Kirti with an expert known for system design.
  • Focus is on a complex system design, specifically for IRCTC (Indian Railway Catering and Tourism Corporation).
  • IRCTC is a train booking website for booking seats on trains.

Key Features to Design

  1. Schedule of Trains

    • Need a rough schedule for trains traveling from one location to another.
    • Trains have routes with multiple stops.
    • Users need to see available seats and book them.
    • Support for booking multiple seats.
    • Routes can change based on dates.
    • Maximum booking allowed is 3 months in advance.
  2. Search Feature

    • Users can search for trains between a source and destination for specific dates.
    • Show a list of available trains, timings, and other details.
  3. Concurrent Bookings

    • Handle multiple users booking the same seat simultaneously.
    • Atomicity guarantees to ensure transactions are complete or rolled back.

Additional Requirements

  • Consideration of cancellation policies.
  • No booking if cancellations occur before money is debited.

Design Considerations

Train Service

  • Components of a Train
    • Train ID, schedule, seating arrangement (simplified assumption).
    • Use of SQL database due to manageable scale (around 1 million records).
    • Important to handle search queries efficiently.

Searching Trains

  • Implement indexes on estimated departure and arrival times for efficient querying.
  • Considerations for handling multiple stop searches and transitive relations between source and destination.
  • Discussed potential use of graph databases for complex route mappings.

Booking Seats

  • Address concurrent booking issues with locking mechanisms (pessimistic and optimistic locks).
  • Booking involves decrementing seat availability between multiple stations.
  • Discussed seat assignment and cancellation impacts.
  • Handling of scenarios where users need to change seats or partial bookings occur.

Feedback and Observations

  • Importance of defining scope and requirements explicitly (e.g., focus on train booking only).
  • Discussion on handling high load scenarios like 'Tatkal' booking.
  • The need for communication with the interviewer during design discussions.
  • Recognize system complexity and potential features beyond basic booking.

Conclusion

  • The interview addressed key design aspects but noted missing considerations for certain use cases.
  • Emphasis placed on the need for more interactive problem-solving with the interviewer.
  • General feedback on improving questioning and involving the interviewer more in discussions.
  • Overall, a valuable learning experience for system design interviews.

Additional Notes

  • Potential scope for future design discussions including other IRCTC functionalities like hotel bookings, catering, etc.
  • Importance of early estimation and assumptions in the system design process.