LLD-5 Elevator System

Akhilesh Mahajan
2 min readFeb 5, 2024

--

In this article, we will discuss and design an Elevator system. Honestly, I feel it's a bit complex problem to design 👀, So I will put down my thoughts and ideas while designing the same.🥸

Requirements Gathering and Clarification:

  1. An elevator is present in a building.
  2. The building may have n number of floors.
  3. The building may have any number of elevators.
  4. Any number of elevators can be added or removed based on the need.
  5. All floors have elevator panels.
  6. Panels consist of buttons (the external side) indicating the direction the user wants to go.
  7. An elevator car has buttons on the internal side, indicating which floor the user wants to go to.
  8. The elevator moves in such a way that there is minimum response time.
  9. A person can enter the elevator only when it is stopped and the doors are open.
  10. The elevator's chosen strategy should be dynamic.
  11. Elevator moving strategy should be dynamic.
  12. A dispatcher is responsible for gathering requests from buttons on both internal and external sides.
  13. A panel controller is mainly responsible for choosing a lift based on the strategy provided.
  14. We should maintain the top floor and the lowest floor number.

Class Identification and Class Diagram:

From the requirements, we can identify the below classes.

  1. Building
  2. Floor
  3. External Panel
  4. Elevator Car
  5. Internal Buttons
  6. Door
  7. Elevator System

Following are the enums that we can use

  1. Direction: Upside/ Downside
  2. Request Type: Internal Request/ External Request
  3. Status: Moving/ Idle/ Stopped/ Not Available/ Open/ Closed

The class Diagram is as under:

Class Diagram

Code Explanation:

  • Let’s discuss about elevator controller, whose main responsibility is to control the elevator functionality.
    The elevator controller involves:
    1) upsideReq: requests for going upside.
    2) downsideReq: requests for going downside.
    3) elevatorMovingStrategy: strategy using which elevator moves to different floors.
    4) elevator: an object to the elevator
  • Now, let's discuss about external panel controller
    External Panel Controller involves:
    1) elevatorChoosingStrategy: a strategy to find which elevator to choose to go to some particular floor.
    2) externalPanel: an object to the external button panel.
  • Now let’s discuss about elevator system. Elevator system involves
    1) elevatorControllers: List of elevator controllers which regulate each elevator.
    2) externalPanelControllers: List of external panel controllers that send requests from the floor whether to upside or downside.

References:

GitHub Code Repo ✍️: https://github.com/Akhilesh53/Design/tree/main/Elevator

Follow for more on LinkedIn ✌🏻.

--

--

Akhilesh Mahajan

Full-Stack Developer | Golang, Java, Rust, Node, React Developer | AWS☁️, Docker, Kubernetes | Passionate about distributed systems and cloud-native application