End-to-End Reserve Journey: 1. Uあser searches → 2. System holds a spot (Status: PENDING) → 3. User pays → 4. Payment Gateway sends callback → 5. System confirms reservation (Status: CONFIRMED).
Payment Handoff & Callback: The system hands off to a 3rd-party (e.g., Stripe) with a unique SessionID. Once paid, Stripe hits our Webhook endpoint. This ensures we don't rely on the client-side redirect for critical state changes.
Define the system constraints to ensure stability and performance.
| Method | Endpoint | Headers | Description |
POST | /v1/reservations | Idempotency-Key | Reserves a spot. Required key to prevent duplicate bookings on retries. |
GET | /v1/reservations/{id} | - | Poll for reservation status. |
POST | /v1/payments/webhook | X-Signature |
Secure callback from payment provider to finalize reservation.
LotID to mitigate Hot-lot surge.REPEATABLE READ isolation to handle overlapping intervals correctly during the "Check Availability" phase.To handle high traffic for a specific popular lot ("Hot-lot"), we implement Distributed Rate Limiting at the Gateway level and use Redis distributed locks with a short TTL for the specific LotID_TimeWindow key during the booking process.
When a user starts a booking, we create a temporary hold for 10 minutes.
Payment Webhook check if the hold is still valid. If expired, it triggers an automatic refund process via the Payment Service.To ensure a retry of a POST /reservations call doesn't create two bookings:
Idempotency-Key.NOT EXSITS and interval overlap logic: