How would you design a parking lot?
I once spent 20 minutes circling a parking garage that had a sign saying "SPACES AVAILABLE." The sign was wrong. Every spot was taken. The system that con...
8 Mar 2024

I once spent 20 minutes circling a parking garage that had a sign saying "SPACES AVAILABLE." The sign was wrong. Every spot was taken. The system that controlled the sign hadn't been updated in hours.
That experience stuck with me. A parking lot system isn't about parking cars. It's about real-time state management under constrained resources. And that makes it a surprisingly interesting system design problem.
The Real Challenge

A parking lot has a fixed number of spots. Cars arrive and leave unpredictably. The system needs to:
- Maximize utilization — every empty spot is lost revenue. The system should guide drivers to available spaces efficiently.
- Provide real-time availability — drivers need to know if spots are open before they enter the lot, not after circling for 20 minutes.
- Support reservations — let users book spots in advance. This requires holding capacity without over-committing.
- Process payments — support hourly rates, daily rates, monthly passes, and multiple payment methods (cards, mobile wallets, contactless).
- Ensure security — surveillance cameras, access gates, and audit logs. Know which car is in which spot at which time.
Data Model

The core entities are straightforward:
- ParkingLot — location, total capacity, operating hours, pricing rules.
- ParkingSpot — spot number, type (compact, regular, handicap, EV charging), floor, current status (available, occupied, reserved, maintenance).
- Vehicle — license plate, type, size.
- Ticket/Session — entry time, exit time, spot assignment, payment status.
- Reservation — user, spot, time window, status.
- Payment — amount, method, timestamp, associated ticket.
System Components
User Interface
Mobile-first. Drivers need to find spots, make reservations, and pay from their phones. The UI must show real-time availability on a floor map — color-coded spots (green available, red occupied, blue reserved). Keep it dead simple. A driver looking at their phone in a parking garage has about 3 seconds of patience.
Backend Infrastructure
The backend handles business logic: spot assignment, reservation management, pricing calculation, and payment processing. It exposes REST APIs consumed by the mobile app, web dashboard, and physical gate systems.
Real-Time Spot Tracking
This is the heart of the system. Options for detecting occupancy:
- IoT sensors (ultrasonic or magnetic) embedded in each spot. Accurate but expensive to install and maintain.
- Camera-based detection using computer vision. Cheaper per spot but requires GPU processing and good lighting.
- Gate-based counting — count entries and exits. Simple but can't tell you which spots are available, only how many.
I'd combine gate-based counting (for overall availability displayed on the street sign) with sensors for individual spot tracking inside the garage.
Reservation System
Users book a spot for a specific time window. The system must handle:
- Capacity limits — don't overbook. Track reserved capacity separately from occupied capacity.
- No-shows — release reserved spots after a grace period (e.g., 15 minutes).
- Cancellations — allow cancellations with a refund policy.
- Concurrent reservations — use optimistic locking or a queue to prevent two users from reserving the same spot simultaneously.
Payment Processing
Integrate with a payment gateway (Stripe, Square). Support multiple pricing models: per-hour, per-day, flat rate, monthly subscriptions. Calculate charges based on actual duration (entry time to exit time).
Access Control
Entry and exit gates controlled by the system. Validate tickets, reservations, or monthly passes at the gate. Log every entry and exit for security and billing.
The Trade-Offs
Sensors vs. cameras vs. gate counting. Sensors give per-spot accuracy but cost $50-100 per spot to install. Cameras are cheaper at scale but need processing power and calibration. Gate counting is simplest but least informative. Most commercial lots use gate counting plus sensors on premium floors.
Reservation guarantee vs. utilization. Holding spots for reservations reduces walk-in availability. If 30% of your capacity is reserved and 20% of reservations no-show, you lose revenue. Short hold windows and no-show penalties mitigate this but add policy complexity.
Real-time accuracy vs. system cost. A perfectly accurate real-time display requires sensors, reliable networking, and constant state updates. An "approximately right" display using gate counting is 90% as useful at 10% of the cost.
The best parking systems I've seen focus on the two things that matter most to drivers: "Is there a spot?" and "How much will it cost?" Everything else is optimization.