Vehicle Entry & Exit:
Vehicle Types:
Space Management:
User Notifications:
Accessibility:
Security:
Scalability:
Reliability:
Performance:
Security:
50 cities in U.S, 100 parking lots per city, 200 slots per lot. 1 million slots per day. if avg parking time is 4 hours, 6 million QPS per day.
http
Copy code
POST /api/v1/vehicles
{
"licensePlate": "ABC123",
"type": "car" // Options: motorcycle, car, truck
}
201 Createdjson
Copy code
{
"vehicleId": "1234",
"licensePlate": "ABC123",
"type": "car"
}
http
Copy code
GET /api/v1/vehicles/{vehicleId}
200 OKjson
Copy code
{
"vehicleId": "1234",
"licensePlate": "ABC123",
"type": "car",
"status": "parked"
}
http
Copy code
GET /api/v1/parking-spaces?type=car&level=1
200 OKjson
Copy code
{
"availableSpaces": [
{ "spaceId": "A101", "level": 1, "type": "car" },
{ "spaceId": "A102", "level": 1, "type": "car" }
]
}
http
Copy code
POST /api/v1/parking-spaces/reserve
{
"vehicleId": "1234",
"spaceId": "A101"
}
200 OKjson
Copy code
{
"reservationId": "5678",
"vehicleId": "1234",
"spaceId": "A101",
"status": "reserved"
}
http
Copy code
POST /api/v1/entry
{
"vehicleId": "1234"
}
200 OKjson
Copy code
{
"entryId": "7890",
"vehicleId": "1234",
"entryTime": "2024-11-23T10:00:00Z"
}
http
Copy code
POST /api/v1/exit
{
"vehicleId": "1234"
}
200 OKjson
Copy code
{
"exitId": "4567",
"vehicleId": "1234",
"exitTime": "2024-11-23T14:00:00Z",
"parkingFee": 20.00
}
http
Copy code
POST /api/v1/payments
{
"vehicleId": "1234",
"amount": 20.00,
"paymentMethod": "credit_card"
}
200 OKjson
Copy code
{
"paymentId": "9988",
"status": "success",
"amount": 20.00
}
http
Copy code
GET /api/v1/admin/stats
200 OKjson
Copy code
{
"totalSpaces": 500,
"occupiedSpaces": 300,
"availableSpaces": 200,
"revenue": 1500.00
}
Stores information about customers and admins.
| ColumnTypeConstraintsDescription | |||
user_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for each user. |
name | VARCHAR(255) | NOT NULL | Full name of the user. |
email | VARCHAR(255) | UNIQUE, NOT NULL | User email for notifications. |
phone | VARCHAR(15) | UNIQUE | Contact number of the user. |
user_type | ENUM('admin', 'customer') | NOT NULL | Defines the type of user. |
created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of record creation. |
Tracks vehicles entering and exiting the parking lot.
| ColumnTypeConstraintsDescription | |||
vehicle_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for vehicles. |
license_plate | VARCHAR(20) | UNIQUE, NOT NULL | License plate of the vehicle. |
vehicle_type | ENUM('motorcycle', 'car', 'truck') | NOT NULL | Type of the vehicle. |
user_id | INT | FOREIGN KEY REFERENCES Users(user_id) | Owner of the vehicle. |
created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of record creation. |
Defines metadata about a parking lot.
| ColumnTypeConstraintsDescription | |||
lot_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for parking lots. |
name | VARCHAR(255) | NOT NULL | Name of the parking lot. |
location | VARCHAR(255) | NOT NULL | Physical address of the lot. |
total_spaces | INT | NOT NULL | Total capacity of the parking lot. |
created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of record creation. |
Tracks levels within a parking lot.
| ColumnTypeConstraintsDescription | |||
level_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for parking levels. |
lot_id | INT | FOREIGN KEY REFERENCES ParkingLots(lot_id) | Associated parking lot. |
level_number | INT | NOT NULL | Level number (e.g., 1, 2). |
total_spaces | INT | NOT NULL | Total spaces on this level. |
created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of record creation. |
Tracks individual parking spaces.
| ColumnTypeConstraintsDescription | |||
space_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for parking spaces. |
level_id | INT | FOREIGN KEY REFERENCES ParkingLevels(level_id) | Associated level. |
space_number | VARCHAR(10) | NOT NULL | Unique number/identifier for the space. |
space_type | ENUM('small', 'medium', 'large') | NOT NULL | Size of the parking space. |
is_occupied | BOOLEAN | DEFAULT FALSE | Indicates if the space is occupied. |
created_at | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of record creation. |
Tracks reserved parking spaces for vehicles.
| ColumnTypeConstraintsDescription | |||
reservation_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for reservations. |
vehicle_id | INT | FOREIGN KEY REFERENCES Vehicles(vehicle_id) | Reserved vehicle. |
space_id | INT | FOREIGN KEY REFERENCES ParkingSpaces(space_id) | Reserved space. |
start_time | DATETIME | NOT NULL | Start of reservation. |
end_time | DATETIME | NOT NULL | End of reservation. |
status | ENUM('active', 'expired') | NOT NULL | Status of reservation. |
Logs vehicle entry and exit events.
| ColumnTypeConstraintsDescription | |||
log_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for logs. |
vehicle_id | INT | FOREIGN KEY REFERENCES Vehicles(vehicle_id) | Associated vehicle. |
entry_time | DATETIME | DEFAULT CURRENT_TIMESTAMP | Time of vehicle entry. |
exit_time | DATETIME | NULLABLE | Time of vehicle exit. |
space_id | INT | FOREIGN KEY REFERENCES ParkingSpaces(space_id) | Assigned parking space. |
Tracks payments for parking services.
| ColumnTypeConstraintsDescription | |||
transaction_id | INT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier for transactions. |
vehicle_id | INT | FOREIGN KEY REFERENCES Vehicles(vehicle_id) | Associated vehicle. |
amount | DECIMAL(10, 2) | NOT NULL | Payment amount. |
payment_time | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of payment. |
payment_method | ENUM('cash', 'credit_card', 'app') | NOT NULL | Payment method used. |
User calls api gateway to get authenticated and then the request will be forwarded to parking service if the user is authenticated. the reservation, entry, exit and payment will be saved to DB to make sure the state are permanently stored.
Entry Process:
Parking:
Exit Process:
Database will be SQL DB with replicas to avoid single point failure, replica can serve as master DB when there is fail over happens.
Load balancing to route to the machine with light load or faster response.
Database Choice:
Space Allocation Algorithm:
IoT Sensors:
Real-Time Updates:
avoid single point of failure in all components
distribute the parking spaces to different levels or physical areas to avoid traffic congestion inside the parking lot.