System requirements
Functional:
- List the types of vehicles the parking lot can accommodate(dimension specification)
- Available lot for each vehicle type
- Price per hour for a vehicle type
- Occupied and Available space count
- Vehicle identity
- Vehicle to space mapping
Non-Functional:
- Safety
- Efficiency
- Usability
Capacity estimation
Assumption, total available space = 1000
3 types of parking space 1. Car 2. Truck 3. TwoWheeler
Car space = 500
Truck space = 200
TwoWheeler = 300
Daily Active Users count - 100K
Request Per Second = 1
Read = Write
Storage capacity = 100 bytes of info per space
1000*100 = 1 MB storage
API design
- GET /show_map - returns the map with following information
[{
space1:{status:"Free", park_type:"Car"},
space2:{status:"Occupied", park_type:"Truck"
}]
- GET /recommendation/{:vehicle_type}
returns the recommendation list
[{
rank:1, floor:1, park_no:16
},
{
rank:2, floor:2, park_no:22
}
]
- POST /place_order
{park_no:22}
- POST /confirmation
{
park_no:22
vehicle_id:2000
}
- POST /complete_order
{
vehicle_id:2000
}
Database design
Choice of DB - SQL
inventory
- park_no:int(PK)
- space_specification:
- status:Free/Occupied
- CostPerHour
- star rating
parking
- user_id:
- park_no
- order_id
- bill_details
- vehicle_details
High-level design
Assumption:
System has 3 types of parking space
1. Car
2. Truck
3. TwoWheeler
Core Entities:
- Authentication Service
- Inventory Service
- Parking Service
- Recommendation Service
- Billing service
- Payment Service
Authentication Service:
- User can create an account and use the application or use guest login facility.
- If created account, login API validates the user
- Manages profile information for the user.
Inventory Service:
- Display the area map with information like park space type, occupied or free with cost information
- Overall availability count.
- Availability count for each park type
Recommadation Service:
Receives vehicle type criteria from user, this service talks to inventory service to match vehicle type with park type and based on availability runs a ranking algorithm and provides a recommendation to User.
Parking Service:
User chooses a park space and makes book request, this service processes the request and assigns the park space chosen by user.
Use can also use random pick, in that case parking service, talks to recommendation service and gets the rank 1 data and assign it to user.
This service also ensures the vehicles are correctly parked in the chosen park space, with a confirmation request from park space.
Also handles the exit request of user and makes the park type status back to available.
Billing Service:
Upon exit request, calculates the bill amount and send notification to user, Pay option is enabled in APP.
Payment Service:
Handles payment request from user with integration of Payment service provider.
Request flows
- User: Able to see the whole parking space map.
- User: specify criteria and check for recommendation
- Place order by choosing a park space from recommendation
- User has random pick option for the system to decide the space and return the park number to user.
Detailed component design
Parking service plays a crucial role in deciding which parking space to chose, by talking to recommendation service, by running a matching algorithm.
This algorithm - considers features like vehicle dimension, nearby space vehicle dimension, nearby slot occupied or free information, taking into account all this information
If he is a regular customer, algorithm also considers previous allotted space and try to provide the same based on availability
Trade offs/Tech choices
- Can use redis cache to store availability information for low latency
Failure scenarios/bottlenecks
- handle down service failure with circuit breaker pattern and appropriate fallbacl
Future improvements
- improved recommendation algorithm
- notification service
- if no space available, suggesting, nearest available park service.