# LLD Case Study: Parking Lot

> Design the classic parking lot: floors, spot types, vehicle types, tickets, fee calculation and concurrent spot allocation. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/lld-parking-lot
Last updated: 2026-11-28

Design the classic parking lot: floors, spot types, vehicle types, tickets, fee calculation and concurrent spot allocation.

Intermediate · about 4 hours · difficulty 3/5

Learn first: [Approaching an LLD Problem: Requirements, Entities and UML](https://www.internhack.in/roadmaps/tracks/system-design/lld-approach-and-uml)

The parking lot is the "hello world" of LLD rounds. It looks simple, which is exactly why interviewers use it to test structure and extensibility.

### Typical requirements

- Multiple floors, each with spots of different sizes (bike, car, truck; maybe EV charging spots).
- Entry and exit gates issue and close **tickets**.
- Fees depend on vehicle type and duration (first hour flat, then per hour; different rules on weekends).
- Show available spots per floor on a display board.

### Core classes

- **ParkingLot** (holds floors, gates; often a single instance).
- **ParkingFloor** has many **ParkingSpot**s; each spot has a type and an occupied flag.
- **Vehicle** (abstract) with Bike, Car, Truck, or simply a VehicleType enum.
- **Ticket**: id, vehicle, spot, entry time, exit time, status.
- **EntryGate / ExitGate**, **DisplayBoard**, **Payment**.

### Where patterns help

- **Strategy** for **spot allocation** (nearest to gate, lowest floor first, spread evenly).
- **Strategy** for **fee calculation** (hourly, flat, weekend pricing). New pricing means a new class, not edited code.
- **Factory** for creating vehicles or spots.
- **Observer** for updating display boards when spots change.

### Concurrency

Two entry gates may try to assign the same spot. Options: synchronise allocation per floor, use atomic compare-and-set on the spot's occupied flag, or keep a concurrent queue of free spots per type. Mention it before you are asked.

### Pitfalls

- Hardcoding fee logic inside the Ticket or Gate class.
- Using deep inheritance for spot types when an enum plus a size rule is enough.
- Forgetting lost tickets, overstays and full-lot handling.

You are ready to move on when you can code a parking lot in under an hour where adding a new vehicle type or pricing rule touches only one or two new classes.

## Key concepts

- **Floors, spots and vehicle types**
- **Ticket lifecycle**
- **Spot allocation strategy**
- **Fee calculation strategy**
- **Concurrent allocation**
- **Display board with Observer**
- **EV charging spots extension**

## Mini project

Implement a parking lot in Java, Python, Go or TypeScript with pluggable allocation and pricing strategies, thread-safe parking from 4 concurrent gates, and tests covering full lot, overstay and a new vehicle type added later.

## Check yourself

Two gates call park() at the same instant and both see spot 12 as free. Describe two ways to make sure only one gets it.

## Free resources

- [Awesome Low Level Design (parking lot and more)](https://github.com/ashishps1/awesome-low-level-design) (GitHub)
- [Strategy pattern](https://refactoring.guru/design-patterns/strategy) (Refactoring.Guru)
- [Java concurrency tutorial](https://docs.oracle.com/javase/tutorial/essential/concurrency/) (Oracle)

Previous: [Approaching an LLD Problem: Requirements, Entities and UML](https://www.internhack.in/roadmaps/tracks/system-design/lld-approach-and-uml) · Next: [LLD Case Study: Movie Ticket Booking (BookMyShow)](https://www.internhack.in/roadmaps/tracks/system-design/lld-bookmyshow)

## More in Low-Level Design (LLD) and Object-Oriented Design

- [OOP Principles and SOLID](https://www.internhack.in/roadmaps/tracks/system-design/oop-and-solid)
- [Design Patterns for LLD](https://www.internhack.in/roadmaps/tracks/system-design/design-patterns)
- [Approaching an LLD Problem: Requirements, Entities and UML](https://www.internhack.in/roadmaps/tracks/system-design/lld-approach-and-uml)
- [LLD Case Study: Parking Lot](https://www.internhack.in/roadmaps/tracks/system-design/lld-parking-lot)
- [LLD Case Study: Movie Ticket Booking (BookMyShow)](https://www.internhack.in/roadmaps/tracks/system-design/lld-bookmyshow)
- [LLD Case Study: Expense Sharing (Splitwise)](https://www.internhack.in/roadmaps/tracks/system-design/lld-splitwise)
- [The Machine Coding Round](https://www.internhack.in/roadmaps/tracks/system-design/machine-coding-round)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [System Design Roadmap](https://www.internhack.in/roadmaps/tracks/system-design)
