# khardikk/lift-simulation architecture

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

- Interactive diagram: https://gitdiagram.com/khardikk/lift-simulation
- Repository: https://github.com/khardikk/lift-simulation

## Overview

##### Main Components
- UI Layer:
- HTML (index.html) for structuring the page and capturing user inputs (number of floors and lifts).
- CSS (main.css) for styling and ensuring a mobile-friendly design.
- Visual components (lift animations, buttons for floors) that the user interacts with.
- Application Logic (“JS Engine”):
- JavaScript (main.js) acts as the controller that handles the simulation logic:
▫ Processes user inputs.
▫ Maintains a simple data store that represents the application’s state (e.g., current floor of each lift, door states, movement delays).
▫ Implements the simulation rules (like door open/close delays, movement speed, stopping behavior).
- Data State:
- Although not in a separate file, the state is an essential component managed by the JS engine. Think of it as an internal model within the JavaScript code that tracks the status of lifts and floors.

##### Relationships & Interactions
- User interactions are captured in the UI (via input fields and floor buttons).
- These interactions are forwarded to the JS engine, which updates the data state accordingly—for example, determining which lift should go to a specific floor.
- The JS engine then issues commands to update the UI (moving lifts, triggering door animations) based on the simulation’s logic.
- The flow from the user’s input on the UI to the JS engine.
- The JS engine’s decision-making and state updates.
- The subsequent update instructions from the JS engine back to the UI components.

##### Important Architectural Patterns & Design Principles
- Separation of Concerns:
- The UI is completely “dumb” in that it only reflects the state and receives instructions.
- The JS engine separately manages the business logic (lift mechanics) and the application state.
- Event-Driven Interaction:
- The architecture heavily relies on events (user clicks, time-based animations) where the JS engine is the central controller reacting to these events.

##### Relevant Technologies and Frameworks
- Vanilla JavaScript, HTML, and CSS – there is no use of modern front-end frameworks given the simplicity of the project.
- Animation/timing logic is handled in JS (setTimeout & setInterval might be used to simulate the door animations and lift movements).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Interactions"]:::external

    subgraph "UI Layer"
        HTML["HTML (index.html)"]:::ui
        CSS["CSS (main.css)"]:::ui
        UIForm["Input Form"]:::ui
        UIDisplay["Interactive Lift Display"]:::ui
    end

    JS["JS Engine (main.js)"]:::controller
    DS["Data Store / State"]:::data

    User -->|"EventTrigger"| UIForm
    UIForm -->|"SendInput"| JS
    JS -->|"StateUpdate"| DS
    DS -->|"StateRetrieval"| JS
    JS -->|"UICommand"| UIDisplay
    JS -->|"Render"| HTML
    JS -->|"StyleUpdate"| CSS
    User -->|"Observes"| UIDisplay

    click HTML "https://github.com/khardikk/lift-simulation/blob/main/src/index.html"
    click CSS "https://github.com/khardikk/lift-simulation/blob/main/src/css/main.css"
    click JS "https://github.com/khardikk/lift-simulation/blob/main/src/js/main.js"
    click DS "https://github.com/khardikk/lift-simulation/blob/main/src/js/main.js"

    classDef ui fill:#f9e79f,stroke:#000,stroke-width:1px;
    classDef controller fill:#aed6f1,stroke:#000,stroke-width:1px;
    classDef data fill:#abebc6,stroke:#000,stroke-width:1px;
    classDef external fill:#f5b7b1,stroke:#000,stroke-width:1px;
```
