System requirements


Functional:

user can select the parking lot and position

user can purchase the ticket with time limit

admin can verify if the car is paid for parking


Non-Functional:

scale up as more parking lot over the world uses the system

consistency and stable




Capacity estimation

if each parking lot we have roughly 100 spot and we have 10 parking lot in the world. each spot will have 5 car each day. we will have 100 * 10 * 5 records of data stored in DB, which is 5000 * 365 per year.





API design

POST /park/{parkinglot#}/{spot#} request (vehicle plate#, valid time)

GET /verify/{parkinglot#}/{spot#} request (vehicle plate#)





Database design

table Record, schema: recordId, createdAt, parkinglot#, spot#, ticketId

table Ticket, schema: ticketId, vehiclePlate, createdAt, expairedAt, paymentId

table Payment, schema: paymentId, amount, currency, createdAt, agent







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

when user purchase the ticket, will create the payment first with calculated amount, then create ticket with valid time to set expiredAt. Then create the record.

when admin to check if the vehicle purchase the ticket, join Record and Ticket table and using the parkinglot#, spot# and vehicle plate to find the latest purchase. If the expired date is before now, it does not have valid ticket, vise versa





Detailed component design

when scale up, since most parking lots are located all around of the world, and unlikely the user in Canada will use the Asian parking lot very often. So we can scale horizontally for the SQL DB, and no need to connect all dbs, the server in each area will connect to it's own DB. So we can replicate this server and deploy to all over the world but data is not connected.





Trade offs/Tech choices

I assume the extentions will located all around the world





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?