Let's design an elevator system. We want to focus on the core functionalities of moving people efficiently between floors in a building.
Here are some key use cases to consider:
Let's design an elevator system. I've worked on similar distributed systems at Amazon, so I'm drawing from that experience.
Functional Requirements:
Non-Functional Requirements:
We'll use a centralized architecture with the following components:
Communication:
Table | Columns | Data Type(s) | Description |
---|---|---|---|
Elevators | elevator_id (PK), current_floor , status (idle , moving ), capacity , current_load , direction (up , down , stationary ) | INT, INT, ENUM, INT, INT, ENUM | Information about each elevator |
Requests | request_id (PK), elevator_id (FK), pickup_floor , destination_floor , request_time , status (pending , assigned , completed ) | INT, INT, INT, INT, TIMESTAMP, ENUM | Requests for elevator service |
FloorButtons | floor_number (PK), up_button_status (active , inactive ), down_button_status (active , inactive ) | INT, ENUM, ENUM | Represents the state of the up and down buttons on each floor |
Request Manager APIs:
POST /request
: Submits a new elevator request.
{floor: INT, direction: ENUM ('up', 'down')}
{request_id: INT}
Elevator Controller APIs:
GET /elevators
: Returns the status of all elevators (for monitoring).
[{elevator_id: INT, current_floor: INT, status: ENUM, ...}]
POST /elevators/{elevator_id}/move
: Instructs an elevator to move to a specific floor.
{floor: INT}
OK
Elevator APIs (internal):
POST /elevator/{elevator_id}/update
: Updates the status of the elevator (e.g., current floor, status).
{current_floor: INT, status: ENUM}
OK