System requirements


Functional:

  • User choose a slot to book for a certain duration
  • User pays for reservation
  • User park a car
  • User can leave before the reserved time
  • when a user makes a reservation, but fails to show up, he pays some money




Non-Functional:

  • Available
  • Consistent/Monolith
  • Scalable




Capacity estimation

  • The company has operations in 10 countries.
  • The company has 100 parking lots, on average, in one country.
  • On average, each parking lot has a capacity of 200 cars.
  • 80% of users use it for short term parking, averaging 4 hours.
  • 20% of users use it for long term parking, averaging 5 days.
  • Each parking lot has 200 parking spots on average.
  • Each parking lot receives 200 reservation requests per day.


Estimation:

  • 10 * 100 = 1000 parking lots.
  • The system receives 200 * 1000 = 200.000 reservation requests per day.
  • Each reservation would mainly consists of:
    • Reservation ID (8 bytes)
    • User ID (8 bytes)
    • Car type (1 byte)
    • Reservation start time (8 byte)
    • Reservation end time (8 byte)


Roughly speaking, let's assume this would total 128 byte in total.


  • Each day, we will add 200K * 128 = 25.6MB of data.
  • In 2 years, it would add up to 25.6 * 365 * 2 * 1.5 = 280 GB (assuming future growth).






API design


  • check_capacity(lot_ID, vehicle_type, start_date_time, end_date_time) Returns the number of open spots in the given parking lot. It also returns the price.


  • reserve_spot(user_ID, lot_ID, vehicle_type, start_date_time, end_date_time) Returns the reservation ID and the price.


After reserve_spot(), user is forwarded to a 3rd party payment mechanism (e.g. PayPal or credit card). We assume that the user receives a token which proves the user made the payment.


  • complete_reservation(user_ID, reservation_ID, payment_token): This verifies the payment token with the 3rd party payment mechanism, and finalizes the reservation.


APIs used by 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...







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?