Design a Parking Garage
Design a parking garage system with OOP modeling, sensor integration, real-time space tracking, payment processing, and reservation management.
Quick answer: Design a Parking Garage
Design a Parking Garage is covered here as a practical system design interview problem. Design a parking garage system with OOP modeling, sensor integration, real-time space tracking, payment processing, and reservation management. Use it to practice requirements, APIs, storage choices, scaling bottlenecks, data consistency, observability, and failure handling for a easy interview round.
Focus on the problem being solved, the main design choice, the failure mode, and the tradeoff you would defend in front of a senior engineer. This page is part of the DosiBridge system design knowledge graph, so it links related concepts, interview problems, tradeoffs, and references instead of leaving the topic isolated.
Problem Statement
Design a parking garage management system that tracks available spaces in real time, handles vehicle entry/exit via sensors or ticketing, calculates fees based on duration and vehicle type, supports reservations, and manages multiple floors with different spot sizes (compact, regular, large, handicapped).
Requirements
Functional
- Track real-time availability per floor and spot type (compact, regular, large, handicapped)
- Handle vehicle entry: assign nearest available spot, issue ticket with entry timestamp
- Handle vehicle exit: calculate fee based on duration and vehicle type, process payment
- Support advance reservations with time-window holds
Non-Functional
- Consistency: No double-booking of spots -- strong consistency required
- Latency: Entry/exit gate processing <2 seconds
- Availability: 99.9% -- gates must open even during partial system failure
- Scale: Support 10,000-spot garages with 50,000 entries/exits per day
Core Architecture
-
Spot Allocation Service -- Maintains an in-memory map of all spots and their states (available, occupied, reserved, maintenance). Uses a priority queue per floor to assign the nearest available spot to each vehicle type. Spot assignment is wrapped in a database transaction to prevent double-booking.
-
Entry/Exit Gate Controller -- Interfaces with physical hardware: license plate cameras, ticket dispensers, barrier gates. On entry, requests a spot from the allocation service and issues a ticket. On exit, looks up the ticket, computes the fee, and lifts the barrier after payment.
-
Payment Service -- Computes fees using a rate engine: first hour flat rate, then per-15-minute increments. Supports credit card, mobile pay, and prepaid passes. Integrates with Stripe/payment processor. Generates receipts and handles refunds for overcharges.
- Reservation Manager -- Accepts advance bookings with a time window. Holds the reserved spot starting 15 minutes before the window. Unredeemed reservations release automatically after a grace period, triggering a no-show fee.
Database Choice
PostgreSQL is the primary database. Spots, tickets, and reservations all have strong relational integrity (a spot belongs to a floor, a ticket references a spot and a vehicle). Transactions ensure no double-booking. The spots table uses a status column with row-level locking on assignment. Redis caches the real-time availability counts per floor for the display boards and mobile app, updated via CDC from Postgres.
Key API Endpoints
POST /api/v1/entry
-> Body: \{ license_plate: "ABC123", vehicle_type: "regular" \}
-> Returns: \{ ticket_id: "T-9001", spot: "F2-R34", floor: 2 \}
POST /api/v1/exit
-> Body: \{ ticket_id: "T-9001", payment_method: "credit_card" \}
-> Returns: \{ duration_min: 147, fee_usd: 12.50, receipt_url: "..." \}
Scaling Insight
For multi-garage chains, use a hierarchical allocation model: each garage runs its own Spot Allocation Service locally (so gates work even if the network is down), while a central service aggregates availability across all garages for the mobile app and reservation system. Local-first design ensures gates never block on a remote call.
Key Tradeoffs
| Decision | Option A | Option B | Chosen |
|---|---|---|---|
| Spot assignment | Random available | Nearest to entrance | Nearest -- better user experience, reduces driving time inside garage |
| Consistency | Optimistic locking | Pessimistic row lock | Pessimistic -- simpler, spot contention is low enough that lock wait is negligible |
| Fee model | Flat hourly rate | Tiered per-minute | Tiered -- fairer to short-stay visitors, higher revenue optimization |
Original DosiBridge notes for Design a Parking Garage
This section is written specifically for this page, not copied from a general system-design checklist. The useful way to study Design a Parking Garage is to connect the concept to a production service where growth exposes the first weak assumption in the original design. That framing changes the design discussion from definitions to operating choices.
What makes this topic distinct
- Core Entity: For Design a Parking Garage, decide the core entity before choosing tools; otherwise the design looks clean but fails when parking changes.
- Read/Write Path: For Design a Parking Garage, decide the read/write path before choosing tools; otherwise the design looks clean but fails when garage changes.
- Contention Point: For Design a Parking Garage, decide the contention point before choosing tools; otherwise the design looks clean but fails when parking changes.
- Abuse Path: For Design a Parking Garage, decide the abuse path before choosing tools; otherwise the design looks clean but fails when garage changes.
- Recovery Workflow: For Design a Parking Garage, decide the recovery workflow before choosing tools; otherwise the design looks clean but fails when parking changes.
Design a Parking Garage correctness boundary
For this problem, separate the user-visible action from background work. The correctness boundary is the smallest state transition that must not be duplicated, lost, or reordered. Naming that boundary makes the solution more original than a stock API/database/cache template.
Design a Parking Garage scaling bottleneck
The first bottleneck should be described in the language of this system: a hot timeline, a contested seat, a busy wallet ledger, a media-processing queue, or a search index update delay. That bottleneck decides which component deserves the deepest interview discussion.
Production review question
If Design a Parking Garage suddenly receives 10x traffic, which entity becomes contested first, and what queue, lock, shard, or cache protects that entity without hiding correctness bugs?
Practical metric to track
Track parking-garage health as a named dashboard or review item: combine one user-facing metric, one saturation metric, and one correctness metric. For Design a Parking Garage, this keeps the discussion grounded in behavior that can be measured after deployment instead of generic advice that sounds good in an interview but never gets verified.