# ofkira/poo_final_elevator architecture

> Architecture diagram of the GitHub repository ofkira/poo_final_elevator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ofkira/poo_final_elevator
- Repository: https://github.com/ofkira/poo_final_elevator

## Overview

1. **Project shape**
   - This is a small Java application in a single package, `com.example`.
   - The architecture is centered on an **elevator simulation/domain model**, not on external infrastructure or frameworks.

2. **Entry point**
   - `Main.java` is the startup point.
   - It likely wires together the elevator, controller, floors, and any initial requests, then drives the simulation from there.

3. **Core domain entity: Elevator**
   - `Elevator.java` is the main stateful object.
   - It represents the moving cabin and is the hub for motion, current floor, direction, door state, and possibly request handling.

4. **Control layer**
   - `ElevatorController.java` is the main orchestration component.
   - Its role is to receive requests, decide the next action, and coordinate elevator movement and door operations.
   - This is the clearest boundary between “user/request input” and “physical elevator state.”

5. **Request flow**
   - `Request.java` models a call to the elevator.
   - A request likely captures a source floor, destination floor, and/or direction, and is consumed by the controller to drive movement decisions.

6. **Floor model**
   - `Floor.java` represents a building floor.
   - It is likely used to identify floor numbers and attach floor-side controls such as call buttons.

7. **Button hierarchy**
   - `Button.java` is the base class for button behavior.
   - `FloorButton.java` and `CabinButton.java` extend it, matching the README’s note about inheritance.
   - This separates **external calls from floors** and **internal cabin selection** while sharing common button behavior.

8. **Mechanical subsystems**
   - `Door.java` models the elevator door lifecycle, such as opening and closing.
   - `Sensor.java` models safety/position detection logic, likely used to validate movement or door status.
   - These classes act as supporting subsystems around the elevator’s core motion.

9. **Direction handling**
   - `Direction.java` is an enum or similar type representing movement state, probably up, down, and possibly idle.
   - It is a small but important cross-cutting type used by the elevator and controller.

10. **Likely runtime interaction**
   - A floor or cabin button is pressed.
   - That action creates or triggers a `Request`.
   - `ElevatorController` evaluates the request and commands `Elevator` to move.
   - `Elevator` updates its floor and direction, while `Door` and `Sensor` support safe transitions.

11. **Design style**
   - The README explicitly mentions using **polymorphism, inheritance, and encapsulation**.
   - The code is organized as a classic object-oriented domain model with behavior distributed across specialized classes rather than a monolithic procedure.

12. **Diagram boundaries to show**
   - Separate the system into:
     - **UI/input objects**: buttons
     - **coordination**: controller
     - **domain state**: elevator, floor, request, direction
     - **mechanical support**: door, sensor
   - The main internal dependency is from buttons and requests into the controller, and from the controller into elevator movement and door/sensor state.

13. **What is not present**
   - There is no sign of a database, network API, GUI framework, or external service integration.
   - The architecture appears self-contained and suitable for a console-based or classroom-style simulation.

Main entry points: [`POO_Final_Ascensor/src/com/example/ElevatorController.java`](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/ElevatorController.java) (Controller), [`POO_Final_Ascensor/src/com/example/Main.java`](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Main.java) (Main), [`POO_Final_Ascensor/src/com/example/Elevator.java`](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Elevator.java) (Elevator), [`POO_Final_Ascensor/src/com/example/Request.java`](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Request.java) (Request)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry point"]
  node_main(("Main<br/>startup<br/>[Main.java]"))
end

subgraph group_input["Input layer"]
  node_button["Button<br/>base class<br/>[Button.java]"]
  node_floor_button["Floor button<br/>floor control<br/>[FloorButton.java]"]
  node_cabin_button["Cabin button<br/>cabin control<br/>[CabinButton.java]"]
end

subgraph group_coordination["Coordination"]
  node_controller["Controller<br/>orchestrator"]
end

subgraph group_domain["Domain model"]
  node_request["Request<br/>call model<br/>[Request.java]"]
  node_elevator[("Elevator<br/>stateful core<br/>[Elevator.java]")]
  node_floor["Floor<br/>building unit<br/>[Floor.java]"]
  node_direction{{"Direction<br/>enum<br/>[Direction.java]"}}
end

subgraph group_mechanical["Mechanical support"]
  node_door["Door<br/>mechanism<br/>[Door.java]"]
  node_sensor["Sensor<br/>safety check<br/>[Sensor.java]"]
end

