System requirements
Functional:
List functional requirements for the system (Ask the chat bot for hints if stuck.)...
1) Assign parking slot based on vehicle type
2) user should be able to book parking slot
3) Manage entry and exits
4) payment processing
Non-Functional:
List non-functional requirements for the system...
1) scalability
2) low latency
3) Highly available
4) Idempotency
5) Consistency
Capacity estimation
Estimate the scale of the system you are going to design...
capacity estimation depends on some facters
1) No of country where operates
2) no of parking lot per country
3) no of reservation request pr day
lets assume
No of country = 10
no of parking lot per country=100
no of reservation request pr day/per parking lot= 200
for this we need to store reservation_id ,user_id like fileds in database.
Assume one reservation takes 128 bytes.
Total memory required daily=
No of country * no of parking lot per country *no of reservation request pr day/per parking lot
10*100*200*128 = 24.4 MB per day
total memory required per year =24.4* 365 =8,906 MB
API design
As we operate in multiple country and have multiple paking facility in a single country we first need to list all parking lots in out application .
for this we need to kind of api one is user api and one is management side .
First we list user side api
- Fetch Parking lots based on location:
Criteria based api due to this its going to post instead of GET
Method : POST
Path : parking/lots
Headers :
session_id:xxxx
Content-Type:application/json
Request :
{
"lat":" ",
"long":" "
}
Response :
{
parking_lots:[
{
"parking_lot_name":"",
"parking_lot_no":"",
"parking_lot_contact_number":""
}
]
}
- Fetch All Parking slots : this api provides slots for parking based on parking lot number.
Criteria based api due to this its going to post instead of GET
Method: Post
path :/parking/slots
Headers
session_id:xxxx
Content-Type:application/json
Request
{
"parking_lot_no":"",
"vechicle_type:"", car/bike/etc....
}
response :
{
"slots": [
{
"floor_no": "",
"slot_no": ""
}
]
}
- Reserve slot : This api provides provide parking slot fee based on time selected and also return the payment Link
Method: post
Path :/parking/reserve/slot
Headers
session_id:xxxx
Content-Type:application/json
Request
{
"parking_start_time":"",
"parking_end_time":"",
"slot_no:"",
"vechicle_no:"",
"vechicle_usage_type":"" commerial/persoal....
}
response :
{
"payment": {
"link": ""
},
"fee":{
"base_payment_amount":"",
"tax_amount_payment":"",
"total_amount_to_be_pay":"",
}
}
In Real World solution based on payment is done by user. when payment is completed we will receive webhook from payment Partner and we do reservation change in database. Till this time the there is database lock on that parking slot so that no one else can book.
if payment fails we removes the lock from that slot.
- Payment status : this api will provide payment status based on this api we will show user appropriate screen
Method: post
Path :/parking/payment-status
Headers
session_id:xxxx
Content-Type:application/json
Request
{
"slot_no":"",
}
response :
{
"status": "sucess/pending/initiated"
}
- Get Booking : this api used to customer done booking for parking slots
Method: GET
path :/parking/bookings
Headers
session_id:xxxx
Content-Type:application/json
response :
{
"booked_slots": [
{
"booking_details": {
"booking_staus": "", //this will provide booking status like book time is going on or not or it expired",
"booking_start_Time": "",
"booking_end_Time": "",
"vechicle_status": "", //User has parked it or not
"vechicle_no": "",
"slot_no": ""
},
"payment_details":{
"ref_no":"",
"payment_method":""
}
}
]
}
- Edit Booking : this api will provide user a way modify time of parking lot and cancel booking
Method: Post
Path :/parking/booking/edit
Headers
session_id:xxxx
Content-Type:application/json
Request
{
"modification_type": "", //CANCEL booking /modify -date time
"modification_date_time": {
"modified_booking_start_date_time": "",
"modified_booking_end_date_time": ""
}, //this will be null in case of CANCEL
"slot_no":""
}
Response
{
"bookedslots": [
{
"modified_booking_staus": "" //this status provide modification is done or not
}
]
}
Database design
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
High-level design
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Request flows
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Detailed component design
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?