List functional requirements for the system (Ask the chat bot for hints if stuck.)...
User can reserve a parking spot.
User pays for the reservation
User can park a car on the parking lot
User can leave before the reservation time expires.
User can be absent with reservation, and we may charge it
List non-functional requirements for the system...
Scalability
Availability
Consistency
Assumption:
20 countries, 100 parking lots for each one
we do both short term and long term and only 20% user do long term parking.
Each parking lots has 200 parking spots
Each parking lots receives 400 reservations per day
20 * 100 = 20000 parking lots
2000 * 400 = 800000 reservations a day
each reservation would be:
reserve id (8 bytes)
userId (8 bytes)
car type (1 byte)
Reservation start time (8 bytes)
Reservation end time (8 bytes)
Define what APIs are expected from the system...
List
List
reserve_ID reserve_spot(auth_token, user_id, lot_id, vehicle_type, start_date_time, end_date_time)
vehicle_arrived(reserve_id)
vehicle_left(reserve_id)
Reservation Table
reservation_id (primary_key)
sport_id (foreign_key)
user_id (foreign_key)
vehicle_id (foreign key)
start_time
end_time
Payment Table
payment_id (primary key)
user_id (foreign_key)
payment_status
update_time
Sport Table
sport_id
lot_id
status
spot_num
Lot Table
lot_id
contact_id
vehicale table
vehicle_id (primary key)
user_id (foreign key)
vehicle_type
plate_numer
parking_staus table:
status_id
status
check_in
check_out
user_id
vehicle_id
client -> payment
client -> api_gateway
api_gateway -> reservation_service -> database
api_gateway -> parking_staus -> database
status_monitoring -> database
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...
it will first call getLot or view lot on local/remote cache
if user click on any lot, it will allow user to reserver with reserve_spot
it will redirect user with payment service and create a reserve_spot request, if payment is made and being called from payment service by call back with a transaction_id, it will process the payment
it can be failed under below cases:
mointor service peroidically check the databse for status and collect payment for absent users
if there is a wrong state happend such as vehicle try to left when it never left or it over stay, the admin will be notified or maybe some auto action will be excuted base on exsiting rule
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...
Explain any trade offs you have made and why you made certain tech choices...
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?