solidcodersolidcoder
AI TopicsExplore Courses
solidcodersolidcoder

Practical courses for software engineering interviews — no gatekeeping, no fluff.

Company-wise Questions

  • Flipkart Machine Coding Questions
  • Swiggy Machine Coding Questions
  • Meesho Machine Coding Questions
  • Razorpay Machine Coding Questions

Machine Coding Tutorial

  • Machine Coding Tutorial

Explore

  • Courses
  • AI Engineering Topics
  • About
  • Privacy Policy
  • Terms

© 2026 solidcoder · Practical courses for software engineering interviews.

Built for the AI era — learn by doing.

Home/Machine Coding/Machine coding Tutorial/Movie Ticket Booking (BookMyShow) — Machine Coding Round
Chapters — Machine coding Tutorial▾

Movie Ticket Booking (BookMyShow) — Machine Coding Round

5 min read·Sep 11, 2026
Keywords:Machine Coding RoundMachine Coding QuestionsLow Level Design

Machine coding round — design a BookMyShow-style movie ticket system: city-to-show browsing, timed seat holds, UPI/card/wallet payments and notifications.

Movie Ticket Booking (BookMyShow) — Machine Coding Round — Machine coding Tutorial
Machine coding round — design a BookMyShow-style movie ticket system: city-to-show browsing, timed seat holds, UPI/card/wallet payments and notifications.
Asked inBookMyShow

Design a movie ticket booking system that lets a user browse from city down to a specific show, pick seats visually, hold them briefly while paying, and book — all while staying correct when many users compete for the same seats at once.

What the round tests

This one tests whether you can model the browsing hierarchy (city → movie → cinema → show → seats) cleanly, while getting the trickier real-world behavior right: temporary seat holds that expire, and fair, race-free seat allocation when multiple users try to book the same seat simultaneously.

Objective

The primary objective is to design and implement a movie ticket booking system that supports browsing from city down to a show, visual seat selection with timed holds, and fair, race-free booking when many users compete for the same seats.

Data Model

The browsing flow is a hierarchy that narrows down to a single show's seat map.

Browsing hierarchy
Level
What it represents
City
A city where the system has one or more cinemas.
Movie
A movie currently released in that city.
Cinema
A specific cinema running that movie.
Show
A specific screening (movie + cinema + time).
Seat
An individual seat within a show's hall, either available, held, or booked.

Requirements

Two tiers of scope

The source splits requirements into functional (what the system does) and non-functional (how well it must do it) rather than basic-vs-bonus — kept as Part 1 and Part 2 here for consistency with the rest of this series.

Part 1 — Functional Requirements

Core functionality you must build and get working first.

Core flow
Requirement
Detail
List cities
The system lists every city where its cinemas are located.
Movies by city
Selecting a city shows the movies currently released there.
Cinemas & shows by movie
Selecting a movie shows the cinemas running it and their available shows.
Select a show
The user selects a show from a cinema to begin booking.
Seating arrangement
The system displays the seating layout of that cinema hall for the selected show.
Multi-seat selection
The user can select multiple seats of their choice.
Seat availability distinction
The seating layout must visually or logically distinguish available seats from already-booked ones.
Temporary hold
Selected seats are held for 5–10 minutes while the user completes payment, before the booking is finalized.
Payment
The user pays for held seats via UPI, credit/debit card, or wallet; confirming payment finalizes the booking and records the payment method.
Assumption for Part 1 — payment mocked

For Part 1, assume payment always succeeds. confirmBooking() finalizes a held seat directly into a booking, recording whichever payment mode (UPI, card, or wallet) the user selected. Payment failure is not a concern yet — that's introduced in Part 2.

Fairness under contention

The system must serve booking requests for contested seats in First In, First Out order — if two users race for the same seat, whoever's request was received first should win the hold, not whoever's request happens to be processed first by chance.

Part 2 — Non-Functional Requirements

Quality attributes, not features

These describe how the system must behave under load and failure, not new user-facing operations.

Quality attributes
Requirement
Detail
High concurrency
Many booking requests can target the same seat at the same instant; the design must resolve this fairly rather than arbitrarily, without corrupting seat state.
Security & ACID compliance
Booking operations must be secure and behave with atomicity, consistency, isolation, and durability — a seat hold or booking should never be left in a half-applied state.
Reliability & payment failure handling
Requirement
Detail
Payment can fail
In Part 2, a payment attempt may succeed or fail (gateway decline, timeout, insufficient funds). A seat becomes BOOKED only once payment succeeds — never on a hold alone. On failure the booking is not confirmed; the seat stays HELD until the hold expires or is explicitly released, so the user can retry within the 5–10 minute window.
Atomic & idempotent confirm
Confirming a booking must be atomic and idempotent — a duplicate confirmation attempt for the same booking (e.g. a retried payment callback) must never result in a double-booking or a double-charge.
Failure response
On payment failure, return a clear error, keep the seat held until expiry, and do not send a booking notification. On success, send a confirmation and persist the payment method used.
Testing the failure path

Evaluation is deterministic — tests trigger explicit success or failure outcomes rather than relying on randomness, so the failure path should be reachable on demand, not just by chance.

Booking extensions
Requirement
Detail
Notifications
Notify the user on booking confirmation via email, WhatsApp, or SMS, plus a reminder before the show starts.
Cancellation
Allow cancellation until 30 minutes before the show starts; the cutoff window can differ per movie, with refunds to the original payment source.

Example Usage: Full Walkthrough

The source doesn't specify an exact command syntax, so here's one reasonable walkthrough exercising the browsing flow, seat holding, and concurrent contention.

1. Browse from city down to a show

> listCities()
["Bengaluru", "Mumbai", "Delhi"]

> listMovies(city: "Bengaluru")
["Interstellar Returns", "The Last Byte"]

> listCinemasAndShows(movie: "Interstellar Returns", city: "Bengaluru")
[
  { cinema: "PVR Forum", shows: ["18:00", "21:30"] },
  { cinema: "INOX Mantri", shows: ["19:15"] },
]

2. View the seating layout for a chosen show

> getSeatLayout(showId: "pvr-1800")
Row A: [A1:available, A2:available, A3:booked, A4:available]
Row B: [B1:available, B2:booked,    B3:available, B4:available]

3. Select seats — placed on hold

> holdSeats(showId: "pvr-1800", user: "alice", seats: ["A1", "A2"])
✅ Seats A1, A2 held for alice. Hold expires in 10 minutes.

4. A concurrent request for an overlapping seat is queued fairly

> holdSeats(showId: "pvr-1800", user: "bob", seats: ["A2", "A4"])   // arrives moments after alice's request
❌ Seat A2 is currently held by another user. Only A4 held for bob.
✅ Seat A4 held for bob. Hold expires in 10 minutes.

5. Alice pays via UPI and gets notified

> confirmBooking(showId: "pvr-1800", user: "alice", seats: ["A1", "A2"], payment: "UPI")
✅ Booking confirmed for alice: seats A1, A2 (paid via UPI).
📧 Email + WhatsApp sent to alice: booking confirmed for Interstellar Returns, PVR Forum, 18:00.

6. An expired hold releases its seats automatically

... 10 minutes pass with no confirmBooking call from bob for seat A4 ...

⏱ Hold on seat A4 for bob expired. Seat A4 is available again.

7. Payment failure in Part 2 — hold survives for retry (idempotent)

> holdSeats(showId: "pvr-1800", user: "charlie", seats: ["B3"])
✅ Seats B3 held for charlie. Hold expires in 10 minutes.

> confirmBooking(showId: "pvr-1800", user: "charlie", seats: ["B3"], payment: "Card")
❌ Payment failed (gateway timeout). Seats B3 still held for charlie — retry within hold window.
📧 No notification sent.

> confirmBooking(showId: "pvr-1800", user: "charlie", seats: ["B3"], payment: "Card") // retry with same idempotencyKey
✅ Booking confirmed for charlie: seats B3 (paid via Card).
📧 Email + WhatsApp sent to charlie.

> confirmBooking(showId: "pvr-1800", user: "charlie", seats: ["B3"], payment: "Card") // duplicate webhook
↩️ Already confirmed — idempotent, no double-charge or double-booking.
Result

Alice's hold on A1/A2 blocks Bob from holding A2 concurrently — his request is resolved fairly rather than racing silently — and once Alice pays, those seats are permanently booked. Bob's own hold on A4, left unconfirmed, expires cleanly and returns that seat to the pool. Charlie's Part 2 flow shows payment failures are handled atomically: failure keeps the hold for retry without notifying, retry succeeds, and duplicate confirms are idempotent with no double-charge — demonstrating concurrency-fairness, timed-hold, and ACID payment handling together.

Up next9/9
Part 2 · Machine Coding Questions
←
← Prev Chapter
Key-Value Store
5 min
Next Chapter →
Ecommerce Loyalty Program
5 min · continue reading
→

Enroll in machine coding mastery series

₹30,000₹3,00090% OFF
Enroll Now →

Use code SOLID50 · 3 years · 40+ lessons

On this page
  • Objective
  • Data Model
  • Requirements
    • Part 1 — Functional Requirements
    • Part 2 — Non-Functional Requirements
  • Example Usage: Full Walkthrough