Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Parking Lot Operations System

Design a parking-lot service that assigns compatible spots without double-booking, tracks active sessions, and gives the owner a trustworthy operational view.

Problem statement

For this exercise, assume one large parking facility serves two-wheeled and four-wheeled vehicles through multiple staffed entry and exit gates.

A security guard uses a gate terminal to admit a vehicle, the system returns either one compatible spot and a durable parking ticket or a clear no-capacity outcome, and another guard closes the ticket when the vehicle exits.

The parking-lot owner needs current occupancy by vehicle class and can manage the spot inventory; guards may mark a free spot temporarily unavailable.

A parking spot and a vehicle may each belong to at most one active parking session. Gate clients may time out, retry, or briefly disconnect, but a retried command must converge on the same durable outcome rather than allocate or release twice.

Availability shown to the owner may be slightly stale, but admission decisions must use authoritative state.

Describe the service boundaries, database schema and state transitions, API semantics, and high-level architecture. Explain how the design prevents two gates from assigning the same last spot and how it recovers after a response is lost.

Payments, reservations, automated plate recognition, valet workflows, and EV charging are out of scope.

What to build

  1. Admit a two-wheeled or four-wheeled vehicle and atomically return one compatible available spot plus a durable parking ticket, or a clear no-capacity result.
  2. Close an active parking session at an exit gate and make its spot safely available for a later admission.
  3. Let the owner add or retire spots and let authorized guards mark a free spot temporarily unavailable or restore it.
  4. Show the owner occupancy and available capacity by vehicle class with an explicit freshness boundary.

At scale

  • One facility contains up to 20,000 spots across vehicle classes and is served by up to 40 entry and exit gates. It sustains up to 10 completed admission or exit operations per second at peak, while API traffic may burst to 100 requests per second including retries and availability reads.
  • Gate admission and exit decisions should complete within 500 ms at p95, while occupancy dashboards may lag authoritative state by up to five seconds.
  • Gate operations target 99.99% availability, and correctness is strict: no spot or vehicle may have two active sessions, and a client retry must return the original committed outcome.