List functional requirements for the system (Ask interviewer if stuck)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Assumptions:
Estimations:
This can be handled using single server. Even during peak hours we can easily scale by adding a load balancer.
Data storage estimation:
Define what APIs are expected from the system...
We have 4 APIs here. 1 for viewing events and 2 for booking tickets.
We use GET endpoint that takes in an eventID and return the details of that event.
GET /events/details/{eventId}
->
{
eventId,
city,
venue,
performer,
date,
tickets []
...
}
The ticket booking process is divided into two steps:
The user first chooses a specific seat or ticket to buy.
They then progress to a payment page to complete the purchase.
We want to guarantee that once a user selects a ticket, it is reserved for them until they complete the purchase, preventing it from being bought by someone else while they try to check out.
We’re going to need two API endpoints, one for each of the steps in the process:
POST /booking/reserve
->
{
bookingId,
ticektIds []
}
POST /booking/confirm
->
{
bookingId,
isSuccess
}
For search, we just need a single GET endpoint that takes a set of parameters and returns a list of events that match those parameters.
GET /events/search?keyword=&start=&end=&city=&page=
->
{
eventIds []
}
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
classDiagram
class Users {
- UserID: string
- UserName: string
- Email: string
- PasswordHash: string
...
}
class Events {
- EventID: string
- EventName: string
- Description: string
- Cast: string
- Genre: string
- TrailerURL: string
- VenueID: string
...
}
class Venues {
- VenueID: string
- VenueName: string
- CityID: string
...
}
class City {
- CityID: string
- CityName: string
...
}
class Bookings {
- BookingID: string
- UserID: string
- EventID: string
- SeatIDs: array
- BookingDate: datetime
...
}
class PaymentInformation {
- PaymentID: string
- BookingID: string
- Amount: float
- PaymentDate: datetime
- PaymentStatus: string
...
}
class Seats {
- SeatID: string
- EventID: string
- VenueIDID: string
- SeatNumber: string
- SeatStatus: string
...
}
Users --o Bookings
Users --o PaymentInformation
Bookings --o Seats
Bookings --o Events
Venues --o City
Events --o Venues
Events --o Seats
Seats --o Venues
PaymentInformation --o Bookings
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design...
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
sequenceDiagram
participant User
participant UI as "User Interface"
participant Search as "Search Service"
participant Ticketing as "Ticketing Service"
participant Booking as "Booking Engine"
participant Database as "Event Database"
participant CinemaAPI as "Cinema Partner API"
participant PaymentGateway as "Payment Gateway"
User ->> UI: Opens App
UI ->> UI: Displays Movie List
User ->> UI: Searches for a Movie
UI ->> Search: SearchMovie("Avengers")
Search -->> UI: Returns Search Results
UI ->> UI: Displays Search Results
User ->> UI: Selects Movie (Avengers)
UI ->> Ticketing: GetMovieDetails("Avengers")
Ticketing -->> UI: Returns Movie Details
UI ->> Ticketing: GetAvailableShowtimes("Avengers", "CityA")
Ticketing -->> UI: Returns Showtimes
User ->> UI: Selects Showtime
UI ->> Ticketing: GetSeatAvailability("Avengers", "CityA", "Showtime1")
Ticketing -->> UI: Returns Available Seats
User ->> UI: Selects Seats
UI ->> Ticketing: BookSeats("Avengers", "CityA", "Showtime1", ["A1", "A2"])
Ticketing -->> Booking: CreateBookingRequest("Avengers", "CityA", "Showtime1", ["A1", "A2"])
Booking -->> Ticketing: ConfirmBooking("BookingID123")
Ticketing -->> PaymentGateway: ProcessPayment("BookingID123", "Amount")
PaymentGateway -->> Ticketing: PaymentConfirmation("BookingID123", "Success")
UI ->> UI: Displays Booking Confirmation
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
How do we handle the conflict when multiple users select the same seat while booking a ticket?
How the system would handle sudden spikes in traffic or ensure high availability during peak hours?
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
How to handle cases where a user may exit the ticket booking process midway, particularly regarding seat reservations or session handling to maintain booking consistency
What happens when a payment fails for a user?
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?