Movie Booking System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2023-11-06

Problem Statement

Design a low-level architecture for a movie ticket booking system that allows users to browse movies, select showtimes, book seats, and make payments. The system should handle concurrency, maintain seat availability, and provide a smooth booking experience.


Functional Requirements (FR)


User Management


•Users can register, login, and manage profiles.
•Maintain booking history for each user.


Movie & Show Management


•Admin can add/update movies, theaters, and show timings.
•Each show has a fixed number of seats (with categories: regular, premium, VIP).


Seat Selection & Booking


•Users can view seat availability in real-time.
•Lock seats temporarily during booking to prevent conflicts.
•Confirm booking after successful payment.


Payment Handling


•Integrate payment gateway for processing payments.
•Support multiple payment methods: credit/debit cards, wallets, UPI.


Notifications


•Notify users about booking confirmation, cancellations, or changes.


Cancellation & Refund


•Allow users to cancel bookings before showtime.
•Process refunds as per policy.


Non-Functional Requirements (NFR)


•Concurrency Handling → Prevent double booking of seats.
•Scalability → Handle multiple theaters, shows, and users concurrently.
•Availability → Ensure system uptime during peak booking hours.
•Low Latency → Real-time seat availability updates.
•Security → Protect user and payment data.


Core Classes & Entities


User


•userId, name, email, phone, bookingHistory


Movie


•movieId, title, genre, duration, language


Theater


•theaterId, name, location, screens


Screen / Auditorium


•screenId, totalSeats, seatMap


Show / Screening


•showId, movieId, screenId, startTime, endTime, availableSeats


Seat


•seatId, seatNumber, category, status (available/booked/locked)


Booking


•bookingId, userId, showId, seatIds, status, paymentId


Payment


•paymentId, bookingId, amount, status, method


Key Methods / Operations


User Service


•registerUser(), loginUser(), getBookingHistory(userId)


Movie Service


•addMovie(), updateMovie(), getMovies()


Theater & Show Service


•addTheater(), addScreen(), addShow(), getAvailableShows()


Booking Service


•selectSeats(showId, seatIds) → lock seats temporarily
•confirmBooking(userId, showId, seatIds) → finalize booking after payment
•cancelBooking(bookingId) → release seats


Payment Service


•processPayment(bookingId, amount, method)


Design Considerations


Concurrency & Seat Locking


•Use in-memory locks or distributed locks to prevent double booking.


Atomic Booking Transactions


•Ensure payment success → seat confirmation → consistency in booking status.


Data Storage


•Relational database for transactional data (users, bookings, payments).
•Cache for frequently accessed show and seat availability.


Extensibility


•Support dynamic pricing, offers, multiple theaters, and different seat categories.


Example Flow


1.User searches for a movie → Movie & Show Service returns available shows.
2.User selects a show and seats → Booking Service locks selected seats.
3.User makes payment → Payment Service processes transaction.
4.On success → Booking Service confirms booking → update seat status.
5.Send booking confirmation to user → Notification Service.


Solution

Comments