Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Designing a Movie Ticket Booking System: My LLD Learning Notes By Payel Paul, Android Developer

Designing a Movie Ticket Booking System: My LLD Learning Notes By Payel Paul, Android Developer I have spent years building Android screens, handling lifecycles, and wiring up ViewModels. Recently I started learning Low Level Design (LLD), and I quickly realized something: I knew how to use architecture, but I had never practiced designing it from a blank page. So I picked a classic LLD problem…

Designing a Movie Ticket Booking System: My LLD Learning Notes By Payel Paul, Android Developer Payel Paul, an Android Developer, shares what they learned while designing a Movie Ticket Booking System (similar to BookMyShow) as part of their Low Level Design (LLD) learning journey. Here are the key points from the article broken down into short, easy-to-follow paragraphs:

1. Why LLD matters for an Android developer

Android developers usually work with established architectures like MVVM, Repository, and Hilt. However, LLD challenges you to create your own classes and design patterns from scratch. This process enhances three essential skills:

- Breaking down vague requirements into clear entities and responsibilities

- Applying SOLID principles and design patterns efficiently

- Anticipating edge cases such as multiple users booking the same seat

2. Clarifying requirements

Before diving into code, it is crucial to ask questions and understand the functional and non-functional requirements. For a Movie Ticket Booking System, these include:

- Users browsing movies in their city

- Viewing theaters and showtimes for a specific movie

- Selecting seats on a show's layout and making a payment

- Receiving a booking confirmation and the ability to cancel a booking

- Ensuring that two users cannot book the same seat for the same show

- Temporarily holding seats while the user pays

- Designing the system to be easily extensible for new payment methods or pricing rules

3. Identifying entities

The most straightforward approach is to read the requirements and underline the nouns, which form the basis of your candidate classes. In this case, some of the key entities are Movie, Theater, Seat, Show, ShowSeat, User, and Booking.

4. The ShowSeat class

One tricky part was deciding how to handle seat availability across different shows. Initially, it might seem sufficient to add a boolean isBooked flag to the Seat class. However, a more nuanced approach is to create a ShowSeat class that represents the state of a single seat for a specific show. This distinction allows for better tracking of seat availability throughout the booking process.

5. Core classes in Kotlin

Representing the entities using Kotlin data classes made the code more concise and readable. The essential classes and their responsibilities include:

- SeatType: Represents the type of seat (REGULAR, PREMIUM, RECLINER)

- SeatStatus: Indicates the availability of a seat (AVAILABLE, LOCKED, BOOKED)

- BookingStatus: Describes the current phase of a booking (PENDING, CONFIRMED, CANCELLED)

- Movie: Holds movie details such as ID, title, duration, and language

- Seat: Contains seat-specific details including ID, row, number, and type

- Screen: Represents a theater hall, including ID, name, and a list of seats

- Show: Links a movie, screen, and showtime together

- ShowSeat: Holds information about a specific seat's status during a particular show

- User: Stores user information like ID, name, and booking history

- Booking: Represents a confirmed reservation, including user details, seat IDs, and status

6. Booking flow

The core of the system revolves around the booking flow, which includes:

- The user selecting a show and seats

- The system temporarily locking those seats for a short time

- The user completing the payment process

- If the payment is successful, the seats are marked as BOOKED, and a Booking object is created

- If the payment fails or times out, the seats revert to AVAILABLE

7. Implementing the booking service

Creating a dedicated BookingService class helps to adhere to the Single Responsibility Principle. This class takes care of coordinating the payment process, seat locking, and confirmation of seats. It also accepts payment processor and seat lock manager dependencies to maintain a clean separation of concerns.

8. Concurrency challenges

When designing the system, Payel encountered the challenge of handling concurrent bookings for the same seat. If two users attempt to book the same seat simultaneously, both might think the seat is available and succeed in their booking attempt. This situation is known as a race condition.

To resolve this issue, Payel implemented an atomic check-and-lock operation within the SeatLockManager class, which ensures all-or-nothing behavior: if any seat fails the availability check, none of the seats are locked. This approach guarantees consistency and proper state management of seats during the booking process.

In conclusion, Payel Paul's LLD learning notes showcase the process of designing a Movie Ticket Booking System from scratch. By breaking down requirements, identifying core entities, and applying SOLID principles, Payel gained a deeper understanding of creating robust and scalable Android applications. The experience with the ShowSeat class and concurrency challenges highlights the importance of considering edge cases and maintaining clean, efficient design patterns.

Rewritten by urgent.news; may contain errors — check the original. How we use AI.

Source: dev.to

Read the original at dev.to →

More from Dev.to on urgent.news

Get the news by email. Yesterday's most-covered stories, every morning.

We track opens and clicks to improve the newsletter.

See today's edition · More options

More in Tech

The US government thinks the Moon could be a $300 billion business

Congress' watchdog, the Government Accountability Office, published the two-page report on December 3. The $300 billion figure didn't come from the agency's own math, though. The GAO told 404 Media it took the number from an August report by Deloitte. That report puts the lunar economy anywhere from $343 billion... Read Entire Article

More from Sunday, 6 December 2026 →