Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
Objects: User, Lot, Reservation, ParkingEvent
`/users/`
`/lots/`
`/reservations/`
`/parking-events/`
Users register themselves
Lots are created by admins
Reservations are made by users
Parking Events are recorded as they occur (check-in/check-out)
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Separate UIWorkflow from API layer in order to keep API layer simple/agnostic of UI concerns.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
start_time
end_time
user_id
lot_id
payment_id
Payments are handled by an outside system via the UIWorkflow system.
The Parking Lot Server will need to communicate with the Gates at each lot in order for them to know that one of our users is parking there. The gates will need to query the parking lot server to determine whether a user can park or not so that it can open the gate to the lot for the car. It will also need to inform the parking lot server when the user checked in and checked out.
Reservations require finding a time window where the lot has sufficient capacity. Reservations can fail between time user requests reservation and time the database attempts to commit due to async reservations consuming all capacity in a lot.
Finalizing the reservation flow is making a payment for it.
The system should book the reservation and reduce the capacity of the lot before attempting the payment in case the capacity is exceeded while the payment is outstanding. If the payment fails, the reservation is removed, opening up the capacity again.
We want to record Parking Events directly from the gates so that we can reconcile the reservation times/payments/costs with what actually occurred. When there is a discrepancy, we can handle refunds or collections as a separate effort.