System requirements


Functional:

These requirements will include:

  1. Allow a user to park a car. This can include params such as vehicle type, vehicle number etc. The user can choose spot based on their vehicle, there will be a timestamp and ticket generted on entry and provide estimate for parking based on traffic in the lot.
  2. Allow a user to retrieve car via their ticket and allow user to pay via some payment method based on exit time.
  3. Allow user shortest time to park and find car. These can include optimizations.



Non-Functional:

  1. The user should get the ticket as soon as they send request.
  2. The user should have a seamless process in payment. Ideally we should have payment booths near to lift lobbys and such areas.
  3. Depending on capacity of lot, the system should be able to handle concurrent users and process payment times within 3 seconds.




Capacity estimation

Lets say we have a parking lot with a capacity of 500 spots. Each vehicle type can take certain number of spots based on vehicle type. That means at most there can be 500 requests/second in one parking lot.

Say we have X number of parking lots in existence. Then we are looking at a system which should be able to handle 500*X requests/sec. If we say X is 100-200 parking lots, then we are looking at about 50,000-100,000 QPS.


This means we need multiple servers which can sit behind a load balancer for distributed traffic. These servers can be distirbuted geographically.


We are going to be storing user information, payment information as well as any additional information. We need fast lookups to quickly allow user to find their ticket and allow them to pay. We can use NoSQL database for this.




API design

We need API's to:

  1. Issue ticket to user upon entry.
  2. Lookup ticket to prompt user to pay upon exit and time spent parked.
  3. Allow user to pay amount due


The above ones are primary but we can have additioanl APIS to optimize our system such as faster algorithms.





Database design

The ER diagram takes care of this portion







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?