System requirements


Functional:

  • efficiently manage vehicle entrance, exit and parking allocation
  • should accommodate different types of vehicles (not every parking spot accommodates every car type)
  • prioritize user convenience
  • safe and functional



Non-Functional:

  • scalable
  • available
  • performant
  • consistent
  • secure




Capacity estimation

  • 1000 parking lots in operation
  • 200 cars per parking lot (200k total parking spots)
  • 200 reservations per day (200k total)




API design






Database design





High-level design

  1. Car placement system: Looks at the parking lot information/available slots and the user's car type; assigns a slot for the car or returns false if the car doesn't fit
  2. User data service: Stores user data like car info, user name, etc
  3. Payment service: To start, we will leverage a payment system like Stripe; that way we don't have to store sensitive payment data in our systems
  4. Notification service: Simple service to send email or text notifications to users. To start, we will only send receipts after the user has paid.
  5. Analytics service


client -> car placement service -> user data service-> payment service -> notification service -> analytics service


Note that if we want to maximize availability and scale, we can place queues in between each service. We can use Kafka, for example. Then we can have consumers at each service that process the Kafka messages at the rate the systems allow. This approach will ensure we can scale without problems and will prevent high throughput to take down the system.



Request flows

  1. car comes in, makes a request via the api gateway
  2. we rate limit the requests to avoid abuse/performance issues
  3. the car placement service picks up the call, checks the car details and checks if there's space in the given parking lot; sends a kafka message out
  4. user data service picks up the message and checks the user details to make sure everything matches the user records; sends a kafka message out
  5. the payments service receives the message, processes the payment; sends a kafka message
  6. the notification service picks up the message and sends out an alert to the user
  7. the analytics service consumes all kafka messages and stores the data in an elastic search index; can use graphana to display the results and facilitate data analytics





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?