# rachitkumar205/visionhubos architecture

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

- Interactive diagram: https://gitdiagram.com/rachitkumar205/visionhubos
- Repository: https://github.com/rachitkumar205/visionhubos

## Overview

##### Main components
- Hardware Interface Layer:
- The actual ESP32 board, connected to an SSD1306 display and a set of input buttons.
- Drivers Layer:
- Driver (src/drivers/display.rs) – interfaces with the SSD1306.
- Input Driver (src/drivers/input.rs) – handles button input.
- The drivers are centralized within the drivers module (src/drivers/mod.rs).
- System Kernel Layer:
- Event Handling (src/system/events.rs) – manages system events.
- Process Scheduler (src/system/scheduler.rs) – basic scheduler to manage tasks.
- System module overall (src/system/mod.rs) forms the kernel’s backbone.
- User Interface (UI) Layer:
- UI Framework (src/ui/framework.rs) – provides abstractions for creating screens and animations.
- Animations (src/ui/animations.rs) and multiple UI Screens (src/ui/screens/home.rs, loading.rs, menu.rs) – create the interactive component.
- The UI module initialization is available via src/ui/mod.rs.
- Build & Configuration:
- Cargo configuration files (Cargo.toml, .cargo/config.toml) and build script (build.rs) denote build system details.
- rust-toolchain.toml shows the compiler specifics.
- sdkconfig.defaults may capture hardware-specific configurations.

##### Relationships and interactions
- The hardware layer communicates with the drivers layer. The display and input drivers directly interact with the physical hardware.
- Drivers feed data into the system kernel, where events are generated and processed. The process scheduler coordinates when and how different routines get executed.
- The UI layer listens to the events from the system and uses the scheduler’s updates to render new screens or animations.
- Internal dependencies: The UI framework relies on the underlying system events to update its state; similarly, the system components may trigger driver functions or changes as needed.

##### Architectural patterns and design principles
- Separation of Concerns: Each module (drivers, system, UI) is isolated such that changes in input/output handling (drivers) do not heavily impact the scheduler or UI rendering.
- Modular and Extensible Design: Adding or modifying drivers is straightforward as indicated by the README. This is facilitated by clear modular boundaries observed from the directory structure.
- Embedded OS Design: With its basic process scheduler and event handling, the code structure reflects typical small-scale operating system kernels used in embedded systems.

##### Technology and framework details
- Rust is the core language and Cargo is used for package/build management.
- Hardware-specific libraries or binding functions might be inferred under the drivers.
- The OS has a UI framework that may define its own abstractions for creating screens and animations.

