Bird
0
0
LLDsystem_design~12 mins

Parking strategy pattern in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Parking strategy pattern

This system manages parking lots using different parking strategies. It supports multiple strategies to decide where to park vehicles efficiently, such as nearest slot, random slot, or reserved slot strategies. The system must be flexible to add new strategies without changing core logic.

Architecture Diagram
User
  |
  v
Parking Controller
  |
  v
+---------------------+
|  Parking Strategy    |
|  (Interface Layer)   |
+---------------------+
   /       |        \
  /        |         \
 v         v          v
Nearest  Random   Reserved
Strategy Strategy Strategy
  |         |          |
  +---------+----------+
            |
            v
      Parking Lot
      Database
Components
User
actor
Person or system requesting to park or unpark a vehicle
Parking Controller
service
Receives user requests and delegates parking decisions to strategy
Parking Strategy
interface
Defines the contract for different parking strategies
Nearest Strategy
service
Implements parking by choosing the nearest available slot
Random Strategy
service
Implements parking by choosing a random available slot
Reserved Strategy
service
Implements parking by choosing reserved slots for special vehicles
Parking Lot Database
database
Stores parking slot availability and vehicle information
Request Flow - 6 Hops
UserParking Controller
Parking ControllerParking Strategy (selected)
Parking StrategyParking Lot Database
Parking Lot DatabaseParking Strategy
Parking StrategyParking Controller
Parking ControllerUser
Failure Scenario
Component Fails:Parking Lot Database
Impact:System cannot check or update slot availability, so parking requests fail or may cause conflicts
Mitigation:Use database replication and caching of slot availability to allow read operations during failure; queue write requests until DB recovers
Architecture Quiz - 3 Questions
Test your understanding
Which component decides which parking slot to assign based on different rules?
AParking Strategy
BParking Controller
CParking Lot Database
DUser
Design Principle
This design uses the Strategy pattern to separate parking slot selection logic from request handling. It allows adding new parking strategies without changing the controller, promoting flexibility and maintainability.