# d-brox/cosmic-ext-applet-system-monitor architecture

> Architecture diagram of the GitHub repository d-brox/cosmic-ext-applet-system-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/d-brox/cosmic-ext-applet-system-monitor
- Repository: https://github.com/d-brox/cosmic-ext-applet-system-monitor

## Overview

##### Main Components
- Application Entry Point: Represented by src/main.rs, which orchestrates the startup, configuration loading, and integration of all submodules.
- Applet/UI Component: Captured in src/applet.rs – this module likely handles interactions with the desktop environment (COSMIC DE) and the applet’s life-cycle.
- System Monitoring Module: Found in src/sysmon (with sysmon/mod.rs and sysmon/chart.rs). This component gathers system metrics (CPU, memory, network, etc.) and prepares data for charting.
- Configuration Module: Found in src/config.rs. This module loads and parses configuration files (such as the charts configuration file in the user’s ~/.config folder) and sets up sampling intervals, chart sizes, and theming.
- Localization Module: Found in src/localization.rs along with the i18n directory containing the language files. This manages multi-language strings and internationalization, ensuring the UI displays the correct text.

##### Architectural Patterns/Design Principles
- Modular Design: The code is cleanly separated into modules (applet, config, localization, sysmon) to isolate responsibilities.
- MVC-like Interaction: Although not strictly MVC, the separation between data collection (model: sysmon) and its presentation (applet) is clear.
- Configuration-Driven Behavior: The applet is highly configurable, with external configs and theming that are parsed and injected to control metrics sampling and chart appearance.
- Internationalization: With a dedicated localization module and i18n resource files, the app supports multiple languages.

##### Technologies, Frameworks, and External Dependencies
- Rust as the primary language along with Cargo for dependency management.
- Integration with system libraries (libfontconfig-dev and libxkbcommon-dev) for rendering and input handling.
- Usage of “just” as a build and packaging tool.
- The applet might be using libraries like wgpu (with note on potential issues) and possibly plotters for charting, based on the acknowledgement of similar projects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    M["Application Entry Point (main.rs)"]:::core
    A["Applet/UI Component (applet.rs)"]:::ui
    C["Configuration Module (config.rs)"]:::support
    L["Localization Module (localization.rs + i18n)"]:::support
    S["System Monitoring Module (sysmon)"]:::monitor

    subgraph "System Monitoring Internal"
        direction TB
        SM["Sysmon Core (mod.rs)"]:::monitor
        SC["Sysmon Chart (chart.rs)"]:::monitor
        SM -->|"delegates"| SC
    end

    CT["Color and Theming (color.rs)"]:::theming

    SC -->|"uses"| CT

    M -->|"initializes"| A
    M -->|"loads"| C
    M -->|"loads"| L
    M -->|"initializes"| S

    C -->|"configures"| A
    C -->|"configures"| S
    L -->|"provides_text"| A
    S -->|"sends_data_to"| A

    click M "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/main.rs"
    click A "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/applet.rs"
    click C "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/config.rs"
    click L "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/localization.rs"
    click L "https://github.com/d-brox/cosmic-ext-applet-system-monitor/tree/master/i18n/"
    click S "https://github.com/d-brox/cosmic-ext-applet-system-monitor/tree/master/src/sysmon"
    click SM "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/sysmon/mod.rs"
    click SC "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/sysmon/chart.rs"
    click CT "https://github.com/d-brox/cosmic-ext-applet-system-monitor/blob/master/src/color.rs"

    classDef core fill:#a0c4ff,stroke:#000,stroke-width:2px;
    classDef ui fill:#bde0fe,stroke:#000,stroke-width:2px;
    classDef support fill:#ffc8dd,stroke:#000,stroke-width:2px;
    classDef monitor fill:#caffbf,stroke:#000,stroke-width:2px;
    classDef theming fill:#ffadad,stroke:#000,stroke-width:2px;
```
