# actuallymentor/battery architecture

> Architecture diagram of the GitHub repository actuallymentor/battery, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/actuallymentor/battery
- Repository: https://github.com/actuallymentor/battery

## Overview

Battery is a macOS menu-bar app and command-line utility for controlling Apple Silicon MacBook charging. The main workflow is tray interaction → app-side battery control → installed CLI → battery/SMC operations; the CLI also supports persistent percentage maintenance, manual charging controls, calibration, and installation management. The GUI initializes and maintains the CLI installation, reads battery status, and reflects status in its tray menu and icon. Relationships for the CLI’s internal behavior are based on README documentation because its implementation was not sampled; the graph does not infer unshown command-level details.

Main entry points: [`app/modules/interface.js`](https://github.com/actuallymentor/battery/blob/main/app/modules/interface.js) (Tray interface), [`app/modules/battery.js`](https://github.com/actuallymentor/battery/blob/main/app/modules/battery.js) (Battery manager), [`battery.sh`](https://github.com/actuallymentor/battery/blob/main/battery.sh) (Battery CLI), [`app/modules/settings.js`](https://github.com/actuallymentor/battery/blob/main/app/modules/settings.js) (Force-discharge settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["Menu-bar app"]
  node_tray["Tray interface<br/>[interface.js]"]
  node_app_start["App startup<br/>[main.js]"]
  node_theme["Tray icon theme<br/>[theme.js]"]
end

subgraph group_control["Battery control"]
  node_battery_mgr["Battery manager<br/>[battery.js]"]
  node_cli["Battery CLI<br/>[battery.sh]"]
  node_smc["SMC tool"]
  node_battery_state["Mac battery"]
end

subgraph group_support["App support"]
  node_settings["Force-discharge settings<br/>[settings.js]"]
  node_settings_store[("Settings store<br/>[settings.js]")]
  node_helpers["Dialogs and logging<br/>[helpers.js]"]
  node_electron_updates["GUI updater<br/>[main.js]"]
end

node_user(("Mac user"))
node_update_service["Update services"]

node_user -->|"uses"| node_tray
node_app_start -->|"starts"| node_tray
node_tray -->|"controls and reads"| node_battery_mgr
node_tray -->|"renders icon"| node_theme
node_tray -->|"reads and updates"| node_settings
node_battery_mgr -->|"runs commands"| node_cli
node_battery_mgr -->|"reads setting"| node_settings
node_cli -->|"uses tool"| node_smc
node_cli -->|"controls battery"| node_battery_state
node_settings -->|"reads and writes"| node_settings_store
node_app_start -->|"configures"| node_electron_updates
node_electron_updates -.->|"checks updates"| node_update_service
node_battery_mgr -->|"uses dialogs and logs"| node_helpers
node_tray -->|"logs errors"| node_helpers

click node_tray "https://github.com/actuallymentor/battery/blob/main/app/modules/interface.js"
click node_app_start "https://github.com/actuallymentor/battery/blob/main/app/main.js"
click node_battery_mgr "https://github.com/actuallymentor/battery/blob/main/app/modules/battery.js"
click node_cli "https://github.com/actuallymentor/battery/blob/main/battery.sh"
click node_smc "https://github.com/actuallymentor/battery/blob/main/dist/smc"
click node_settings "https://github.com/actuallymentor/battery/blob/main/app/modules/settings.js"
click node_settings_store "https://github.com/actuallymentor/battery/blob/main/app/modules/settings.js"
click node_theme "https://github.com/actuallymentor/battery/blob/main/app/modules/theme.js"
click node_helpers "https://github.com/actuallymentor/battery/blob/main/app/modules/helpers.js"
click node_electron_updates "https://github.com/actuallymentor/battery/blob/main/app/main.js"

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_tray,node_app_start,node_theme,node_user toneBlue
class node_battery_mgr,node_cli,node_smc,node_battery_state toneAmber
class node_settings,node_settings_store,node_helpers,node_electron_updates toneMint
class node_update_service toneIndigo
```

## Components

### Menu-bar app

- [Tray interface](https://github.com/actuallymentor/battery/blob/main/app/modules/interface.js): `app/modules/interface.js`
- [App startup](https://github.com/actuallymentor/battery/blob/main/app/main.js): `app/main.js`
- [Tray icon theme](https://github.com/actuallymentor/battery/blob/main/app/modules/theme.js): `app/modules/theme.js`

### Battery control

- [Battery manager](https://github.com/actuallymentor/battery/blob/main/app/modules/battery.js): `app/modules/battery.js`
- [Battery CLI](https://github.com/actuallymentor/battery/blob/main/battery.sh): `battery.sh`
- [SMC tool](https://github.com/actuallymentor/battery/blob/main/dist/smc): `dist/smc`
- **Mac battery**

### App support

- [Force-discharge settings](https://github.com/actuallymentor/battery/blob/main/app/modules/settings.js): `app/modules/settings.js`
- [Settings store](https://github.com/actuallymentor/battery/blob/main/app/modules/settings.js): `app/modules/settings.js`
- [Dialogs and logging](https://github.com/actuallymentor/battery/blob/main/app/modules/helpers.js): `app/modules/helpers.js`
- [GUI updater](https://github.com/actuallymentor/battery/blob/main/app/main.js): `app/main.js`

### Other components

- **Mac user**
- **Update services**

## Connections

- Mac user → Tray interface: uses (evidence: `README.md`)
- App startup → Tray interface: starts (evidence: `app/main.js`)
- Tray interface → Battery manager: controls and reads (evidence: `app/modules/interface.js`)
- Tray interface → Tray icon theme: renders icon (evidence: `app/modules/interface.js`)
- Tray interface → Force-discharge settings: reads and updates (evidence: `app/modules/interface.js`)
- Battery manager → Battery CLI: runs commands (evidence: `app/modules/battery.js`)
- Battery manager → Force-discharge settings: reads setting (evidence: `app/modules/battery.js`)
- Battery CLI → SMC tool: uses tool (evidence: `README.md`)
- Battery CLI → Mac battery: controls battery (evidence: `README.md`)
- Force-discharge settings → Settings store: reads and writes (evidence: `app/modules/settings.js`)
- App startup → GUI updater: configures (evidence: `app/main.js`)
- GUI updater → Update services: checks updates (evidence: `README.md`)
- Battery manager → Dialogs and logging: uses dialogs and logs (evidence: `app/modules/battery.js`)
- Tray interface → Dialogs and logging: logs errors (evidence: `app/modules/interface.js`)