##### Specific elements
- For each main module (Drivers, System, UI), include detailed labels specifying the responsible files (e.g., label “Display Driver – src/drivers/display.rs”).
- You may also include a side note highlighting that build and configuration files (Cargo.toml, build.rs, rust-toolchain.toml) support the codebase and provide necessary build-time configurations, even though they are not part of the runtime architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Hardware Interface"
        ESP32["ESP32 Board (with SSD1306 Display and Input Buttons)"]:::hardware
    end

    subgraph "Drivers Layer"
        DisplayDriver["Display Driver – src/drivers/display.rs"]:::drivers
        InputDriver["Input Driver – src/drivers/input.rs"]:::drivers
        DriversModule["Drivers Module – src/drivers/mod.rs"]:::drivers
    end

    subgraph "System Kernel Layer"
        EventHandling["Event Handling – src/system/events.rs"]:::kernel
        ProcessScheduler["Process Scheduler – src/system/scheduler.rs"]:::kernel
        SystemModule["System Module (Kernel Backbone) – src/system/mod.rs"]:::kernel
    end

    subgraph "User Interface (UI) Layer"
        UIFramework["UI Framework – src/ui/framework.rs"]:::ui
        UIAnimations["UI Animations – src/ui/animations.rs"]:::ui
        HomeScreen["UI Home Screen – src/ui/screens/home.rs"]:::ui
        LoadingScreen["UI Loading Screen – src/ui/screens/loading.rs"]:::ui
        MenuScreen["UI Menu Screen – src/ui/screens/menu.rs"]:::ui
        UIModule["UI Module Initialization – src/ui/mod.rs"]:::ui
    end

    subgraph "Build & Configuration"
        CargoToml["Cargo Build Configuration – Cargo.toml"]:::build
        CargoConfig["Cargo Configuration File – .cargo/config.toml"]:::build
        BuildScript["Build Script – build.rs"]:::build
        RustToolchain["Rust Toolchain Specification – rust-toolchain.toml"]:::build
        Sdkconfig["Hardware-specific Configuration – sdkconfig.defaults"]:::build
    end

    %% Connections between layers
    ESP32 -->|"drives"| DisplayDriver
    ESP32 -->|"drives"| InputDriver

    DisplayDriver -->|"registered_in"| DriversModule
    InputDriver -->|"registered_in"| DriversModule

    DriversModule -->|"sends_events_to"| EventHandling
    DriversModule -->|"triggers_scheduler"| ProcessScheduler

    EventHandling -->|"notifies"| UIFramework
    ProcessScheduler -->|"updates"| UIFramework

    UIFramework -->|"renders_using"| UIAnimations
    UIFramework -->|"renders"| HomeScreen
    UIFramework -->|"renders"| LoadingScreen
    UIFramework -->|"renders"| MenuScreen
    UIFramework -->|"initialized_by"| UIModule

    %% Build & Configuration support links (non-runtime)
    CargoToml ---|"supports_build"| DriversModule
    CargoToml ---|"supports_build"| SystemModule
    CargoToml ---|"supports_build"| UIModule

    %% Click Events
    click DisplayDriver "https://github.com/rachitkumar205/visionhubos/blob/main/src/drivers/display.rs"
    click InputDriver "https://github.com/rachitkumar205/visionhubos/blob/main/src/drivers/input.rs"
    click DriversModule "https://github.com/rachitkumar205/visionhubos/blob/main/src/drivers/mod.rs"
    click EventHandling "https://github.com/rachitkumar205/visionhubos/blob/main/src/system/events.rs"
    click ProcessScheduler "https://github.com/rachitkumar205/visionhubos/blob/main/src/system/scheduler.rs"
    click SystemModule "https://github.com/rachitkumar205/visionhubos/blob/main/src/system/mod.rs"
    click UIFramework "https://github.com/rachitkumar205/visionhubos/blob/main/src/ui/framework.rs"
    click UIAnimations "https://github.com/rachitkumar205/visionhubos/blob/main/src/ui/animations.rs"
    click HomeScreen "https://github.com/rachitkumar205/visionhubos/blob/main/src/ui/screens/home.rs"
    click LoadingScreen "https://github.com/rachitkumar205/visionhubos/blob/main/src/ui/screens/loading.rs"
    click MenuScreen "https://github.com/rachitkumar205/visionhubos/blob/main/src/ui/screens/menu.rs"
    click UIModule "https://github.com/rachitkumar205/visionhubos/blob/main/src/ui/mod.rs"
    click CargoToml "https://github.com/rachitkumar205/visionhubos/blob/main/Cargo.toml"
    click CargoConfig "https://github.com/rachitkumar205/visionhubos/blob/main/.cargo/config.toml"
    click BuildScript "https://github.com/rachitkumar205/visionhubos/blob/main/build.rs"
    click RustToolchain "https://github.com/rachitkumar205/visionhubos/blob/main/rust-toolchain.toml"
    click Sdkconfig "https://github.com/rachitkumar205/visionhubos/blob/main/sdkconfig.defaults"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef drivers fill:#87CEEB,stroke:#000,stroke-width:1px;
    classDef kernel fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef ui fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef build fill:#DDA0DD,stroke:#000,stroke-width:1px;
```
