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...
POST api/parking_lot/reservation
{
vehicle_number: str
vehicle_type: str (e.g. SUV, Sedan, truck, bike)
full_name: str
personal_id: str
time: int (minutes)
} -> Reservation {
spot: int
client_id: str
remaining_time: int
}
GET api/parking_lot/reservation?client_id=...
->Reservation
POST api/parking_lot/checkout
{
vehicle_number: str
client_id: str
}
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.
Load Balancer is used for failover, if one server fails, requests are router to another to ensure fault tolerance.
Reservation Service receives the reservation request from the client then sends a request to an external payment service e.g. Stripe. Stripe also handles idempotency and prevents the possibility of double payment.
We create a webhook so that when payment is done, Stripe sends a response back to the server. once this response is received, the MySQL DB is updated
MySQL DB
Checkout Service is responsible for deleting the row of that specific client.
We use the parking spot id as an idempotency key with TTL equal to the duration of the reservation. We add this key to Redis cache with a status PROCESSING. Once the data is written to mySQL DB we update the status to processed.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
MySQL DB
Reservation Service: