Design Parking Lot
Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2025-01-18
Problem Statement
Designing a Parking Lot System that manages vehicle parking for multiple types of vehicles (cars, bikes, trucks) across multiple floors and slots. The system should efficiently handle vehicle entry/exit, parking slot allocation, and fee calculation, while supporting scalability, availability, and real-time monitoring.
Functional Requirements (FR)
Vehicle Management
•Register vehicle entry and exit.
•Track vehicle type (bike, car, truck) and license plate.
Parking Slot Management
•Allocate available slots based on vehicle type.
•Track occupancy status of each slot.
•Release slot when vehicle exits.
Payment & Billing
•Calculate parking fees based on duration and vehicle type.
•Support multiple payment methods (cash, card, digital wallets).
Reporting & Analytics
•Daily/weekly/monthly occupancy reports.
•Revenue reports.
•Track frequently used slots or peak hours.
Optional Features
•Reservation of slots in advance.
•Automated vehicle detection using sensors or cameras.
•Notifications for slot availability.
Non-Functional Requirements (NFR)
•Scalability: Handle large parking lots with thousands of vehicles.
•Availability: System should operate 24/7.
•Low Latency: Real-time slot allocation and updates.
•Reliability: Ensure no double allocation of slots.
•Security: Secure user data and payment transactions.
Core Components
Entry/Exit Service
•Manages vehicle entry and exit, triggers slot allocation and fee calculation.
Parking Slot Service
•Maintains status of all slots (occupied/free).
•Provides available slot information.
Payment Service
•Calculates fees, handles payment transactions, generates receipts.
Notification Service
•Sends alerts for full parking, reserved slot confirmations, or promotions.
Reporting & Analytics Service
•Tracks occupancy, revenue, peak usage times, and generates reports.
Database Layer
•Relational DB: Stores vehicle info, parking history, payments.
•Cache: Frequently accessed slot availability data for fast retrieval.
Data Flow (High-Level)
1.Vehicle arrives → Entry Service reads license plate → Parking Slot Service allocates slot.
2.Slot information updated in DB and Cache → Customer guided to allocated slot.
3.Vehicle exits → Exit Service calculates fee → Payment Service processes payment.
4.Slot released → Parking Slot Service updates availability.
5.Reporting Service aggregates data for analytics.
Key Design Challenges
•Handling real-time slot allocation without conflicts.
•Optimizing slot utilization in multi-level parking.
•Managing high concurrency during peak hours.
•Ensuring accurate billing and preventing fraud.
•Supporting extensibility for reservations, VIP slots, or automated detection systems.