# calcprogrammer1/openrgb architecture

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

- Interactive diagram: https://gitdiagram.com/calcprogrammer1/openrgb
- Repository: https://github.com/calcprogrammer1/openrgb

## Overview

- User Interface Layer: Represent two main UI components—a graphical interface (built with Qt, as seen in the “qt” directory containing forms, dialogs, and various UI pages) and a command‑line interface (see cli.cpp and cli.h). Show that these functions provide interaction with the end user.
- Core Application and Control Logic: Include modules managing device profiles, settings, and resource management (for example, files like ProfileManager.cpp/h, SettingsManager.cpp/h, ResourceManager.cpp/h, LogManager.cpp/h, and PluginManager.cpp/h). These components form the core engine that governs state, logging, profile persistence, and plugin orchestration.
- Device Detection and Abstraction: Demonstrate the detection, communication, and control aspects. This covers:
– Common device detection and protocol interfaces are abstracted in files such as Detector.h, DeviceDetector.h, and the “RGBController” folder. Indicate that these modules provide a hardware abstraction layer.
– USB and SMBus communication (see SPDAccessor, USBAccess documentation, i2c_smbus folder, and related dependencies).
– Tools and libraries for low‑level access such as libusb, hidapi, winring0 (found in the “dependencies” folder) that abstract the raw communication links.
- Network Module: Incorporate the network components (NetworkClient.cpp/h, NetworkServer.cpp/h, and net_port) that allow multiple instances to connect and synchronize, and also for supporting the OpenRGB SDK.
- Plugin/SKD Integration: Represent the plugin interface (OpenRGBPluginInterface.h, PluginManager.cpp/h) that enables external software integrations and supports third‑party client apps (documented in the README under “OpenRGB SDK” and “OpenRGB Plugins”).
- Cross‑platform and Utility Modules: Include components for suspend/resume (found in the SuspendResume folder), configuration management (SettingsManager), logging (LogManager), string utilities (StringUtils), and others that wrap platform‑specific implementations.

##### Relationships and Interactions
- A communication flow between the Network Interface and the core. For instance, the NetworkServer and NetworkClient facilitate remote control or synchronization between instances, while the PluginManager provides extensibility.
- Hardware Access subsystems to the Device Controllers, showing that controllers rely on lower‑level libraries (such as those in dependencies and in the i2c_smbus or SPDAccessor folders) for direct hardware communication.
- Optionally, layer “Utilities” (ResourceManager, LogManager, SuspendResume) as supporting components providing common services across the application.

##### Architectural Patterns and Design Principles
- Cross‑platform Abstractions: Mark components such as SuspendResume or platform‑dependent device access code (mac, linux, Windows specific source files) to show adaptability across operating systems.

##### Technologies and Frameworks
- C++ (the language tying the entire project)
- Qt for the graphical user interface (directories and files in the “qt” folder)
- libusb, hidapi, and other hardware access libraries (listed in “dependencies”)
- Custom SDK for network communication and remote control (NetworkClient/Server, OpenRGBPluginInterface)
- Reverse‐engineered protocols implemented in individual controller modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        GUI["GUI (Qt)"]:::gui
        CLI["CLI"]:::gui
    end

    %% Core Business Logic Layer
    subgraph "Core Business Logic"
        PManager["Profile Manager"]:::core
        SManager["Settings Manager"]:::core
        PlManager["Plugin Manager"]:::core
        RManager["Resource Manager"]:::core
        LManager["Log Manager"]:::core
    end

    %% Device Abstraction Layer
    subgraph "Device Abstraction Layer"
        DInterface["Detector & RGB Interface"]:::hardware
        DControllers["Device Controllers"]:::hardware
    end

    %% Hardware Access Layer
    subgraph "Hardware Access Layer"
        SPD["SPDAccessor"]:::access
        I2C["i2c_smbus"]:::access
        DEP["Dependencies"]:::access
    end

    %% Network & Plugin Integration Layer
    subgraph "Network & Plugin Integration Layer"
        NClient["Network Client"]:::network
        NServer["Network Server"]:::network
        NPort["Network Port"]:::network
        PluginSDK["Plugin/SDK Interface"]:::network
    end

    %% Utility & Cross-platform Layer
    subgraph "Utility & Cross-platform"
        Suspend["Suspend/Resume"]:::utility
        StringUtil["String Utilities"]:::utility
    end

    %% ------------------ Connections ------------------

    %% Presentation to Core Business Logic
    GUI -->|"userinput"| PManager
    CLI -->|"userinput"| PManager

    %% Core Business Logic interactions
    PManager -->|"manage-devices"| DInterface
    SManager -->|"update-settings"| DInterface
    RManager -->|"resource-request"| DInterface
    LManager -->|"log-action"| DInterface
    PlManager -->|"invoke-plugin"| PluginSDK

    %% Feedback from Device Abstraction to UI
    DInterface -->|"status-update"| GUI

    %% Internal Device Abstraction flow
    DInterface -->|"control-devices"| DControllers

    %% Device Controllers accessing Hardware Access modules
    DControllers -->|"communicates"| SPD
    DControllers -->|"communicates"| I2C
    DControllers -->|"communicates"| DEP

    %% Core Business Logic to Network interactions
    PlManager -->|"sync"| NClient
    SManager -->|"notify"| NServer

    %% Network components interaction
    NClient -->|"network-call"| NServer

    %% Plugin/SDK interaction back to Core
    PluginSDK -->|"load-plugin"| PlManager

    %% Core managers utilizing Utility modules
    PManager ---|"utilize"| Suspend
    SManager ---|"utilize"| StringUtil
    RManager ---|"utilize"| Suspend

    %% ------------------ Click Events ------------------
    click GUI "https://github.com/calcprogrammer1/openrgb/tree/master/qt/"
    click CLI "https://github.com/calcprogrammer1/openrgb/blob/master/cli.cpp"
    click PManager "https://github.com/calcprogrammer1/openrgb/tree/master/ProfileManager.cpp/h"
    click SManager "https://github.com/calcprogrammer1/openrgb/tree/master/SettingsManager.cpp/h"
    click PlManager "https://github.com/calcprogrammer1/openrgb/tree/master/PluginManager.cpp/h"
    click RManager "https://github.com/calcprogrammer1/openrgb/tree/master/ResourceManager.cpp/h"
    click LManager "https://github.com/calcprogrammer1/openrgb/tree/master/LogManager.cpp/h"
    click DInterface "https://github.com/calcprogrammer1/openrgb/blob/master/Detector.h"
    click DControllers "https://github.com/calcprogrammer1/openrgb/tree/master/Controllers/"
    click SPD "https://github.com/calcprogrammer1/openrgb/tree/master/SPDAccessor/"
    click I2C "https://github.com/calcprogrammer1/openrgb/tree/master/i2c_smbus/"
    click DEP "https://github.com/calcprogrammer1/openrgb/tree/master/dependencies/"
    click NClient "https://github.com/calcprogrammer1/openrgb/tree/master/NetworkClient.cpp/h"
    click NServer "https://github.com/calcprogrammer1/openrgb/tree/master/NetworkServer.cpp/h"
    click NPort "https://github.com/calcprogrammer1/openrgb/tree/master/net_port/"
    click PluginSDK "https://github.com/calcprogrammer1/openrgb/blob/master/OpenRGBPluginInterface.h"
    click Suspend "https://github.com/calcprogrammer1/openrgb/tree/master/SuspendResume/"
    click StringUtil "https://github.com/calcprogrammer1/openrgb/tree/master/StringUtils.cpp/h"

    %% ------------------ Styles ------------------
    classDef gui fill:#b3cde0,stroke:#1f78b4,stroke-width:2px;
    classDef core fill:#c7e9c0,stroke:#2ca02c,stroke-width:2px;
    classDef hardware fill:#fdd49e,stroke:#ff7f00,stroke-width:2px;
    classDef access fill:#fdae6b,stroke:#d95f02,stroke-width:2px;
    classDef network fill:#fbb4ae,stroke:#e31a1c,stroke-width:2px;
    classDef utility fill:#d9d9d9,stroke:#636363,stroke-width:2px;
```
