System requirements


Functional:

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

  • Users can reserve a parking spot
  • User pays for parking spot
  • User can park a vehicle (compact, SUV, motorcycle, or electric) in a parking spot
  • User can leave prior to reservation time expires
  • Parking reservation will be voided if user does not show up after 12 hours


Non-Functional:

List non-functional requirements for the system...

  • Scalable: if more parking lots are created the system should not fail
  • Consistent: if a user books a parking spot, another user cannot book as well
  • Available


Capacity estimation

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


  • This system operates in 10 countries
  • The system has about 100 parking lots per country
  • Each parking lot can hold 200 cars
  • 80% of users will park short term
  • 20% of users will park long term


Parking lots:

10*100 = 1000 parking lots


Total parking spots:

10*100*200 = 200,000 parking spots


Reservation rates per day:

If ~200 reservation requests in a day, 200 requests per parking lot * 100 parking lots = 20,000 reservations per day


Across all countries: 20,000 requests/day * 10 countries = 200,000 requests/day


Data storage:

  • Estimate: Reservation ID (8 bytes), User ID (8 bytes), Vehicle type (1 byte), Time stamps (16 bytes total)
  • Let's say an average reservation record is roughly 128 bytes.
  • Data generated per day = 200,000 requests * 128 bytes = 25.6 MB/day
  • In one year, that would sum up to approximately 9.36 GB.



API design

Define what APIs are expected from the system...


reserveParkingSpot ({

user_id,

lot_id,

vehicle_type,

start_time,

end_time

}) => reservation_id & price

checkAvailability({

lot_id,

vehicle_type,

available_spots,

total_spots

}) => available_spots & total spots

completeReservation({

reservation_id,

parking_token

}) => status


vehicleArrive({

reservation_id,

date_time

}) => status

vehicleLeave({

reservation_id,

date_time

}) => status


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 {

user_id

reservation_id,

lot_id,

vehicle_type,

start_time,

end_time,

payment_status,

completion_status,

date_created,

price,

spot_id

}



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


  • Client interacting via mobile or web app
  • API Gateway: routes requests to appropriate services
  • Reservation Service: handling reservations and managing availability
  • Payment Service: handles transactions securely
  • Parking Lot Management Service: maintains parking lot data & vehicle movement
  • Database: central storage for reservations, parking lot info, and more



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.


  • Many requests to reserve at same time
  • External payment service goes down



Future improvements

What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?


  • Multiple vehicles
  • Multiple parking lot reservations
  • Multiple parking spots
  • Monthly passes