Design Movie Ticket Booking
🎟️ What is a movie ticket booking system? It is the app you use to buy cinema tickets. You pick a movie and a show time, see a map of the seats, choose a few, and pay. While you pay, those seats are held for you for a few minutes. If you pay, they are yours; if you walk away, they go back to everyone else.
BookMyShow and Ticketmaster are the same design with different names: shows (or events), a seat map, short-lived holds, and confirmed bookings. The hard part is not the catalog. It is the seat: many people want the same seat at the same moment, and exactly one of them may get it. So this post spends most of its time on seat holds, their expiry, and concurrent booking, and keeps browsing simple.
Requirements
"Design a movie ticket booking system like BookMyShow. Users pick a show, choose seats and pay. Two people must never get the same seat."
Clarifying Questions
You: What can users browse? Cities, cinemas, movies?
Interviewer: Keep the catalog small. Users look up the upcoming shows of a movie, then see which seats of a show are free.
You: Does picking seats book them right away?
Interviewer: No. Picking seats holds them while the user pays. The hold lasts a fixed number of minutes. If the user pays in time, the booking is confirmed. If not, the seats are released.
You: If a user asks for four seats and one is taken, do they get the other three?
Interviewer: No. They get all four or nothing. Nobody wants to sit apart from their friends without being asked.
You: Do we handle the payment?
Interviewer: No. Assume a payment service. When it succeeds, it calls us to confirm.
You: Can users cancel?
Interviewer: Yes, a hold or a confirmed booking, as long as the show has not started. The seats become free at once. Only the user who made the booking can confirm or cancel it.
You: How do we know the time?
Interviewer: Pass a timestamp in minutes into every call.
You: Many users will book at the same moment. Is that in scope?
Interviewer: Yes. Design the classes first, then show me how two users can't get the same seat.
The fourth answer is a gift. With payment outside, our job is the life of a booking: held, then confirmed, cancelled or expired. That is a state machine, and it is the core of the design.
💡 Interview tip: Ask early whether a hold is all or nothing. It decides whether
hold_seatsneeds to check every seat before it takes any, which is the same shape as the locking code you will write later.
Final Requirements
- An admin adds shows: a movie, a start time, and a room of
rows × colsseats (rowsA,B, ...; seats1tocols). - Users list the upcoming shows of a movie, sorted by start time.
- Users see the free seats of a show. A seat is free unless it is in an active hold or a confirmed booking.
- A user holds a set of seats for a show. The hold takes all of them or none. It gets a booking id.
- A hold expires a fixed number of minutes after it was made. Its seats are then free again.
- The user who made a hold can confirm it while it is active (the payment succeeded). Confirmed bookings never expire.
- The user can cancel a hold or a confirmed booking; its seats become free at once.
- Nothing can be held, confirmed or cancelled once the show has started.
- Two users can never hold or own the same seat at the same time, even when they ask at the same moment.
Out of scope
- Payment, refunds and tickets as PDFs or QR codes.
- Cities, cinema chains, search filters and recommendations.
- Seat categories and prices, and picking the best seats for the user (both in Extensibility).