# acemythos/cosmic-power-monitor architecture

> Architecture diagram of the GitHub repository acemythos/cosmic-power-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acemythos/cosmic-power-monitor
- Repository: https://github.com/acemythos/cosmic-power-monitor

## Overview

This COSMIC desktop applet polls Linux power-supply data, combines readings into battery status and estimates, then presents configurable panel text and detailed popup information. The main workflow is supported by the excerpts; UI behavior not shown in full is represented only where the README or sampled code supports it.

Main entry points: [`src/app.rs`](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs) (Monitor controller), [`src/battery.rs`](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/battery.rs) (Battery polling), [`src/main.rs`](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/main.rs) (Applet entry), [`src/config.rs`](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/config.rs) (Display settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Applet runtime"]
  node_entry["Applet entry<br/>[main.rs]"]
  node_controller["Monitor controller<br/>[app.rs]"]
end

subgraph group_battery["Battery readings"]
  node_battery_logic["Battery polling<br/>[battery.rs]"]
  node_sysfs["Power-supply sysfs"]
end

subgraph group_presentation["Display and settings"]
  node_panel_view["Panel display<br/>[app.rs]"]
  node_popup_view["Detail popup<br/>[app.rs]"]
  node_settings["Display settings<br/>[config.rs]"]
end

node_user(("Desktop user"))
node_cosmic["COSMIC panel"]

node_entry -->|"runs applet"| node_controller
node_user -->|"interacts"| node_controller
node_controller -->|"polls batteries"| node_battery_logic
node_battery_logic -->|"reads readings"| node_sysfs
node_controller -->|"renders panel"| node_panel_view
node_controller -->|"renders details"| node_popup_view
node_controller -->|"loads and saves"| node_settings
node_panel_view -->|"shows label"| node_cosmic
node_popup_view -->|"shows details"| node_cosmic

click node_entry "https://github.com/acemythos/cosmic-power-monitor/blob/main/src/main.rs"
click node_controller "https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs"
click node_battery_logic "https://github.com/acemythos/cosmic-power-monitor/blob/main/src/battery.rs"
click node_panel_view "https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs"
click node_popup_view "https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs"
click node_settings "https://github.com/acemythos/cosmic-power-monitor/blob/main/src/config.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_controller,node_user toneBlue
class node_battery_logic,node_sysfs toneAmber
class node_panel_view,node_popup_view,node_settings toneMint
class node_cosmic toneIndigo
```

## Components

### Applet runtime

- [Applet entry](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/main.rs): `src/main.rs`
- [Monitor controller](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs): `src/app.rs`

### Battery readings

- [Battery polling](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/battery.rs): `src/battery.rs`
- **Power-supply sysfs**

### Display and settings

- [Panel display](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs): `src/app.rs`
- [Detail popup](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/app.rs): `src/app.rs`
- [Display settings](https://github.com/acemythos/cosmic-power-monitor/blob/main/src/config.rs): `src/config.rs`

### Other components

- **Desktop user**
- **COSMIC panel**

## Connections

- Applet entry → Monitor controller: runs applet (evidence: `src/main.rs`)
- Desktop user → Monitor controller: interacts (evidence: `src/app.rs`)
- Monitor controller → Battery polling: polls batteries (evidence: `src/app.rs`)
- Battery polling → Power-supply sysfs: reads readings (evidence: `src/battery.rs`)
- Monitor controller → Panel display: renders panel (evidence: `README.md`)
- Monitor controller → Detail popup: renders details (evidence: `README.md`)
- Monitor controller → Display settings: loads and saves (evidence: `src/app.rs`)
- Panel display → COSMIC panel: shows label (evidence: `README.md`)
- Detail popup → COSMIC panel: shows details (evidence: `README.md`)
