# espressif/esp-insights architecture

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

- Interactive diagram: https://gitdiagram.com/espressif/esp-insights
- Repository: https://github.com/espressif/esp-insights

## Overview

ESP Insights is an embedded remote-diagnostics agent for ESP devices, paired with a cloud service and dashboard. The documented workflow is: diagnostics capture logs, events, metrics, and variables; the agent buffers critical and non-critical data in RTC storage, periodically CBOR-encodes it, and sends it using HTTPS or MQTT for cloud processing and visualization. The graph includes documented capabilities such as boot/reset and crash information, plus command/configuration handling. Several subsystem links are documented in the README; unsampled implementation details are not assumed.

Main entry points: [`components/esp_insights/src/esp_insights.c`](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights.c) (Insights agent), [`components/esp_diag_data_store/src/esp_diag_data_store.c`](https://github.com/espressif/esp-insights/blob/main/components/esp_diag_data_store/src/esp_diag_data_store.c) (Diagnostics data store), [`components/esp_insights/src/esp_insights_cmd_resp.c`](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cmd_resp.c) (Command and response), [`components/esp_insights/src/esp_insights_transport.c`](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_transport.c) (Transport selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Diagnostics capture"]
  node_logs["Log capture"]
  node_events["Custom events<br/>[esp_diagnostics.h]"]
  node_metrics["Metrics"]
  node_system_metrics["System and Wi-Fi metrics"]
  node_variables["Variables"]
end

subgraph group_agent["Insights agent"]
  node_agent_core["Insights agent<br/>[esp_insights.c]"]
  node_store_api["Diagnostics data store"]
  node_rtc_store[("RTC storage<br/>[rtc_store.c]")]
  node_encoder["CBOR encoding"]
  node_decoder["CBOR decoding"]
  node_command_response["Command and response"]
  node_boot_crash["Boot and crash data<br/>[esp_insights.c]"]
end

subgraph group_delivery["Delivery and cloud"]
  node_transport["Transport selection"]
  node_https["HTTPS transport"]
  node_mqtt["MQTT transport"]
  node_cloud{{"Insights cloud"}}
end

subgraph group_experience["Monitoring"]
  node_dashboard["Web dashboard"]
end

node_firmware(("Device firmware"))
node_developer(("Device developer"))

node_firmware -->|"emits logs"| node_logs
node_firmware -->|"reports events"| node_events
node_firmware -->|"reports metrics"| node_metrics
node_firmware -->|"reports variables"| node_variables
node_firmware -->|"initializes"| node_agent_core
node_logs -->|"buffers logs"| node_store_api
node_events -->|"buffers events"| node_store_api
node_metrics -->|"buffers metrics"| node_store_api
node_system_metrics -.->|"provides metrics"| node_metrics
node_variables -->|"buffers variables"| node_store_api
node_agent_core -->|"reads and writes"| node_store_api
node_store_api -->|"persists data"| node_rtc_store
node_agent_core -->|"encodes batches"| node_encoder
node_agent_core -->|"sends batches"| node_transport
node_transport -.->|"selects HTTPS"| node_https
node_transport -.->|"selects MQTT"| node_mqtt
node_https -->|"uploads data"| node_cloud
node_mqtt -->|"publishes data"| node_cloud
node_cloud -->|"processes for display"| node_dashboard
node_developer -->|"monitors devices"| node_dashboard
node_agent_core -->|"collects boot and crash data"| node_boot_crash
node_agent_core -.->|"handles configuration"| node_command_response
node_command_response -->|"decodes messages"| node_decoder
node_command_response -->|"encodes responses"| node_encoder

click node_logs "https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_log_hook.c"
click node_events "https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/include/esp_diagnostics.h"
click node_metrics "https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_metrics.c"
click node_system_metrics "https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_heap_metrics.c"
click node_variables "https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_variables.c"
click node_agent_core "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights.c"
click node_store_api "https://github.com/espressif/esp-insights/blob/main/components/esp_diag_data_store/src/esp_diag_data_store.c"
click node_rtc_store "https://github.com/espressif/esp-insights/blob/main/components/esp_diag_data_store/src/rtc_store/rtc_store.c"
click node_encoder "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cbor_encoder.c"
click node_decoder "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cbor_decoder.c"
click node_command_response "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cmd_resp.c"
click node_boot_crash "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights.c"
click node_transport "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_transport.c"
click node_https "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/transport/esp_insights_https.c"
click node_mqtt "https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/transport/esp_insights_mqtt.c"

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_logs,node_events,node_metrics,node_system_metrics,node_variables toneBlue
class node_agent_core,node_store_api,node_rtc_store,node_encoder,node_decoder,node_command_response,node_boot_crash toneAmber
class node_transport,node_https,node_mqtt,node_cloud toneMint
class node_dashboard toneRose
class node_firmware,node_developer toneIndigo
```

## Components

### Diagnostics capture

- [Log capture](https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_log_hook.c): `components/esp_diagnostics/src/esp_diagnostics_log_hook.c`
- [Custom events](https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/include/esp_diagnostics.h): `components/esp_diagnostics/include/esp_diagnostics.h`
- [Metrics](https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_metrics.c): `components/esp_diagnostics/src/esp_diagnostics_metrics.c`
- [System and Wi-Fi metrics](https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_heap_metrics.c): `components/esp_diagnostics/src/esp_diagnostics_heap_metrics.c`
- [Variables](https://github.com/espressif/esp-insights/blob/main/components/esp_diagnostics/src/esp_diagnostics_variables.c): `components/esp_diagnostics/src/esp_diagnostics_variables.c`

### Insights agent

- [Insights agent](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights.c): `components/esp_insights/src/esp_insights.c`
- [Diagnostics data store](https://github.com/espressif/esp-insights/blob/main/components/esp_diag_data_store/src/esp_diag_data_store.c): `components/esp_diag_data_store/src/esp_diag_data_store.c`
- [RTC storage](https://github.com/espressif/esp-insights/blob/main/components/esp_diag_data_store/src/rtc_store/rtc_store.c): `components/esp_diag_data_store/src/rtc_store/rtc_store.c`
- [CBOR encoding](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cbor_encoder.c): `components/esp_insights/src/esp_insights_cbor_encoder.c`
- [CBOR decoding](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cbor_decoder.c): `components/esp_insights/src/esp_insights_cbor_decoder.c`
- [Command and response](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_cmd_resp.c): `components/esp_insights/src/esp_insights_cmd_resp.c`
- [Boot and crash data](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights.c): `components/esp_insights/src/esp_insights.c`

### Delivery and cloud

- [Transport selection](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/esp_insights_transport.c): `components/esp_insights/src/esp_insights_transport.c`
- [HTTPS transport](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/transport/esp_insights_https.c): `components/esp_insights/src/transport/esp_insights_https.c`
- [MQTT transport](https://github.com/espressif/esp-insights/blob/main/components/esp_insights/src/transport/esp_insights_mqtt.c): `components/esp_insights/src/transport/esp_insights_mqtt.c`
- **Insights cloud**

### Monitoring

- **Web dashboard**

### Other components

- **Device firmware**
- **Device developer**

## Connections

- Device firmware → Log capture: emits logs (evidence: `README.md`)
- Device firmware → Custom events: reports events (evidence: `README.md`)
- Device firmware → Metrics: reports metrics (evidence: `README.md`)
- Device firmware → Variables: reports variables (evidence: `README.md`)
- Device firmware → Insights agent: initializes (evidence: `README.md`)
- Log capture → Diagnostics data store: buffers logs (evidence: `README.md`)
- Custom events → Diagnostics data store: buffers events (evidence: `README.md`)
- Metrics → Diagnostics data store: buffers metrics (evidence: `README.md`)
- System and Wi-Fi metrics → Metrics: provides metrics
- Variables → Diagnostics data store: buffers variables (evidence: `README.md`)
- Insights agent → Diagnostics data store: reads and writes (evidence: `components/esp_insights/src/esp_insights.c`)
- Diagnostics data store → RTC storage: persists data (evidence: `README.md`)
- Insights agent → CBOR encoding: encodes batches (evidence: `README.md`)
- Insights agent → Transport selection: sends batches (evidence: `README.md`)
- Transport selection → HTTPS transport: selects HTTPS
- Transport selection → MQTT transport: selects MQTT
- HTTPS transport → Insights cloud: uploads data (evidence: `README.md`)
- MQTT transport → Insights cloud: publishes data (evidence: `README.md`)
- Insights cloud → Web dashboard: processes for display (evidence: `README.md`)
- Device developer → Web dashboard: monitors devices (evidence: `README.md`)
- Insights agent → Boot and crash data: collects boot and crash data (evidence: `README.md`)
- Insights agent → Command and response: handles configuration
- Command and response → CBOR decoding: decodes messages (evidence: `components/esp_insights/src/esp_insights_cmd_resp.c`)
- Command and response → CBOR encoding: encodes responses (evidence: `components/esp_insights/src/esp_insights_cmd_resp.c`)
