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 to start with: a Movie Ticket Booking System (think BookMyShow). This post is what I learned while working through it.
Why LLD matters for an Android developer
As Android devs, we often work with a ready-made structure: MVVM, Repository, Hilt. LLD asks a different question: "If nobody gave me a structure, what classes would I create, and how would they talk to each other?"
It sharpens three skills:
• Turning vague requirements into clear entities and responsibilities
• Applying SOLID principles and design patterns where they actually help
• Thinking about edge cases such as two people booking the same seat
Step 1: Clarify the requirements
The first lesson: never start coding. Start by asking questions.
Functional requirements
• Users can browse movies in their city
• Users can see theaters and shows for a movie
• Users can view the seat layout of a show and pick seats
• Users can pay and receive a booking confirmation
• Users can cancel a booking
Non-functional requirements
• Two users must never book the same seat for the same show
• Seats should be held temporarily while the user pays
• The design should be easy to extend (new payment methods, new pricing rules)
Step 2: Identify the entities
A trick I learned: read the requirements and underline the nouns. Those are your candidate classes.
Entity
Responsibility
Movie
Title, duration, language, genre
Theater
A cinema in a city, owns multiple screens
Screen
A hall inside a theater, owns a seat layout
Seat
A physical seat with a row, number and type
Show
A movie playing on a screen at a given time
ShowSeat
The status of one seat for one show
User
The person booking
Booking
A confirmed reservation
Payment
Payment details and status
The one that confused me at first was ShowSeat. Why not just put a isBooked flag on Seat? Because a physical seat is the same every day, but its availability is different for every show. Seat is the physical thing, ShowSeat is that seat's state for a specific show. This was my first real "aha" moment.
Step 3: Define the core classes in Kotlin
Since I think in Kotlin, I modeled everything with it.
enum class SeatType { REGULAR, PREMIUM, RECLINER }
enum class SeatStatus { AVAILABLE, LOCKED, BOOKED }
enum class BookingStatus { PENDING, CONFIRMED, CANCELLED }
data class Movie(
val id: String,
val title: String,
val durationMinutes: Int,
val language: String
)
data class Seat(
val id: String,
val row: Char,
val number: Int,
val type: SeatType
)
data class Screen(
val id: String,
val name: String,
val seats: List
)
data class Show(
val id: String,
val movie: Movie,
val screen: Screen,
val startTime: Long
)
class ShowSeat(
val seat: Seat,
var status: SeatStatus = SeatStatus.AVAILABLE
)
Notice how Seat is immutable (a data class with val) while ShowSeat carries the changing state. Keeping mutable state in as few places as possible makes the system easier to reason about.
Step 4: The booking flow
The heart of the system is the booking flow:
- User selects a show and seats
- System locks those seats for a short time (say 5 minutes)
- User completes payment
- On success, seats become BOOKED and a Booking is created
-
On failure or timeout, seats are released back to AVAILABLE
I put this logic in a dedicated service class instead of cramming it into the UI or the models. That follows the Single Responsibility Principle.
class BookingService(
private val paymentProcessor: PaymentProcessor,
private val seatLockManager: SeatLockManager
) {fun bookSeats(user: User, show: Show, seatIds: List): Booking {
// 1. Try to lock all requested seats
val locked = seatLockManager.lockSeats(show.id, seatIds)
if (!locked) throw SeatUnavailableException()try { // 2. Calculate price and take payment val amount = calculateAmount(show, seatIds) val paid = paymentProcessor.pay(user, amount) if (!paid) { seatLockManager.unlockSeats(show.id, seatIds) throw PaymentFailedException() } // 3. Confirm seatLockManager.confirmSeats(show.id, seatIds) return Booking( id = generateId(), user = user, show = show, seatIds = seatIds, status = BookingStatus.CONFIRMED ) } catch (e: Exception) { seatLockManager.unlockSeats(show.id, seatIds) throw e }}
}
Step 5: The tricky part, concurrency
This was the most interesting part. What if two users tap "Book" on seat A5 at the same moment?
If the check and the update are separate steps, both users may see the seat as available and both succeed. This is a classic race condition.
The fix is to make check-and-lock a single atomic operation:
class SeatLockManager {
private val showSeats = mutableMapOf>()@synchronized
fun lockSeats(showId: String, seatIds: List): Boolean {
val seatsForShow = showSeats[showId] ?: return false// Check that ALL seats are available first val allAvailable = seatIds.all { seatsForShow[it]?.status == SeatStatus.AVAILABLE } if (!allAvailable) return false // Then lock them all seatIds.forEach { seatsForShow[it]?.status = SeatStatus.LOCKED } return true}
@synchronized
fun unlockSeats(showId: String, seatIds: List) {
seatIds.forEach { showSeats[showId]?.get(it)?.status = SeatStatus.AVAILABLE }
}@synchronized
fun confirmSeats(showId: String, seatIds: List) {
seatIds.forEach { showSeats[showId]?.get(it)?.status = SeatStatus.BOOKED }
}
}
Two takeaways here:
• All or nothing: if a user picks 3 seats and only 2 are free, we should lock none, not 2.
• In a real production system with many servers, @synchronized is not enough. You would use a database transaction or a distributed lock (for example Redis) with an expiry time. For an LLD interview, explaining this limitation is a great bonus.
Step 6: Design patterns that fit naturally
I used to think design patterns were things to memorize. Working on this problem showed me they are answers to problems I was already facing.
Strategy pattern for payments. Today it is UPI, tomorrow it might be cards or wallets. I should not need to edit BookingService every time.
interface PaymentProcessor {
fun pay(user: User, amount: Double): Boolean
}
class UpiPayment : PaymentProcessor {
override fun pay(user: User, amount: Double): Boolean {
// call UPI gateway
return true
}
}
class CardPayment : PaymentProcessor {
override fun pay(user: User, amount: Double): Boolean {
// call card gateway
return true
}
}
This follows the Open/Closed Principle: open for extension, closed for modification.
Strategy pattern for pricing. Weekend pricing, premium seats, festival surcharges can all be separate PricingStrategy implementations.
Observer pattern for notifications. When a booking is confirmed, we may want to send an SMS, an email and a push notification. The booking service should simply announce "a booking was confirmed" and let observers react.
Singleton or dependency injection for shared managers. Something like SeatLockManager must be a single shared instance. As an Android dev, I realized this is exactly the kind of thing Hilt gives us for free, and now I understand why.
Step 7: Relating it back to Android
What I enjoyed most was seeing how this maps to my daily work:
• BookingService is like a UseCase / Repository in Clean Architecture
• PaymentProcessor as an interface is the same idea as hiding a Retrofit API behind a repository interface
• Seat state changing from AVAILABLE to LOCKED to BOOKED is a perfect fit for a sealed class or enum driving UI state in Jetpack Compose
LLD did not replace what I know. It gave me the vocabulary for why those patterns exist.
Mistakes I made while learning
• I jumped into code before writing down requirements. I ended up redesigning twice.
• I made one giant Booking class that did everything. Splitting responsibilities made it much cleaner.
• I ignored the edge cases at first: payment failure, lock expiry, partial seat availability.
What I want to explore next
• Add seat lock expiry using a scheduler or coroutines with a delay
• Add cancellation and refund flows
• Write unit tests for BookingService using fake payment processors
• Practice other LLD problems: Parking Lot, Splitwise, Elevator System, Food Delivery
Final thoughts
Learning LLD with a Movie Ticket Booking System taught me that good design is mostly about asking the right questions: Who owns this data? What can change? What must never go wrong?
If you are an Android developer thinking about learning LLD, my advice is simple: pick one small problem, model it in the language you love, and break it on purpose with edge cases. That is where the real learning happens.
Thanks for reading, and I would love to hear how you approached this problem!
Payel Paul
