# nokyan/resources architecture

> Architecture diagram of the GitHub repository nokyan/resources, 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/nokyan/resources
- Repository: https://github.com/nokyan/resources

## Overview

##### Main Components
- User Interface (UI) Layer:
- Located largely under the src/ui directory (with pages, dialogs, widgets, and the main window definition in src/ui/window.rs).
- Uses GTK 4 and libadwaita (as referenced in the README) for rendering the GUIs.
- Application Logic & Utilities:
- Core application logic and resource handling occur in several layers:
– The primary entry point in src/application.rs and src/lib.rs.
– Submodules in src/utils/ for CPU, memory, network, GPU, NPU, battery, etc.
- Data Processing/Library Component:
- The lib/process_data directory encapsulates logic for processing resource data, and can be treated as a separate module or micro-library.
- Data & Resources:
- Build & Deployment Modules:
- Meson build files (meson.build, meson_options.txt) that define configuration.
- Cargo.toml and Cargo.lock for Rust dependency management.
- Flatpak build configuration under build-aux (including net.nokyan.Resources.Devel.json) and GitHub workflows for CI.

##### Relationships and Interactions
- The UI Layer communicates with the application logic to display current system metrics (CPU, memory, GPU, etc.) and to interact with user actions.
- The application logic gathers system status data using the utilities module (src/utils) and, when needed, performs operations like listing processes or terminating them.
- Data modules (in lib/process_data) provide underlying processing functions that are consumed by both the UI and utility functions.
- Build configurations (Meson and Flatpak files) encapsulate the dependencies and deployment settings, ensuring the project builds correctly in multiple environments.

##### Architectural Patterns / Design Principles
- Modular Separation: The application divides responsibilities clearly by splitting UI, utilities, and data processing into their own subdirectories.
- Layered Structure: Presentation (UI), business logic (core application and utilities), and infrastructure (build scripts, assets) are defined in different layers.
- Extensibility: The clear separation of concerns (e.g., distinct modules for different resource types and UI components) facilitates easier maintenance and potential future expansions (e.g., adding new resource monitors).

##### Technologies and Frameworks
- Rust language for backend logic.
- GTK 4 and libadwaita for the front-end graphical interface.
- Meson and Ninja for native builds, along with Cargo for dependency management.
- Flatpak for distribution, making sure to reference the specific build configurations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI["User Interface (GTK4+libadwaita)"]:::ui
        Win["Main Window"]:::ui
    end

    %% Application Core Layer
    subgraph "Application Core"
        Core["Core Application"]:::core
        App["Entry Point (src/application.rs)"]:::core
        Lib["Library (src/lib.rs)"]:::core
    end

    %% Utilities Layer
    subgraph "Utilities & System Resources"
        Utils["Resource Utilities (CPU,Memory,Network,GPU,NPU,Battery,Process)"]:::utils
    end

    %% Data Processing Library
    subgraph "Data Processing Library"
        DataProc["Data Processing Module"]:::data
        DataLib["Library (lib/process_data/src/lib.rs)"]:::data
    end

    %% Data & Resources
    subgraph "Data & Resources"
        Assets["Icons, Templates, CSS, Resources"]:::assets
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        Build["Meson & Cargo Configurations"]:::build
        Flatpak["Flatpak & CI Configurations"]:::build
    end

    %% Relationships
    UI -->|"triggers"| Core
    Win -->|"partOf"| UI
    Core -->|"callsUtilities"| Utils
    Core -->|"usesDataProc"| DataProc
    Utils -->|"processesData"| DataProc
    UI -->|"rendersAssets"| Assets
    Build -->|"builds_Core"| Core
    Build -->|"builds_Utils"| Utils
    Build -->|"builds_DataProc"| DataProc
    Flatpak -->|"packages_Core"| Core
    Flatpak -->|"packages_UI"| UI

    %% Click Events
    click UI "https://github.com/nokyan/resources/tree/main/src/ui"
    click Win "https://github.com/nokyan/resources/blob/main/src/ui/window.rs"
    click App "https://github.com/nokyan/resources/blob/main/src/application.rs"
    click Lib "https://github.com/nokyan/resources/blob/main/src/lib.rs"
    click Utils "https://github.com/nokyan/resources/tree/main/src/utils"
    click DataProc "https://github.com/nokyan/resources/tree/main/lib/process_data"
    click DataLib "https://github.com/nokyan/resources/blob/main/lib/process_data/src/lib.rs"
    click Assets "https://github.com/nokyan/resources/tree/main/data"
    click Build "https://github.com/nokyan/resources/blob/main/meson.build"
    click Build "https://github.com/nokyan/resources/blob/main/Cargo.toml"
    click Build "https://github.com/nokyan/resources/blob/main/Cargo.lock"
    click Flatpak "https://github.com/nokyan/resources/tree/main/build-aux"
    click Flatpak "https://github.com/nokyan/resources/tree/main/.github/workflows"

    %% Styles
    classDef ui fill:#fce4ec,stroke:#d81b60,stroke-width:2px;
    classDef core fill:#e1f5fe,stroke:#0277bd,stroke-width:2px;
    classDef utils fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    classDef data fill:#fff3e0,stroke:#f57c00,stroke-width:2px;
    classDef assets fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
    classDef build fill:#ede7f6,stroke:#5e35b1,stroke-width:2px;
```
