Loading...
POST /entries
Request
{
"licensePlate": "30A12345",
"vehicleType": "CAR"
}
Response
{
"ticketId": "T123",
"slotId": "A-101"
}
POST /exits
Request
{
"ticketId": "T123"
}
Response
{
"amount": 50000,
"status": "PENDING"
}
POST /payments
GET /parking-slots/available?vehicleType=CAR
+-------------+
| Mobile App |
+------+------+
|
v
+-------------+
| API Gateway |
+------+------+
|
+------------+-------------+
| | |
v v v
+--------+ +-----------+ +----------+
| Ticket | | Allocation| | Payment |
|Service | | Service | | Service |
+----+---+ +-----+-----+ +-----+----+
| | |
+-----------+-------------+
|
+-----------+
| Database |
+-----------+
Entry Gate --> Ticket Service
Exit Gate --> Payment Service
Maintains available slots by vehicle type.
Data Structure
CAR Heap:
A1
A2
A5
A8
Allocation:
Complexity:
Allocate: O(log n)
Release : O(log n)
Stores active parking sessions.
Ticket
ticket_id
slot_id
license_plate
vehicle_type
entry_time
exit_time
status
Responsibilities:
Responsibilities:
Example pricing:
First hour : 2 Additional hour : 1 Daily cap : $20
ParkingSlot
slot_id
vehicle_type
status
zone
floor
Status:
AVAILABLE
RESERVED
OCCUPIED
OUT_OF_SERVICE
Prevent double allocation using atomic updates:
UPDATE ParkingSlot
SET status='RESERVED'
WHERE slot_id='A1'
AND status='AVAILABLE';
If no row is updated, retry with another slot.
ParkingSlot(slot_id, vehicle_type, status)
Ticket(ticket_id, slot_id, vehicle_type,
license_plate, entry_time, exit_time)
Payment(payment_id, ticket_id,
amount, status)
VehicleEntered, VehicleExited, PaymentCompleted) for analytics and monitoring.