Movie Booking System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-04-16

Problem Statement

Design the Low-Level Design (LLD) of a Movie Ticket Booking System, similar to platforms like BookMyShow or Paytm Movies.


The goal is to design the classes, interactions, and relationships that support searching movies, viewing showtimes, selecting seats, and booking tickets.


Focus on object modeling, seat management, and concurrent booking safety, not the large-scale architecture (databases, caching, microservices — that would be part of HLD).


🎯 Goal


Design a system that can:


•Manage movies, theatres, screens, and shows.
•Allow users to search for movies by location, date, or theatre.
•Support seat selection and ticket booking.
•Ensure thread-safe seat allocation.
•Handle cancellations and payments.


✅ Functional Requirements


1. Movie and Theatre Management


•Each Movie has:
•Name, duration, language, genre, cast, and certification.
•Each Theatre has:
•Name, location, and multiple Screens.
•Each Screen can host multiple Shows per day.


2. Show and Seat Management


•Each Show has:
•A movie, screen, start time, end time, and available seats.
•Seats have:
•Seat number, row, type (Regular, Premium, VIP), and booking status.
•Seats must be locked during the booking flow to avoid double-booking.


3. Search Functionality


•Search by:
•Movie name → shows across theatres.
•Location → movies playing nearby.
•Theatre → all shows in that theatre.


4. Booking Flow


1.User searches for a movie.
2.Selects theatre, show, and seats.
3.System checks if seats are available.
4.Temporarily locks seats during payment.
5.If payment successful → confirm booking, mark seats as booked.
6.If payment fails or timeout → release seats.


5. Payment and Ticket


•Integrate with a mock PaymentService (success/failure).
•On success:
•Generate Booking ID and Ticket.
•Email/SMS ticket details to user.
•On failure:
•Release seats back to available pool.


6. Cancellation


•Users can cancel tickets before showtime.
•Refund (mocked) is initiated.
•Seats are released and made available again.


⚙️ Non-Functional Requirements


•Thread-safety: Ensure atomic seat allocation during concurrent booking.
•Extensible: Easily add new seat types, discount logic, or loyalty features.
•Scalable (conceptually): Should support multiple locations and theatres.
•Fault-tolerant: Seat lock timeout mechanism.


🧱 Key Classes to Design


ClassResponsibility


Movie

Stores movie metadata (title, duration, language, genre).


Theatre

Represents a cinema with location and multiple screens.


Screen

Contains layout of seats and linked to multiple shows.


Show

Represents a specific screening of a movie with time, date, and seats.


Seat

Represents a seat with number, type, and booking status.


User

Represents a customer booking tickets.


Booking

Represents confirmed booking with seats, user, show, and payment details.


Payment

Handles payment processing and status.


SeatLockManager

Handles locking and releasing of seats during booking.


BookingManager

Orchestrates booking flow (search → lock → payment → confirm).


🧩 Example Class Structure (Simplified)

1 2Movie 3 ├── id 4 ├── name 5 ├── duration 6 ├── genre 7 ├── language 8 9Theatre 10 ├── name 11 ├── location 12 ├── List<Screen> 13 14Screen 15 ├── id 16 ├── name 17 ├── List<Seat> 18 ├── List<Show> 19 20Show 21 ├── id 22 ├── movie 23 ├── screen 24 ├── startTime 25 ├── List<Seat> 26 ├── priceMap (SeatType → Price) 27 28Seat 29 ├── id 30 ├── row 31 ├── number 32 ├── type (REGULAR, PREMIUM) 33 ├── status (AVAILABLE, LOCKED, BOOKED) 34 35Booking 36 ├── bookingId 37 ├── user 38 ├── show 39 ├── List<Seat> 40 ├── status (PENDING, CONFIRMED, CANCELLED) 41 ├── payment


🔄 Booking Flow Example


Input:

1 2User: Sahil 3Movie: Interstellar 4Location: Mumbai 5Show: 25 Oct 2025, 7:30 PM 6Seats: A1, A2


Steps:


1.System checks availability of A1, A2.
2.Seats locked for 2 minutes.
3.Payment initiated → success.
4.Seats confirmed and marked as BOOKED.
5.Booking confirmation generated.


Output:

1 2Booking ID: BK202510250123 3Movie: Interstellar 4Show: 7:30 PM, PVR Mumbai 5Seats: A1, A2 6Amount: ₹800 7Status: Confirmed


🧠 Concurrency Scenario


If two users attempt to book the same seat:


•The SeatLockManager ensures one user acquires the lock first.
•The other user gets an “Unavailable” message.
•Lock expires automatically after timeout (e.g., 2 min).


🧪 Extension Ideas


•Add discounts, coupons, loyalty points.
•Integrate with food ordering inside theatre.
•Implement dynamic pricing based on demand.
•Add seat maps and real-time availability APIs.


✅ Summary:

Design a Movie Ticket Booking System (LLD) that allows:


•Searching movies/shows,
•Selecting and locking seats,
•Processing payments,
•Confirming or cancelling bookings,
•with focus on class design, seat management, and thread-safe seat allocation.


Solution

Comments