# xkain/espsomfy-rts architecture

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

- Interactive diagram: https://gitdiagram.com/xkain/espsomfy-rts
- Repository: https://github.com/xkain/espsomfy-rts

## Overview

ESPSomfy-RTS is ESP32 firmware that bridges a responsive web interface and network integrations to Somfy-compatible 433 MHz devices and wired relay motors. The principal flow is a user command through the web API to device control and radio transmission; configuration, live updates, and integrations support that flow. The graph also includes documented backup, discovery, and update capabilities. Some relationships are based on README documentation or source-index references rather than shown calls; those are marked dashed where the call path is unverified.

Main entry points: [`src/Web.cpp`](https://github.com/xkain/espsomfy-rts/blob/main/src/Web.cpp) (Web API), [`src/Somfy.cpp`](https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp) (RTS device control), [`src/Network.cpp`](https://github.com/xkain/espsomfy-rts/blob/main/src/Network.cpp) (Network connectivity), [`data-dev/index.js`](https://github.com/xkain/espsomfy-rts/blob/main/data-dev/index.js) (Responsive UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_ui["Responsive UI<br/>[index.js]"]
  node_web["Web API<br/>[Web.cpp]"]
  node_json["JSON responses<br/>[WResp.cpp]"]
  node_sockets["Live events<br/>[Sockets.cpp]"]
end

subgraph group_device["Device control"]
  node_somfy["RTS device control<br/>[Somfy.cpp]"]
  node_radio["433 MHz transceiver<br/>[Somfy.cpp]"]
  node_relay["Relay motors<br/>[Somfy.cpp]"]
end

subgraph group_platform["Network platform"]
  node_network["Network connectivity<br/>[Network.cpp]"]
  node_mqtt["MQTT integration<br/>[MQTT.cpp]"]
  node_ssdp["SSDP discovery<br/>[SSDP.cpp]"]
end

subgraph group_operations["Configuration and updates"]
  node_settings["Device settings<br/>[ConfigSettings.cpp]"]
  node_config[("Config files<br/>[ConfigFile.cpp]")]
  node_updater["Firmware updater<br/>[GitOTA.cpp]"]
  node_backup["Backup and restore<br/>[Web.cpp]"]
end

node_user(("User"))
node_github["GitHub releases"]
node_homeassistant["Home Assistant"]

node_user -->|"controls"| node_ui
node_ui -.->|"sends requests"| node_web
node_web -->|"dispatches commands"| node_somfy
node_somfy -.->|"transmits frames"| node_radio
node_somfy -.->|"drives motors"| node_relay
node_web -->|"formats responses"| node_json
node_somfy -->|"emits events"| node_sockets
node_network -.->|"hosts interface"| node_web
node_somfy -->|"publishes state"| node_mqtt
node_network -.->|"supports discovery"| node_ssdp
node_web -.->|"updates settings"| node_settings
node_settings -.->|"loads and saves"| node_config
node_web -->|"handles backup"| node_backup
node_web -.->|"offers updates"| node_updater
node_updater -->|"downloads releases"| node_github
node_mqtt -->|"integrates via MQTT"| node_homeassistant

click node_ui "https://github.com/xkain/espsomfy-rts/blob/main/data-dev/index.js"
click node_web "https://github.com/xkain/espsomfy-rts/blob/main/src/Web.cpp"
click node_json "https://github.com/xkain/espsomfy-rts/blob/main/src/WResp.cpp"
click node_somfy "https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp"
click node_radio "https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp"
click node_relay "https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp"
click node_sockets "https://github.com/xkain/espsomfy-rts/blob/main/src/Sockets.cpp"
click node_network "https://github.com/xkain/espsomfy-rts/blob/main/src/Network.cpp"
click node_mqtt "https://github.com/xkain/espsomfy-rts/blob/main/src/MQTT.cpp"
click node_ssdp "https://github.com/xkain/espsomfy-rts/blob/main/src/SSDP.cpp"
click node_settings "https://github.com/xkain/espsomfy-rts/blob/main/src/ConfigSettings.cpp"
click node_config "https://github.com/xkain/espsomfy-rts/blob/main/src/ConfigFile.cpp"
click node_updater "https://github.com/xkain/espsomfy-rts/blob/main/src/GitOTA.cpp"
click node_backup "https://github.com/xkain/espsomfy-rts/blob/main/src/Web.cpp"

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_ui,node_web,node_json,node_sockets,node_user toneBlue
class node_somfy,node_radio,node_relay toneAmber
class node_network,node_mqtt,node_ssdp toneMint
class node_settings,node_config,node_updater,node_backup toneRose
class node_github,node_homeassistant toneIndigo
```

## Components

### Web interface

- [Responsive UI](https://github.com/xkain/espsomfy-rts/blob/main/data-dev/index.js): `data-dev/index.js`
- [Web API](https://github.com/xkain/espsomfy-rts/blob/main/src/Web.cpp): `src/Web.cpp`
- [JSON responses](https://github.com/xkain/espsomfy-rts/blob/main/src/WResp.cpp): `src/WResp.cpp`
- [Live events](https://github.com/xkain/espsomfy-rts/blob/main/src/Sockets.cpp): `src/Sockets.cpp`

### Device control

- [RTS device control](https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp): `src/Somfy.cpp`
- [433 MHz transceiver](https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp): `src/Somfy.cpp`
- [Relay motors](https://github.com/xkain/espsomfy-rts/blob/main/src/Somfy.cpp): `src/Somfy.cpp`

### Network platform

- [Network connectivity](https://github.com/xkain/espsomfy-rts/blob/main/src/Network.cpp): `src/Network.cpp`
- [MQTT integration](https://github.com/xkain/espsomfy-rts/blob/main/src/MQTT.cpp): `src/MQTT.cpp`
- [SSDP discovery](https://github.com/xkain/espsomfy-rts/blob/main/src/SSDP.cpp): `src/SSDP.cpp`

### Configuration and updates

- [Device settings](https://github.com/xkain/espsomfy-rts/blob/main/src/ConfigSettings.cpp): `src/ConfigSettings.cpp`
- [Config files](https://github.com/xkain/espsomfy-rts/blob/main/src/ConfigFile.cpp): `src/ConfigFile.cpp`
- [Firmware updater](https://github.com/xkain/espsomfy-rts/blob/main/src/GitOTA.cpp): `src/GitOTA.cpp`
- [Backup and restore](https://github.com/xkain/espsomfy-rts/blob/main/src/Web.cpp): `src/Web.cpp`

### Other components

- **User**
- **GitHub releases**
- **Home Assistant**

## Connections

- User → Responsive UI: controls (evidence: `README.md`)
- Responsive UI → Web API: sends requests
- Web API → RTS device control: dispatches commands (evidence: `src/Web.cpp`)
- RTS device control → 433 MHz transceiver: transmits frames (evidence: `src/Somfy.cpp`)
- RTS device control → Relay motors: drives motors (evidence: `README.md`)
- Web API → JSON responses: formats responses (evidence: `src/Web.cpp`)
- RTS device control → Live events: emits events (evidence: `src/Somfy.cpp`)
- Network connectivity → Web API: hosts interface
- RTS device control → MQTT integration: publishes state (evidence: `src/Somfy.cpp`)
- Network connectivity → SSDP discovery: supports discovery
- Web API → Device settings: updates settings
- Device settings → Config files: loads and saves
- Web API → Backup and restore: handles backup (evidence: `src/Web.cpp`)
- Web API → Firmware updater: offers updates (evidence: `README.md`)
- Firmware updater → GitHub releases: downloads releases (evidence: `README.md`)
- MQTT integration → Home Assistant: integrates via MQTT (evidence: `README.md`)
