Design BookMyShow (LLD)
1. Requirements
-
Functional
- Cities contain venues; shows run at events with seat maps.
- Users select contiguous or best-available seats; hold briefly while paying.
- Booking confirms seats and issues tickets; cancellation policy applies refunds.
-
Non-Functional
- No double booking same seat for overlapping confirmation window.
- Horizontally sharded by show id in production; object model stays consistent.
-
Assumptions / Out of Scope
- Payment PSP integration stubbed; inventory authoritative in booking service.
2. Core Entities
| Entity | Responsibility | Key Attributes |
|---|---|---|
| City | Region container | name, venues |
| Venue | Physical location | identifier, screens |
| Show | Movie or performance | title, duration |
| Screen | Hall with seats | identifier, seatLayout |
| Seat | Bookable unit | rowLabel, number, category |
| ShowRun | Timetabled instance | show, screen, startTime |
| Booking | Purchased set of seats | userId, seats, status |
| SeatHold | Temporary lock | seats, expiresAt |
3. Class Diagram
Loading diagram…
4. State / Sequence Diagram (where relevant)
Loading diagram…
5. Design Patterns Applied
- Facade —
BookingServiceover inventory and payments. Facade pattern. - Flyweight — Shared seat layout template per screen geometry. Flyweight pattern.
- Proxy — Lazy-loaded seat map from CDN or cache. Proxy pattern.
6. Implementation
Go
package booking
type Seat struct {
Identifier string
RowLabel string
Number int
}
type ShowRun struct {
Identifier string
ScreenID string
StartsAt time.Time
}
type BookingService struct {
Inventory SeatInventory
}
func (service *BookingService) HoldSeats(runID string, seatIDs []string) (holdToken string, err error) { /* ... */ }
func (service *BookingService) Confirm(holdToken string, paymentRef string) (*Booking, error) { /* ... */ }JavaScript
class BookingService {
constructor({ seatInventory, paymentClient }) {
this.seatInventory = seatInventory;
this.paymentClient = paymentClient;
}
async holdSeats({ runId, seatIds }) { /* ... */ }
async confirmBooking({ holdToken, paymentMethod }) { /* ... */ }
}7. Concurrency / Thread Safety
- Collisions: Two users selecting same seat before hold.
- Granularity: Transactional compare-and-set on seat status; short TTL holds with token.
- Go: Mutex per
ShowRunduring hold creation or rely on DB constraints.
8. Extensibility & Followups
- Dynamic pricing by seat category and show demand.
- Waitlists when sold out.
- Edge cases: partial payment failure after hold, show cancellation refunds en masse.
Last updated on
Spotted something unclear or wrong on this page?