# resistanceto/miniwatts architecture

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

- Interactive diagram: https://gitdiagram.com/resistanceto/miniwatts
- Repository: https://github.com/resistanceto/miniwatts

## Overview

MiniWatts is an on-device iPhone charging and battery monitor. Its main workflow samples private power and thermal sensors, builds a live power snapshot, and presents charger-to-cell power, heat, adapter, and cable details. PowerMonitor also tracks charge sessions and persists their history. The app exposes readings through its screens, a floating Picture-in-Picture meter, widgets, a charging Live Activity, and Shortcuts. The graph follows documented capabilities and sampled ownership; some unsampled subsystem wiring is intentionally left out.

Main entry points: [`MiniWatts/Core/PowerMonitor.swift`](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/PowerMonitor.swift) (Power monitor), [`MiniWatts/Core/Sensors/SensorProbe.swift`](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/SensorProbe.swift) (Sensor probe), [`MiniWatts/Features/RootView.swift`](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/RootView.swift) (Root coordinator), [`MiniWatts/Floating/FloatingMeterController.swift`](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Floating/FloatingMeterController.swift) (Floating meter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensing["Sensor acquisition"]
  node_probe["Sensor probe<br/>[SensorProbe.swift]"]
  node_catalog["Sensor catalog"]
  node_hid["HID sensors<br/>[HIDSensors.swift]"]
  node_accessory["Accessory probe"]
  node_batterybridge["Battery Center bridge"]
  node_iokit["IOKit battery<br/>[IOKitBattery.swift]"]
  node_thermal["Thermal monitor"]
end

subgraph group_monitoring["Monitoring and history"]
  node_monitor["Power monitor<br/>[PowerMonitor.swift]"]
  node_snapshot["Power snapshot"]
  node_energy["Energy accumulator"]
  node_resistance["Path resistance"]
  node_sessions[("Session model and store")]
end

subgraph group_app["App experience"]
  node_appentry["App entry<br/>[MiniWattsApp.swift]"]
  node_root["Root coordinator<br/>[RootView.swift]"]
  node_dashboard["Power dashboard"]
  node_adapterview["Adapter analysis<br/>[AdapterView.swift]"]
  node_thermalview["Thermal view<br/>[ThermalView.swift]"]
  node_devices["Device inventory<br/>[DevicesView.swift]"]
  node_history["Session history<br/>[SessionsView.swift]"]
  node_settings["Settings and debug<br/>[SettingsView.swift]"]
end

subgraph group_surfaces["Glance surfaces"]
  node_floating["Floating meter"]
  node_floatingdata["Floating telemetry"]
  node_publisher["Widget publisher"]
  node_reading["Shared charge reading"]
  node_widget["Battery widget"]
  node_widgetprobe["Widget reading probe<br/>[ReadingProbe.swift]"]
  node_activitycontroller["Live Activity controller"]
  node_activityview["Live Activity surface"]
  node_intent["Get reading intent"]
end

node_user(("iPhone user"))
node_iossensors{{"iOS sensor APIs"}}
node_widgetkit{{"WidgetKit"}}
node_activitykit{{"ActivityKit"}}
node_pip{{"Picture in Picture"}}

node_user -->|"opens"| node_appentry
node_appentry -->|"shows"| node_root
node_root -->|"starts and ticks"| node_monitor
node_monitor -->|"reads sensors"| node_probe
node_monitor -->|"updates"| node_thermal
node_probe -->|"consults"| node_catalog
node_probe -->|"reads"| node_hid
node_probe -->|"probes"| node_accessory
node_probe -->|"queries"| node_batterybridge
node_probe -->|"reads"| node_iokit
node_probe -->|"accesses"| node_iossensors
node_probe -->|"produces"| node_snapshot
node_monitor -->|"publishes"| node_snapshot
node_monitor -->|"accumulates"| node_energy
node_monitor -->|"fits resistance"| node_resistance
node_monitor -->|"records and loads"| node_sessions
node_dashboard -->|"reads"| node_monitor
node_adapterview -->|"reads"| node_monitor
node_thermalview -->|"reads"| node_monitor
node_devices -->|"requests inventory"| node_monitor
node_history -->|"reads history"| node_monitor
node_settings -->|"configures"| node_monitor
node_settings -->|"starts or stops"| node_floating
node_root -->|"syncs readings"| node_activitycontroller
node_activitycontroller -->|"updates activity"| node_activitykit
node_activityview -->|"renders activity"| node_activitykit
node_root -->|"publishes readings"| node_publisher
node_publisher -->|"creates"| node_reading
node_publisher -->|"reloads timelines"| node_widgetkit
node_widget -->|"requests reading"| node_widgetprobe
node_widgetprobe -->|"reads sensors"| node_iossensors
node_widget -->|"provides timeline"| node_widgetkit
node_intent -->|"requests fresh read"| node_monitor
node_root -->|"renders snapshots"| node_floating
node_floating -->|"creates telemetry"| node_floatingdata
node_floating -->|"starts Picture in Picture"| node_pip

click node_appentry "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/MiniWattsApp.swift"
click node_root "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/RootView.swift"
click node_monitor "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/PowerMonitor.swift"
click node_probe "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/SensorProbe.swift"
click node_catalog "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/SensorCatalog.swift"
click node_hid "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/HIDSensors.swift"
click node_accessory "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/AccessoryProbe.swift"
click node_batterybridge "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/BatteryCenterBridge.swift"
click node_iokit "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/IOKitBattery.swift"
click node_thermal "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/ThermalMonitor.swift"
click node_snapshot "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/PowerSnapshot.swift"
click node_energy "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/EnergyAccumulator.swift"
click node_resistance "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/PathResistance.swift"
click node_sessions "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/ChargeSession.swift"
click node_dashboard "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Dashboard/DashboardView.swift"
click node_adapterview "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Adapter/AdapterView.swift"
click node_thermalview "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Thermal/ThermalView.swift"
click node_devices "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Devices/DevicesView.swift"
click node_history "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Sessions/SessionsView.swift"
click node_settings "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Debug/SettingsView.swift"
click node_floating "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Floating/FloatingMeterController.swift"
click node_floatingdata "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Floating/FloatingMeterTelemetry.swift"
click node_publisher "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Widgets/WidgetPublisher.swift"
click node_reading "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Shared/ChargeReading.swift"
click node_widget "https://github.com/resistanceto/miniwatts/blob/master/Widget/BatteryWidget.swift"
click node_widgetprobe "https://github.com/resistanceto/miniwatts/blob/master/Widget/ReadingProbe.swift"
click node_activitycontroller "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Widgets/ChargeActivityController.swift"
click node_activityview "https://github.com/resistanceto/miniwatts/blob/master/Widget/ChargeLiveActivity.swift"
click node_intent "https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Shortcuts/GetReadingIntent.swift"

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_probe,node_catalog,node_hid,node_accessory,node_batterybridge,node_iokit,node_thermal,node_user toneBlue
class node_monitor,node_snapshot,node_energy,node_resistance,node_sessions toneAmber
class node_appentry,node_root,node_dashboard,node_adapterview,node_thermalview,node_devices,node_history,node_settings,node_iossensors toneMint
class node_floating,node_floatingdata,node_publisher,node_reading,node_widget,node_widgetprobe,node_activitycontroller,node_activityview,node_intent toneRose
class node_widgetkit,node_activitykit,node_pip toneIndigo
```

## Components

### Sensor acquisition

- [Sensor probe](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/SensorProbe.swift): `MiniWatts/Core/Sensors/SensorProbe.swift`
- [Sensor catalog](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/SensorCatalog.swift): `MiniWatts/Core/Sensors/SensorCatalog.swift`
- [HID sensors](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/HIDSensors.swift): `MiniWatts/Core/Sensors/HIDSensors.swift`
- [Accessory probe](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/AccessoryProbe.swift): `MiniWatts/Core/Sensors/AccessoryProbe.swift`
- [Battery Center bridge](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/BatteryCenterBridge.swift): `MiniWatts/Core/Sensors/BatteryCenterBridge.swift`
- [IOKit battery](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/IOKitBattery.swift): `MiniWatts/Core/Sensors/IOKitBattery.swift`
- [Thermal monitor](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Sensors/ThermalMonitor.swift): `MiniWatts/Core/Sensors/ThermalMonitor.swift`

### Monitoring and history

- [Power monitor](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/PowerMonitor.swift): `MiniWatts/Core/PowerMonitor.swift`
- [Power snapshot](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/PowerSnapshot.swift): `MiniWatts/Core/Model/PowerSnapshot.swift`
- [Energy accumulator](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/EnergyAccumulator.swift): `MiniWatts/Core/Model/EnergyAccumulator.swift`
- [Path resistance](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/PathResistance.swift): `MiniWatts/Core/Model/PathResistance.swift`
- [Session model and store](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Core/Model/ChargeSession.swift): `MiniWatts/Core/Model/ChargeSession.swift`

### App experience

- [App entry](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/MiniWattsApp.swift): `MiniWatts/MiniWattsApp.swift`
- [Root coordinator](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/RootView.swift): `MiniWatts/Features/RootView.swift`
- [Power dashboard](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Dashboard/DashboardView.swift): `MiniWatts/Features/Dashboard/DashboardView.swift`
- [Adapter analysis](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Adapter/AdapterView.swift): `MiniWatts/Features/Adapter/AdapterView.swift`
- [Thermal view](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Thermal/ThermalView.swift): `MiniWatts/Features/Thermal/ThermalView.swift`
- [Device inventory](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Devices/DevicesView.swift): `MiniWatts/Features/Devices/DevicesView.swift`
- [Session history](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Sessions/SessionsView.swift): `MiniWatts/Features/Sessions/SessionsView.swift`
- [Settings and debug](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Features/Debug/SettingsView.swift): `MiniWatts/Features/Debug/SettingsView.swift`

### Glance surfaces

- [Floating meter](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Floating/FloatingMeterController.swift): `MiniWatts/Floating/FloatingMeterController.swift`
- [Floating telemetry](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Floating/FloatingMeterTelemetry.swift): `MiniWatts/Floating/FloatingMeterTelemetry.swift`
- [Widget publisher](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Widgets/WidgetPublisher.swift): `MiniWatts/Widgets/WidgetPublisher.swift`
- [Shared charge reading](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Shared/ChargeReading.swift): `MiniWatts/Shared/ChargeReading.swift`
- [Battery widget](https://github.com/resistanceto/miniwatts/blob/master/Widget/BatteryWidget.swift): `Widget/BatteryWidget.swift`
- [Widget reading probe](https://github.com/resistanceto/miniwatts/blob/master/Widget/ReadingProbe.swift): `Widget/ReadingProbe.swift`
- [Live Activity controller](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Widgets/ChargeActivityController.swift): `MiniWatts/Widgets/ChargeActivityController.swift`
- [Live Activity surface](https://github.com/resistanceto/miniwatts/blob/master/Widget/ChargeLiveActivity.swift): `Widget/ChargeLiveActivity.swift`
- [Get reading intent](https://github.com/resistanceto/miniwatts/blob/master/MiniWatts/Shortcuts/GetReadingIntent.swift): `MiniWatts/Shortcuts/GetReadingIntent.swift`

### Other components

- **iPhone user**
- **iOS sensor APIs**
- **WidgetKit**
- **ActivityKit**
- **Picture in Picture**

## Connections

- iPhone user → App entry: opens
- App entry → Root coordinator: shows
- Root coordinator → Power monitor: starts and ticks
- Power monitor → Sensor probe: reads sensors
- Power monitor → Thermal monitor: updates
- Sensor probe → Sensor catalog: consults
- Sensor probe → HID sensors: reads
- Sensor probe → Accessory probe: probes
- Sensor probe → Battery Center bridge: queries
- Sensor probe → IOKit battery: reads
- Sensor probe → iOS sensor APIs: accesses
- Sensor probe → Power snapshot: produces
- Power monitor → Power snapshot: publishes
- Power monitor → Energy accumulator: accumulates
- Power monitor → Path resistance: fits resistance
- Power monitor → Session model and store: records and loads
- Power dashboard → Power monitor: reads
- Adapter analysis → Power monitor: reads
- Thermal view → Power monitor: reads
- Device inventory → Power monitor: requests inventory
- Session history → Power monitor: reads history
- Settings and debug → Power monitor: configures
- Settings and debug → Floating meter: starts or stops
- Root coordinator → Live Activity controller: syncs readings
- Live Activity controller → ActivityKit: updates activity
- Live Activity surface → ActivityKit: renders activity
- Root coordinator → Widget publisher: publishes readings
- Widget publisher → Shared charge reading: creates
- Widget publisher → WidgetKit: reloads timelines
- Battery widget → Widget reading probe: requests reading
- Widget reading probe → iOS sensor APIs: reads sensors
- Battery widget → WidgetKit: provides timeline
- Get reading intent → Power monitor: requests fresh read
- Root coordinator → Floating meter: renders snapshots
- Floating meter → Floating telemetry: creates telemetry
- Floating meter → Picture in Picture: starts Picture in Picture
