# wolfofnox/esp32-captive-wifi-manager architecture

> Architecture diagram of the GitHub repository wolfofnox/esp32-captive-wifi-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wolfofnox/esp32-captive-wifi-manager
- Repository: https://github.com/wolfofnox/esp32-captive-wifi-manager

## Overview

The product is an ESP-IDF component that manages ESP32 WiFi connectivity and provides a captive-portal setup experience. Its main workflow initializes the manager, attempts saved-network operation, and can fall back to an AP portal for scanning and configuration; credentials and network options persist in NVS. HTTP runtime handlers expose status, configuration, and file serving, with optional WebSocket/RAP, SD-card, mDNS, and LED capabilities. Some internal call sites were not excerpted, so inferred subsystem links are marked dashed and uncited.

Main entry points: [`src/Wifi.c`](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Wifi.c) (WiFi manager), [`src/Captive.c`](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Captive.c) (Captive portal), [`src/Runtime-handlers.c`](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Runtime-handlers.c) (Runtime HTTP handlers), [`src/Server-mgr.c`](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Server-mgr.c) (HTTP server manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_connectivity["WiFi connectivity"]
  node_wifi["WiFi manager<br/>[Wifi.c]"]
  node_sta["Station mode<br/>[STA.c]"]
  node_ap["Access point mode<br/>[AP.c]"]
end

subgraph group_portal["Portal and API"]
  node_captive["Captive portal<br/>[Captive.c]"]
  node_dns["Captive DNS<br/>[dns_server.c]"]
  node_http["HTTP server manager<br/>[Server-mgr.c]"]
  node_runtime["Runtime HTTP handlers<br/>[Runtime-handlers.c]"]
  node_common["Common handlers<br/>[Common-handlers.c]"]
  node_websocket["WebSocket RAP<br/>[ws_server.c]"]
end

subgraph group_state["Configuration and state"]
  node_nvs[("Credential persistence<br/>[nvs-mgr.c]")]
  node_flags["Mode and event flags<br/>[Flags.c]"]
end

subgraph group_extensions["Optional integrations"]
  node_sd["SD card mount<br/>[SD-mgr.c]"]
  node_files["SD file serving<br/>[Runtime-handlers.c]"]
  node_led["Status LED<br/>[wifi_led.h]"]
  node_mdns["mDNS discovery<br/>[Captive.c]"]
end

node_app(("ESP-IDF application"))
node_device(("ESP32 device"))

node_app -->|"initializes"| node_wifi
node_wifi -.->|"selects mode"| node_sta
node_wifi -.->|"selects mode"| node_ap
node_wifi -.->|"loads settings"| node_nvs
node_wifi -.->|"starts server"| node_http
node_wifi -.->|"initializes"| node_led
node_wifi -.->|"mounts card"| node_sd
node_wifi -.->|"tracks events"| node_flags
node_captive -->|"stops server"| node_dns
node_runtime -->|"registers errors"| node_http
node_runtime -->|"registers handlers"| node_common
node_runtime -->|"registers portal routes"| node_captive
node_runtime -->|"serves files"| node_files
node_files -->|"reads mounted files"| node_sd
node_captive -.->|"persists settings"| node_nvs
node_captive -.->|"requests mode changes"| node_flags
node_wifi -.->|"enables messaging"| node_websocket
node_captive -.->|"configures discovery"| node_mdns
node_device -.->|"provides network"| node_wifi

click node_wifi "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Wifi.c"
click node_sta "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/STA.c"
click node_ap "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/AP.c"
click node_captive "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Captive.c"
click node_dns "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/priv_include/dns_server/dns_server.c"
click node_http "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Server-mgr.c"
click node_runtime "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Runtime-handlers.c"
click node_common "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Common-handlers.c"
click node_websocket "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/ws_server.c"
click node_nvs "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/nvs-mgr.c"
click node_flags "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Flags.c"
click node_sd "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/SD-mgr.c"
click node_files "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Runtime-handlers.c"
click node_led "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/priv_include/wifi_led.h"
click node_mdns "https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Captive.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_wifi,node_sta,node_ap toneBlue
class node_captive,node_dns,node_http,node_runtime,node_common,node_websocket toneAmber
class node_nvs,node_flags toneMint
class node_sd,node_files,node_led,node_mdns toneRose
class node_app,node_device toneIndigo
```

## Components

### WiFi connectivity

- [WiFi manager](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Wifi.c): `src/Wifi.c`
- [Station mode](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/STA.c): `src/STA.c`
- [Access point mode](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/AP.c): `src/AP.c`

### Portal and API

- [Captive portal](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Captive.c): `src/Captive.c`
- [Captive DNS](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/priv_include/dns_server/dns_server.c): `priv_include/dns_server/dns_server.c`
- [HTTP server manager](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Server-mgr.c): `src/Server-mgr.c`
- [Runtime HTTP handlers](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Runtime-handlers.c): `src/Runtime-handlers.c`
- [Common handlers](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Common-handlers.c): `src/Common-handlers.c`
- [WebSocket RAP](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/ws_server.c): `src/ws_server.c`

### Configuration and state

- [Credential persistence](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/nvs-mgr.c): `src/nvs-mgr.c`
- [Mode and event flags](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Flags.c): `src/Flags.c`

### Optional integrations

- [SD card mount](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/SD-mgr.c): `src/SD-mgr.c`
- [SD file serving](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Runtime-handlers.c): `src/Runtime-handlers.c`
- [Status LED](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/priv_include/wifi_led.h): `priv_include/wifi_led.h`
- [mDNS discovery](https://github.com/wolfofnox/esp32-captive-wifi-manager/blob/main/src/Captive.c): `src/Captive.c`

### Other components

- **ESP-IDF application**
- **ESP32 device**

## Connections

- ESP-IDF application → WiFi manager: initializes
- WiFi manager → Station mode: selects mode
- WiFi manager → Access point mode: selects mode
- WiFi manager → Credential persistence: loads settings
- WiFi manager → HTTP server manager: starts server
- WiFi manager → Status LED: initializes (evidence: `src/Wifi.c`)
- WiFi manager → SD card mount: mounts card
- WiFi manager → Mode and event flags: tracks events
- Captive portal → Captive DNS: stops server (evidence: `src/Captive.c`)
- Runtime HTTP handlers → HTTP server manager: registers errors (evidence: `src/Runtime-handlers.c`)
- Runtime HTTP handlers → Common handlers: registers handlers (evidence: `src/Runtime-handlers.c`)
- Runtime HTTP handlers → Captive portal: registers portal routes (evidence: `src/Runtime-handlers.c`)
- Runtime HTTP handlers → SD file serving: serves files (evidence: `src/Runtime-handlers.c`)
- SD file serving → SD card mount: reads mounted files (evidence: `src/Runtime-handlers.c`)
- Captive portal → Credential persistence: persists settings
- Captive portal → Mode and event flags: requests mode changes
- WiFi manager → WebSocket RAP: enables messaging
- Captive portal → mDNS discovery: configures discovery (evidence: `src/Captive.c`)
- ESP32 device → WiFi manager: provides network