node_main -->|"starts"| node_controller
node_main -->|"creates"| node_elevator
node_main -->|"creates"| node_floor
node_main -->|"creates"| node_floor_button
node_main -->|"creates"| node_cabin_button
node_floor_button -->|"extends"| node_button
node_cabin_button -->|"extends"| node_button
node_floor_button -->|"triggers"| node_request
node_cabin_button -->|"triggers"| node_request
node_request -->|"consumed by"| node_controller
node_controller -->|"commands"| node_elevator
node_controller -->|"coordinates"| node_door
node_controller -->|"checks"| node_sensor
node_controller -->|"uses"| node_direction
node_elevator -->|"interacts with"| node_door
node_elevator -->|"monitors"| node_sensor
node_elevator -->|"tracks"| node_direction
node_floor -->|"hosts"| node_request

click node_main "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Main.java"
click node_button "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Button.java"
click node_floor_button "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/FloorButton.java"
click node_cabin_button "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/CabinButton.java"
click node_request "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Request.java"
click node_controller "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/ElevatorController.java"
click node_elevator "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Elevator.java"
click node_floor "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Floor.java"
click node_direction "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Direction.java"
click node_door "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Door.java"
click node_sensor "https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Sensor.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_button,node_floor_button,node_cabin_button toneAmber
class node_controller toneMint
class node_request,node_elevator,node_floor,node_direction toneRose
class node_door,node_sensor toneIndigo
```

## Components

### Entry point

Application startup and wiring

- [Main](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Main.java): startup · Bootstraps the simulation and wires core objects · `POO_Final_Ascensor/src/com/example/Main.java`

### Input layer

User-facing controls that initiate requests

- [Button](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Button.java): base class · Shared button behavior for floor and cabin controls · `POO_Final_Ascensor/src/com/example/Button.java`
- [Floor button](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/FloorButton.java): floor control · External call button used from building floors · `POO_Final_Ascensor/src/com/example/FloorButton.java`
- [Cabin button](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/CabinButton.java): cabin control · Internal cabin selection button · `POO_Final_Ascensor/src/com/example/CabinButton.java`

### Coordination

Orchestrates requests and elevator actions

- [Controller](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/ElevatorController.java): orchestrator · Receives requests and decides elevator actions · `POO_Final_Ascensor/src/com/example/ElevatorController.java`

### Domain model

Core elevator state and shared types

- [Request](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Request.java): call model · Represents a ride request or destination intent · `POO_Final_Ascensor/src/com/example/Request.java`
- [Elevator](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Elevator.java): stateful core · Main cabin state and movement logic · `POO_Final_Ascensor/src/com/example/Elevator.java`
- [Floor](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Floor.java): building unit · Represents a building floor and its identity · `POO_Final_Ascensor/src/com/example/Floor.java`
- [Direction](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Direction.java): enum · Movement state such as up, down, or idle · `POO_Final_Ascensor/src/com/example/Direction.java`

### Mechanical support

Door and sensor subsystems

- [Door](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Door.java): mechanism · Models door opening and closing lifecycle · `POO_Final_Ascensor/src/com/example/Door.java`
- [Sensor](https://github.com/ofkira/poo_final_elevator/blob/main/POO_Final_Ascensor/src/com/example/Sensor.java): safety check · Provides position and safety feedback · `POO_Final_Ascensor/src/com/example/Sensor.java`

## Connections

- Main → Controller: starts · Main wires and runs the controller
- Main → Elevator: creates · Main initializes the elevator state
- Main → Floor: creates · Main prepares floor objects
- Main → Floor button: creates · Main may wire floor-side controls
- Main → Cabin button: creates · Main may wire cabin-side controls
- Floor button → Button: extends · FloorButton inherits shared button behavior
- Cabin button → Button: extends · CabinButton inherits shared button behavior
- Floor button → Request: triggers · Floor button press initiates a request
- Cabin button → Request: triggers · Cabin button press initiates a request
- Request → Controller: consumed by · Controller evaluates incoming requests
- Controller → Elevator: commands · Controller directs motion and state changes
- Controller → Door: coordinates · Controller manages door operations
- Controller → Sensor: checks · Controller relies on sensor feedback
- Controller → Direction: uses · Controller reasons about movement direction
- Elevator → Door: interacts with · Elevator opens and closes through the door subsystem
- Elevator → Sensor: monitors · Elevator state is guarded by sensor feedback
- Elevator → Direction: tracks · Elevator keeps current movement direction
- Floor → Request: hosts · Floors are the source or target of requests
