System requirements


Functional:

List functional requirements for the system (Ask the chat bot for hints if stuck.)...

  1. we need to be able to reserve parking spots
  2. we need to be able to pay for reservations
  3. we need the user to park in the spot
  4. the user can leave before the reservation expires
  5. 3 different parking types - compact, standard, and electric size
  6. if user reserves and fails to show up, only charge for 24 hours


Non-Functional:

List non-functional requirements for the system...


  1. consistency is prioritized because we don't want double bookings
  2. scalability - we are designing for international booking company with thousands of parking garages across the world




Capacity estimation

Estimate the scale of the system you are going to design...


i assume:

  • the company has operations in 10 countries
  • the company has 100 parking lots, on average, in each country
  • on average, each parking lot has a capacity of 200 cars. 70% standard cars, 20% compact cars, and 20% electric chargers
  • 80% of users use it for short term parking aka 4 hours
  • 20% of users use it longer than 4 hours
  • for each parking lot, we are averaging 50 reservations requests per day

i estimate 10 * 100 = 1000 parking lots

for each day, the system recieves roughly 50,000 reservation requests

each reservation consists of:

  • car type (1 byte)
  • reservation start time (8 bytes)
  • reservation end time (8 bytes)
  • user id (20 bytes)
  • total, this is around 36 bytes



API design

Define what APIs are expected from the system...

APIs used by users:


  • check_capacity(lot_id, user_id, vehicle_type, start_time, end_time): returns the number of open spots in the parking lot. it also returns the price - tuple()
  • reserve_spot(user_id, lot_id, vehicle_type, start_time, end_time): returns the reservation id and the price as a tuple
  • pay(user_id, reservation_id): returns a confirmation message

APIs used at gate checking service at the parking lot:


  • vehicle_arrived(reservation_id, date_time)
  • vehicle_left(reservation_id, date_time)



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...

reservation table:


  • reservation_id (primary_key)
  • lot_ID (foreign key)
  • user_ID (foreign key)
  • start_time
  • end_time
  • vehicle_type (foreign key)
  • payment_status(boolean)
  • completion_status(boolean)



vehicle table:

  • vehicle id


lot table:

  • lot_ID (primary key)
  • parking_garage()
  • size()

lot capacity table:

  • lot_space ID
  • vehicle_type
  • numberofspaces


contact info table:

  • contact info id (primary key)
  • contact phone number
  • contact email


transactions:

  • id
  • user id (foreign key)
  • vehicle id (foreign key)
  • check_in_date_time
  • check_out_date_time









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...


CND caches static content for high performance (web assets for UI)

Rate Limiter protects service from DOS attacks

load balancers distribute requests to app servers using round robin algo


client > CDN > rate limiter > load balancer > api gateway > transaction server / reservation server










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?