-- 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
Block diagram for HLD is on the right side. 3 main services/components play major role here:
each service has it's own db.
kafka message/event queue Queue to notify users and outbox pattern implementation.