# mccannex/sysmon architecture

> Architecture diagram of the GitHub repository mccannex/sysmon, 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/mccannex/sysmon
- Repository: https://github.com/mccannex/sysmon

## Overview

SysMon is an ESP-IDF component that samples FreeRTOS task and memory statistics, then serves telemetry and an embedded browser dashboard. The main workflow is application initialization after network connectivity, background sampling and history collection, HTTP endpoint responses, and browser-side visualization. The README documents dashboard capabilities beyond the sampled C excerpts; those are represented at subsystem level. Source excerpts establish runtime and API wiring, but browser-script interactions are not shown, so their internal edges are omitted.

Main entry points: [`www/js/app.js`](https://github.com/mccannex/sysmon/blob/main/www/js/app.js) (Dashboard updates), [`src/sysmon_http.c`](https://github.com/mccannex/sysmon/blob/main/src/sysmon_http.c) (HTTP server and routes), [`src/sysmon.c`](https://github.com/mccannex/sysmon/blob/main/src/sysmon.c) (SysMon lifecycle), [`src/sysmon_handlers.c`](https://github.com/mccannex/sysmon/blob/main/src/sysmon_handlers.c) (Request handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime lifecycle"]
  node_sysmon["SysMon lifecycle<br/>[sysmon.c]"]
  node_wifi["Connectivity checks<br/>[sysmon_utils.c]"]
end

subgraph group_sampling["Monitoring and state"]
  node_sampler["Task and resource sampler<br/>[sysmon.c]"]
  node_task_state[("Task usage history<br/>[sysmon.c]")]
  node_system_state[("CPU and memory history<br/>[sysmon.c]")]
  node_stack_registry[("Stack registration<br/>[sysmon_stack.c]")]
end

subgraph group_api["HTTP and telemetry"]
  node_http_server["HTTP server and routes<br/>[sysmon_http.c]"]
  node_request_handlers["Request handlers<br/>[sysmon_handlers.c]"]
  node_json_builders["Telemetry JSON<br/>[sysmon_json.c]"]
  node_api_config["Route configuration<br/>[sysmon_config.h]"]
  node_http_utils["HTTP utilities<br/>[sysmon_utils.c]"]
end

subgraph group_dashboard["Browser dashboard"]
  node_dashboard_app["Dashboard updates<br/>[app.js]"]
  node_charts["Charts<br/>[charts.js]"]
  node_task_table["Task tables<br/>[table.js]"]
  node_dashboard_config["Dashboard configuration<br/>[config.js]"]
  node_dashboard_utils["Dashboard utilities<br/>[utils.js]"]
  node_theme["Theme controls<br/>[theme.js]"]
  node_web_assets["Embedded web assets"]
end

node_app(("ESP-IDF application"))
node_network(("Connected network"))
node_browser(("Web browser"))

node_app -->|"initializes"| node_sysmon
node_sysmon -->|"checks connectivity"| node_wifi
node_network -->|"provides connection"| node_wifi
node_sysmon -->|"starts server"| node_http_server
node_sysmon -->|"starts task"| node_sampler
node_sampler -->|"records samples"| node_task_state
node_sampler -->|"records samples"| node_system_state
node_app -->|"registers stacks"| node_stack_registry
node_sampler -.->|"uses registrations"| node_stack_registry
node_http_server -->|"configures routes"| node_api_config
node_http_server -->|"registers handlers"| node_request_handlers
node_request_handlers -->|"calls configured builder"| node_json_builders
node_request_handlers -->|"uses content type"| node_http_utils
node_json_builders -->|"reads task history"| node_task_state
node_json_builders -->|"reads system history"| node_system_state
node_browser -->|"loads dashboard"| node_web_assets
node_web_assets -->|"served by"| node_http_server
node_browser -->|"requests telemetry"| node_http_server
node_dashboard_app --> node_charts
node_dashboard_app --> node_task_table
node_dashboard_app --> node_dashboard_config
node_dashboard_app --> node_dashboard_utils
node_dashboard_app --> node_theme

click node_sysmon "https://github.com/mccannex/sysmon/blob/main/src/sysmon.c"
click node_wifi "https://github.com/mccannex/sysmon/blob/main/src/sysmon_utils.c"
click node_sampler "https://github.com/mccannex/sysmon/blob/main/src/sysmon.c"
click node_task_state "https://github.com/mccannex/sysmon/blob/main/src/sysmon.c"
click node_system_state "https://github.com/mccannex/sysmon/blob/main/src/sysmon.c"
click node_stack_registry "https://github.com/mccannex/sysmon/blob/main/src/sysmon_stack.c"
click node_http_server "https://github.com/mccannex/sysmon/blob/main/src/sysmon_http.c"
click node_request_handlers "https://github.com/mccannex/sysmon/blob/main/src/sysmon_handlers.c"
click node_json_builders "https://github.com/mccannex/sysmon/blob/main/src/sysmon_json.c"
click node_api_config "https://github.com/mccannex/sysmon/blob/main/include/sysmon_config.h"
click node_http_utils "https://github.com/mccannex/sysmon/blob/main/src/sysmon_utils.c"
click node_dashboard_app "https://github.com/mccannex/sysmon/blob/main/www/js/app.js"
click node_charts "https://github.com/mccannex/sysmon/blob/main/www/js/charts.js"
click node_task_table "https://github.com/mccannex/sysmon/blob/main/www/js/table.js"
click node_dashboard_config "https://github.com/mccannex/sysmon/blob/main/www/js/config.js"
click node_dashboard_utils "https://github.com/mccannex/sysmon/blob/main/www/js/utils.js"
click node_theme "https://github.com/mccannex/sysmon/blob/main/www/js/theme.js"
click node_web_assets "https://github.com/mccannex/sysmon/tree/main/www"

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_sysmon,node_wifi,node_browser toneBlue
class node_sampler,node_task_state,node_system_state,node_stack_registry toneAmber
class node_http_server,node_request_handlers,node_json_builders,node_api_config,node_http_utils toneMint
class node_dashboard_app,node_charts,node_task_table,node_dashboard_config,node_dashboard_utils,node_theme,node_web_assets toneRose
class node_app,node_network toneIndigo
```

## Components

### Runtime lifecycle

- [SysMon lifecycle](https://github.com/mccannex/sysmon/blob/main/src/sysmon.c): `src/sysmon.c`
- [Connectivity checks](https://github.com/mccannex/sysmon/blob/main/src/sysmon_utils.c): `src/sysmon_utils.c`

### Monitoring and state

- [Task and resource sampler](https://github.com/mccannex/sysmon/blob/main/src/sysmon.c): `src/sysmon.c`
- [Task usage history](https://github.com/mccannex/sysmon/blob/main/src/sysmon.c): `src/sysmon.c`
- [CPU and memory history](https://github.com/mccannex/sysmon/blob/main/src/sysmon.c): `src/sysmon.c`
- [Stack registration](https://github.com/mccannex/sysmon/blob/main/src/sysmon_stack.c): `src/sysmon_stack.c`

### HTTP and telemetry

- [HTTP server and routes](https://github.com/mccannex/sysmon/blob/main/src/sysmon_http.c): `src/sysmon_http.c`
- [Request handlers](https://github.com/mccannex/sysmon/blob/main/src/sysmon_handlers.c): `src/sysmon_handlers.c`
- [Telemetry JSON](https://github.com/mccannex/sysmon/blob/main/src/sysmon_json.c): `src/sysmon_json.c`
- [Route configuration](https://github.com/mccannex/sysmon/blob/main/include/sysmon_config.h): `include/sysmon_config.h`
- [HTTP utilities](https://github.com/mccannex/sysmon/blob/main/src/sysmon_utils.c): `src/sysmon_utils.c`

### Browser dashboard

- [Dashboard updates](https://github.com/mccannex/sysmon/blob/main/www/js/app.js): `www/js/app.js`
- [Charts](https://github.com/mccannex/sysmon/blob/main/www/js/charts.js): `www/js/charts.js`
- [Task tables](https://github.com/mccannex/sysmon/blob/main/www/js/table.js): `www/js/table.js`
- [Dashboard configuration](https://github.com/mccannex/sysmon/blob/main/www/js/config.js): `www/js/config.js`
- [Dashboard utilities](https://github.com/mccannex/sysmon/blob/main/www/js/utils.js): `www/js/utils.js`
- [Theme controls](https://github.com/mccannex/sysmon/blob/main/www/js/theme.js): `www/js/theme.js`
- [Embedded web assets](https://github.com/mccannex/sysmon/tree/main/www): `www`

### Other components

- **ESP-IDF application**
- **Connected network**
- **Web browser**

## Connections

- ESP-IDF application → SysMon lifecycle: initializes (evidence: `README.md`)
- SysMon lifecycle → Connectivity checks: checks connectivity (evidence: `src/sysmon.c`)
- Connected network → Connectivity checks: provides connection (evidence: `README.md`)
- SysMon lifecycle → HTTP server and routes: starts server (evidence: `src/sysmon.c`)
- SysMon lifecycle → Task and resource sampler: starts task (evidence: `src/sysmon.c`)
- Task and resource sampler → Task usage history: records samples (evidence: `src/sysmon.c`)
- Task and resource sampler → CPU and memory history: records samples (evidence: `src/sysmon.c`)
- ESP-IDF application → Stack registration: registers stacks (evidence: `README.md`)
- Task and resource sampler → Stack registration: uses registrations
- HTTP server and routes → Route configuration: configures routes (evidence: `src/sysmon_http.c`)
- HTTP server and routes → Request handlers: registers handlers (evidence: `src/sysmon_http.c`)
- Request handlers → Telemetry JSON: calls configured builder (evidence: `src/sysmon_handlers.c`)
- Request handlers → HTTP utilities: uses content type (evidence: `src/sysmon_handlers.c`)
- Telemetry JSON → Task usage history: reads task history (evidence: `src/sysmon_json.c`)
- Telemetry JSON → CPU and memory history: reads system history (evidence: `src/sysmon_json.c`)
- Web browser → Embedded web assets: loads dashboard (evidence: `README.md`)
- Embedded web assets → HTTP server and routes: served by (evidence: `src/sysmon_http.c`)
- Web browser → HTTP server and routes: requests telemetry (evidence: `README.md`)
- Dashboard updates → Charts
- Dashboard updates → Task tables
- Dashboard updates → Dashboard configuration
- Dashboard updates → Dashboard utilities
- Dashboard updates → Theme controls
