1) post : api/reserveSpot/ -> this end point will create a request for reservation of a parking spot & redirect to payment
2) post : api/payment?userId -> this url handels payment's very securly and returns success to spot allocation
3) post : api/spotAllocation -> this end point will allocate a place for parking the car for the user and also decide the expire time
4) get : api/parkingId -> this end point will bring's coordinates of the parking spot for the car
5) post : api/check-in -> this end point start's timer
6) post : api/notify -> this end point will send's a alert to the user to avocate the parking of care before the time expires.
7) post : api/extendParkingtime: -> this url is used to extend the parking slot expire time by extra payment
8) post : api/check-out : -> this end point will check's weather the user has avocated within the time and also free up the slot for next car
Client App
|
API Gateway
|
--------------------------
Reservation Service
Payment Service
Allocation Service
Gate Service
Notification Service
--------------------------
|
DB + Cache + Queue
How does it work?
Possible logic:
Available spots
↓
Filter by:
↓
Choose nearest/optimal.
Possible DS:
Tradeoff:
Nearest vs load balancing.
How avoid double booking?
Need:
Locking.
Options:
Fast
Retry on conflict.
Safe
Lower concurrency.
Interview gold topic.
Background scheduler.
Every minute:
Check expired reservations.
If:
not checked-in
↓
cancel
↓
refund
↓
release spot.
Usually:
Queue + cron worker.