# takimoysha/randy architecture

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

- Interactive diagram: https://gitdiagram.com/takimoysha/randy
- Repository: https://github.com/takimoysha/randy

## Overview

##### Main Components
- Application Core – Represented by the main executable (src/main.rs) which initializes and orchestrates the application.
- Configuration Module – Found in src/config.rs and supported by various configuration files under the config/ folder (with both Toml and YAML formats). Indicate that this component handles the reading/parsing of application settings (such as UI parameters, module preferences, etc.).
- System Data Modules – Located in src/deets/ and possibly integrated through the configurable modules described in the README (such as system, cpus, mem_consumers, filesystem, net, battery, etc.). This part of the architecture is responsible for gathering, processing, and forwarding system metrics.
- UI Subsystem – Contained in the src/ui/ directory (with helpers, styles, and widgets in subdirectories). This is where GTK4 is heavily used to build the interface. The system’s styling (via resources/app.css) and custom widget implementations (e.g., in src/ui/widgets/) must be clearly depicted.
- Benchmark Suite – Shown by the bench/ folder; not part of the runtime architecture but important for performance evaluation. You may add this as a testing or performance evaluation component.
- Packaging & Deployment – The packaging/ directory contains scripts and Dockerfiles for Fedora, Flatpak configs, and Gentoo packaging scripts. They represent how the application is built and deployed in different environments.
- Auxiliary Scripts – The scripts/ directory holds build scripts and additional helper scripts for testing or processing data (e.g., rss_proc_missing.sh).

##### Relationships and Data/Control Flow
- The Application Core (main.rs) initializes the configuration module and then sets up the UI subsystem.
- The Configuration Module supplies parameters to both the UI Subsystem (for styling, layout, and behavior) and the Data Modules (to determine what metrics to display and customizations for refresh rates, etc.).
- Benchmark tests interact with the same underlying logic (for example, the system data modules) to gauge performance, but these components are isolated in their own “bench” section.
- Packaging and auxiliary scripts support the build/deployment process, and they are connected to the Application Core in an overall deployment pipeline layer.

##### Architectural Patterns and Design Principles
- Modular Design – Notice how the code is separated into distinct directories (deets, ui, config) indicating an emphasis on modularity. This supports configurable modules and the separation of concerns (data vs. UI).
- Config-driven Customization – The heavy use of configuration files (TOML, YAML, CSS files) emphasizes flexibility in runtime behavior and appearance.
- Separation of Build, Deployment, and Testing – Packaging scripts and benchmark folders demonstrate a separation between development (logic and UI) and operations (packaging, deployment, performance testing).

##### Technologies and Frameworks
- Rust – The entire application is built in Rust (evident from Cargo.toml, src/main.rs, etc.).
- GTK4 – The UI is based on GTK4. Distinguish UI components as “GTK4 Widgets.”
- CSS – Used for styling (resources/app.css) and customization of the UI.
- Configuration Formats – TOML and YAML play key roles in application settings.
- Benchmark Tools – Included in the bench/ folder, which might use Rust’s benchmarking facilities.

##### Practical Steps
– Application Core (src/main.rs).
– Configuration Management (src/config.rs + config/ files).
– Data Acquisition Modules (src/deets/).
– UI Layer (src/ui/ and resources/app.css).
– Additional Testing/Benchmarking (bench/ folder).
– Deployment/Packaging (packaging/ and scripts/ folders).
c. That the UI layer utilizes GTK4 and custom CSS for styling.
d. Notations about the modular design (supporting configurable modules) and the planned improvements in the roadmap (such as using gio::Settings and XDG config).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application
    A("Application Core"):::core

    %% Configuration & Data Modules
    subgraph "Configuration & Data Modules"
        C1("Configuration Module"):::config
        C2("Configuration Files"):::config
        D1("System Data Modules"):::config
        D2("Data Module _deets.rs"):::config
        D3("Data Module mod.rs"):::config
    end

    %% UI Subsystem
    subgraph "UI Subsystem"
        U1("UI Core"):::ui
        U2("UI Helpers"):::ui
        U3("UI Style"):::ui
        U4("UI Widgets"):::ui
        U5("App CSS"):::ui
    end

    %% Benchmark Suite
    subgraph "Benchmark Suite"
        B1("Bench Folder"):::auxiliary
        B2("Bench Benches"):::auxiliary
        B3("Bench Lib"):::auxiliary
    end

    %% Packaging & Deployment
    subgraph "Packaging & Deployment"
        P1("Packaging Scripts"):::auxiliary
        P2("Auxiliary Scripts"):::auxiliary
    end

    %% Connections
    A -->|"config_init"| C1
    A -->|"ui_init"| U1
    C1 -->|"config_params"| U1
    C1 -->|"config_params"| D1
    C1 -->|"reads"| C2
    U1 -->|"data_query"| D1
    D1 -->|"extends"| D2
    D1 -->|"extends"| D3
    B1 -->|"bench_test"| D1
    A -->|"build_deploy"| P1
    A -->|"build_support"| P2

    %% Internal UI connections
    U1 --- U2
    U1 --- U3
    U1 --- U4
    U3 --- U5

    %% Click Events
    click A "https://github.com/takimoysha/randy/blob/main/src/main.rs"
    click C1 "https://github.com/takimoysha/randy/blob/main/src/config.rs"
    click C2 "https://github.com/takimoysha/randy/tree/main/config/"
    click D1 "https://github.com/takimoysha/randy/tree/main/src/deets/"
    click D2 "https://github.com/takimoysha/randy/blob/main/src/deets/_deets.rs"
    click D3 "https://github.com/takimoysha/randy/blob/main/src/deets/mod.rs"
    click U1 "https://github.com/takimoysha/randy/tree/main/src/ui/"
    click U2 "https://github.com/takimoysha/randy/blob/main/src/ui/helpers.rs"
    click U3 "https://github.com/takimoysha/randy/blob/main/src/ui/style.rs"
    click U4 "https://github.com/takimoysha/randy/tree/main/src/ui/widgets/"
    click U5 "https://github.com/takimoysha/randy/blob/main/resources/app.css"
    click B1 "https://github.com/takimoysha/randy/tree/main/bench/"
    click B2 "https://github.com/takimoysha/randy/tree/main/bench/benches/"
    click B3 "https://github.com/takimoysha/randy/blob/main/bench/src/lib.rs"
    click P1 "https://github.com/takimoysha/randy/tree/main/packaging/"
    click P2 "https://github.com/takimoysha/randy/tree/main/scripts/"

    %% Styles
    classDef core fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef config fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef ui fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef auxiliary fill:#d3d3d3,stroke:#000,stroke-dasharray:5,stroke-width:2px;
```
