-- No two vehicles to be reserved to same spot.
-- low latency, reliability
Reservation API:
-> VechicleDetails(vehicle entry time, type etc.
-> Reservation Service(db entry with BOOKING_PENDING status)
-> Spot Service, checks spot availability if available, lock the row(pessimistic lock) and return spot details, update the Spot status as OCCUPIED. if not, throw exception "No spot available" and rollback Reservation entry.
-> entry into outbox event
-> Reservation Service consumes the event and updates the status to BOOKED
-> Notification to user about Payment API:
ReservationService(update exit time, status to RELEASED
-> Payment service (payment gateway). if payment fails, rollback Reservation status
-> SpotService - update the spot status as AVAILABLE
-> Notification service - notify to user
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.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.