KatInterview

Multi-Level Parking Facility: Allocation, Ticketing, and Payments

System DesignModel answer
HardModel answerSystem Designsystem-designconcurrencyidempotency

Last updated

Design a multi-level parking facility with typed spots, entry/exit gates, ticketing, pricing, and availability — covering concurrency, consistency, and failure handling.

You are asked to design the software behind a parking facility (or a chain of them). The facility has several floors, each with many bays, and several drive-in and drive-out gates.

Requirements to cover:

  • Several vehicle classes and bay sizes, with a fit rule between them.
  • A ticket is created on arrival, a price is computed on departure, payment is collected, and the barrier opens.
  • Prices follow a rate card: an hourly rate per vehicle class plus a per-day maximum, and stays can span many days.
  • Live counts of free bays, per floor and per vehicle class, feed signage and a mobile app.
  • Define the main objects, their relationships, and the endpoint shapes for arriving, leaving, paying, and checking availability.
  • Explain how you prevent one bay being handed to two cars, how ticket and payment state stays consistent, and what happens with duplicate requests, a misplaced ticket, a network partition at a gate, and a completely full facility.

State your assumptions about size and traffic explicitly. Expect follow-up questions on failure modes, monitoring, and how you would roll this out.

Hints

Hint 1

Start by pinning down the fit rule and the fact that per-facility write rates are tiny — correctness, not throughput, is the real problem, which then justifies partitioning state by facility.

Hint 2

For double-allocation, a conditional UPDATE ... WHERE status='FREE' or SELECT ... FOR UPDATE SKIP LOCKED is enough at these volumes; don't reach for a distributed lock unless you can explain why.

Hint 3

Make payments idempotent with a unique key, model paid_until as a short grace window, and decide explicitly whether an offline gate lets cars out unpaid.