# baihengrui/esp32c3_usb_meter_host architecture

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

- Interactive diagram: https://gitdiagram.com/baihengrui/esp32c3_usb_meter_host
- Repository: https://github.com/baihengrui/esp32c3_usb_meter_host

## Overview

ESP32-USB-METER Host is an Electron desktop application for monitoring and controlling an ESP32-C3 USB meter. The primary workflow connects to a serial device, sends commands, and displays incoming measurements and live charts; users can also export data and logs. Separate workflows update or erase device firmware and update the application from GitHub Releases. The graph follows the documented capabilities and sampled IPC/serial/firmware code; some UI and offline-data wiring is only documented, so uncertain links are omitted.

Main entry points: [`main.js`](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js) (Main process), [`preload.js`](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/preload.js) (IPC bridge), [`renderer.js`](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/renderer.js) (Meter controls), [`firmware-flash.js`](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/firmware-flash.js) (Flash and erase)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop shell"]
  node_main["Main process<br/>[main.js]"]
  node_bridge["IPC bridge<br/>[preload.js]"]
  node_settings[("Settings and logs<br/>[main.js]")]
end

subgraph group_meter["Meter monitoring"]
  node_meterui["Meter controls<br/>[renderer.js]"]
  node_serial["Serial transport<br/>[main.js]"]
  node_charts["Live charts<br/>[curve.html]"]
  node_offline["Offline data<br/>[offline.html]"]
end

subgraph group_firmware["Firmware tools"]
  node_firmui["Firmware window"]
  node_flash["Flash and erase<br/>[firmware-flash.js]"]
  node_transport["Flash serial adapter"]
  node_drivers["Driver installation<br/>[driver.html]"]
  node_driverfiles["USB JTAG drivers"]
end

subgraph group_updates["Updates and support"]
  node_appupdate["Application updater<br/>[update.js]"]
  node_fwupdate["Firmware release checks<br/>[update.js]"]
  node_manual["User manual<br/>[manual.html]"]
end

node_user(("Operator"))
node_device(("ESP32-C3 meter"))
node_esptool["esptool-js"]
node_github["GitHub Releases"]

node_user -->|"controls"| node_meterui
node_meterui -->|"invokes IPC"| node_bridge
node_bridge -->|"dispatches IPC"| node_main
node_main -->|"opens and reads"| node_serial
node_serial -->|"serial data"| node_device
node_main -->|"sends measurements"| node_meterui
node_main -->|"sends measurements"| node_charts
node_meterui -->|"saves exports"| node_bridge
node_main -->|"reads and writes"| node_settings
node_user -->|"selects firmware"| node_firmui
node_firmui -->|"requests flash"| node_bridge
node_bridge -->|"dispatches flash IPC"| node_main
node_main -->|"calls flash logic"| node_flash
node_flash -->|"uses transport"| node_transport
node_flash -->|"flashes or erases"| node_esptool
node_transport -->|"SLIP serial"| node_device
node_main -->|"sends progress"| node_firmui
node_user -->|"installs driver"| node_drivers
node_main -->|"uses driver files"| node_driverfiles
node_main -->|"checks and applies"| node_appupdate
node_main -->|"checks and downloads"| node_fwupdate
node_appupdate -.->|"checks releases"| node_github
node_appupdate -.->|"downloads assets"| node_github
node_fwupdate -.->|"checks firmware releases"| node_github
node_user -->|"consults"| node_manual
node_main -->|"sends export records"| node_offline

click node_main "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js"
click node_bridge "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/preload.js"
click node_settings "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js"
click node_meterui "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/renderer.js"
click node_serial "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js"
click node_charts "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/curve.html"
click node_offline "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/offline.html"
click node_firmui "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/firmware-renderer.js"
click node_flash "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/firmware-flash.js"
click node_transport "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/serialport-transport.js"
click node_drivers "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/driver.html"
click node_driverfiles "https://github.com/baihengrui/esp32c3_usb_meter_host/tree/main/drives/esp32-jtag-usb-drives"
click node_appupdate "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/update.js"
click node_fwupdate "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/update.js"
click node_manual "https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/manual.html"

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_main,node_bridge,node_settings toneBlue
class node_meterui,node_serial,node_charts,node_offline toneAmber
class node_firmui,node_flash,node_transport,node_drivers,node_driverfiles toneMint
class node_appupdate,node_fwupdate,node_manual toneRose
class node_user,node_device,node_esptool,node_github toneIndigo
```

## Components

### Desktop shell

- [Main process](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js): `main.js`
- [IPC bridge](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/preload.js): `preload.js`
- [Settings and logs](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js): `main.js`

### Meter monitoring

- [Meter controls](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/renderer.js): `renderer.js`
- [Serial transport](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/main.js): `main.js`
- [Live charts](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/curve.html): `curve.html`
- [Offline data](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/offline.html): `offline.html`

### Firmware tools

- [Firmware window](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/firmware-renderer.js): `firmware-renderer.js`
- [Flash and erase](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/firmware-flash.js): `firmware-flash.js`
- [Flash serial adapter](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/serialport-transport.js): `serialport-transport.js`
- [Driver installation](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/driver.html): `driver.html`
- [USB JTAG drivers](https://github.com/baihengrui/esp32c3_usb_meter_host/tree/main/drives/esp32-jtag-usb-drives): `drives/esp32-jtag-usb-drives`

### Updates and support

- [Application updater](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/update.js): `update.js`
- [Firmware release checks](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/update.js): `update.js`
- [User manual](https://github.com/baihengrui/esp32c3_usb_meter_host/blob/main/manual.html): `manual.html`

### Other components

- **Operator**
- **ESP32-C3 meter**
- **esptool-js**
- **GitHub Releases**

## Connections

- Operator → Meter controls: controls
- Meter controls → IPC bridge: invokes IPC
- IPC bridge → Main process: dispatches IPC
- Main process → Serial transport: opens and reads
- Serial transport → ESP32-C3 meter: serial data
- Main process → Meter controls: sends measurements
- Main process → Live charts: sends measurements
- Meter controls → IPC bridge: saves exports
- Main process → Settings and logs: reads and writes
- Operator → Firmware window: selects firmware
- Firmware window → IPC bridge: requests flash
- IPC bridge → Main process: dispatches flash IPC
- Main process → Flash and erase: calls flash logic
- Flash and erase → Flash serial adapter: uses transport
- Flash and erase → esptool-js: flashes or erases
- Flash serial adapter → ESP32-C3 meter: SLIP serial
- Main process → Firmware window: sends progress
- Operator → Driver installation: installs driver
- Main process → USB JTAG drivers: uses driver files
- Main process → Application updater: checks and applies
- Main process → Firmware release checks: checks and downloads
- Application updater → GitHub Releases: checks releases
- Application updater → GitHub Releases: downloads assets
- Firmware release checks → GitHub Releases: checks firmware releases
- Operator → User manual: consults
- Main process → Offline data: sends export records
