System Design: Multi‑Level Parking System
Context
Design the backend for a multi‑level parking facility. The system must track floors, rows, parking spots, and vehicle types. Some vehicles require multiple adjacent spots. The service should allocate and release spots on vehicle entry/exit and support queries for availability by vehicle/spot type and by floor.
Assume:
-
Vehicles: motorcycle, car, van/SUV, bus/truck (some may require k adjacent standard spots).
-
Spots: motorcycle, compact, regular, large, EV (flag for charging capability), each on a specific floor and row, with a sequential index for adjacency.
-
Adjacency means contiguous indexes within the same row.
Requirements
-
Define core data models (entities, relationships, key fields).
-
Define APIs for:
-
Vehicle entry (allocate spot(s) and issue a ticket/allocation).
-
Vehicle exit (release spot(s)).
-
Queries: available spots by type and by floor; availability for a given vehicle type.
-
Address allocation for vehicles that need multiple adjacent spots.
-
Note key constraints, concurrency handling, and performance considerations.