Design Elevator Management System

Difficulty: MEDIUMCategory: LLDFrequency: 1Asked On 2021-10-28

Problem Statement

Design a Low-Level Design (LLD) for an Elevator Management System that controls multiple elevators in a building. The system should efficiently handle user requests, optimize elevator movement, and support multiple concurrent requests.


Functional Requirements (FR)


Elevator Management


•Support multiple elevators in a building.
•Each elevator has a current floor, direction (up/down/idle), and capacity.
•Elevators can move to requested floors based on requests.


User Requests


•External requests: Users call an elevator from a floor (Up/Down).
•Internal requests: Users inside an elevator select a destination floor.
•Requests should be assigned to the most suitable elevator.


Scheduling & Optimization


•Minimize wait time and travel time.
•Avoid unnecessary stops.
•Support concurrent requests efficiently.


Elevator Operations


•Move between floors.
•Open/close doors with safety checks.
•Handle overcapacity gracefully.


Notifications & Alerts


•Notify users when elevator arrives.
•Alert in case of errors or maintenance mode.


Non-Functional Requirements (NFR)


•Scalability: Support buildings with many floors and elevators.
•Reliability: Ensure no request is lost and elevator movement is safe.
•Low Latency: Assign requests and move elevators promptly.
•Extensibility: Easily add new scheduling algorithms or sensors.


Core Entities / Classes


Elevator


•Attributes: id, currentFloor, direction, capacity, occupants, status
•Methods: moveTo(floor), openDoor(), closeDoor(), addPassenger(user), removePassenger(user)


Floor


•Attributes: floorNumber, upButtonPressed, downButtonPressed


Request (Abstract)


•Attributes: requestId, floorNumber, direction
•Subclasses: ExternalRequest, InternalRequest


ElevatorController


•Attributes: elevators (list of Elevator), pendingRequests (queue)
•Methods: assignElevator(request), scheduleNextMove(), processRequest(request)


User / Passenger


•Attributes: userId, name, currentFloor, destinationFloor
•Methods: pressButton(floor, direction)


Scheduler (Strategy Pattern)


•Methods: selectElevator(request) → Implements algorithms like Nearest Car, Collective Control, etc.


Key Operations


•requestElevator(floor, direction) → External request from a floor.
•selectFloor(elevatorId, floor) → Internal request from inside elevator.
•assignElevator(request) → Choose the best elevator for the request.
•moveElevator(elevatorId) → Move elevator one step towards target floor.
•openDoor(elevatorId) / closeDoor(elevatorId)


Design Considerations


•Use priority queues or sorted lists to manage requests efficiently.
•Track elevator direction and current floor to assign requests optimally.
•Implement thread-safe handling for multiple concurrent requests.
•Scheduler can be pluggable to support different algorithms.


Example Flow


1.User presses "Up" at floor 5 → ExternalRequest generated.
2.ElevatorController checks elevators → selects the nearest idle/up elevator.
3.Elevator moves to floor 5 → opens door → passengers enter.
4.Passengers select destination floor → InternalRequest added.
5.Elevator moves to destination floors, stops accordingly, and repeats scheduling.


✅ This is a complete LLD Problem Statement for Elevator Management System.

Solution

Comments