# espressif/esp-aliyun architecture

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

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

## Overview

This is an embedded Alibaba Cloud IoT SDK, presented for ESP devices. Its primary workflow is device Wi-Fi provisioning, device authentication/registration, then a TLS-protected MQTT connection for cloud messaging through the device model. The SDK also includes OTA, HTTP/HTTP2, CoAP/ALCS, gateway, reset, and device-binding capabilities. The README documents the MQTT workflow; source-index references establish some module dependencies, but many runtime call paths are not shown, so those links are omitted or marked unverified.

Main entry points: [`iotkit-embedded/mqtt/iotx_mqtt_client.c`](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/mqtt/iotx_mqtt_client.c) (MQTT client), [`iotkit-embedded/dev_model/dm_manager.c`](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_manager.c) (Device model), [`iotkit-embedded/infra`](https://github.com/espressif/esp-aliyun/tree/master/iotkit-embedded/infra) (Runtime infrastructure), [`iotkit-embedded/dev_sign/dev_sign_mqtt.c`](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_sign/dev_sign_mqtt.c) (Device signing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_onboarding["Device onboarding"]
  node_wifi_prov["Wi-Fi provisioning"]
  node_conn_mgr["Connection manager<br/>[conn_mgr.c]"]
  node_device_sign["Device signing<br/>[dev_sign_mqtt.c]"]
  node_dynreg["Dynamic registration<br/>[dynreg.c]"]
  node_dev_bind["Device binding<br/>[awss_bind.c]"]
  node_dev_reset["Device reset<br/>[dev_reset.c]"]
end

subgraph group_connectivity["Cloud connectivity"]
  node_mqtt["MQTT client<br/>[iotx_mqtt_client.c]"]
  node_mqtt_packet["MQTT packets<br/>[MQTTPacket.c]"]
  node_coap_client["Cloud CoAP<br/>[iotx_coap_api.c]"]
  node_coap_server["CoAP server<br/>[CoAPServer.c]"]
  node_http["HTTP client<br/>[iotx_http_api.c]"]
  node_http2["HTTP/2 streams<br/>[http2_api.c]"]
end

subgraph group_device["Device services"]
  node_device_model["Device model<br/>[dm_manager.c]"]
  node_dm_client["Device client<br/>[dm_client.c]"]
  node_shadow["Device shadow<br/>[dm_shadow.c]"]
  node_ota["Firmware OTA<br/>[iotx_ota.c]"]
  node_ota_fetch["OTA fetching<br/>[ota_fetch.c]"]
  node_alcs["Local ALCS<br/>[alcs_client.c]"]
end

subgraph group_platform["Shared platform"]
  node_infra["Runtime infrastructure"]
  node_nghttp2["HTTP/2 engine<br/>[nghttp2_session.c]"]
  node_root_ca["Root certificates<br/>[root_ca.c]"]
end

node_user(("Device owner"))
node_cloud(("Alibaba IoT Hub"))

node_user -.->|"provides network"| node_wifi_prov
node_wifi_prov -.->|"enables connectivity"| node_conn_mgr
node_conn_mgr -->|"starts services"| node_device_model
node_device_sign -.->|"authenticates"| node_cloud
node_dynreg -.->|"registers device"| node_cloud
node_device_model -.->|"delegates requests"| node_dm_client
node_dm_client -.->|"sends cloud messages"| node_mqtt
node_mqtt -->|"encodes packets"| node_mqtt_packet
node_mqtt -->|"publishes and subscribes"| node_cloud
node_cloud -->|"delivers messages"| node_mqtt
node_device_model -.->|"manages state"| node_shadow
node_device_model -.->|"coordinates updates"| node_ota
node_ota -->|"fetches firmware"| node_ota_fetch
node_dev_bind -.->|"binds device"| node_cloud
node_dev_reset -->|"uses messaging"| node_mqtt
node_coap_client -.->|"communicates by CoAP"| node_cloud
node_coap_server -->|"serves local resources"| node_alcs
node_http -.->|"sends HTTP requests"| node_cloud
node_http2 -.->|"uses protocol engine"| node_nghttp2
node_device_sign -->|"uses hashing"| node_infra
node_http -->|"uses HTTP transport"| node_infra
node_http2 -->|"uses transport"| node_infra
node_cloud -.->|"TLS trust anchor"| node_root_ca

click node_wifi_prov "https://github.com/espressif/esp-aliyun/tree/master/iotkit-embedded/wifi_provision"
click node_conn_mgr "https://github.com/espressif/esp-aliyun/blob/master/conn_mgr/conn_mgr.c"
click node_device_sign "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_sign/dev_sign_mqtt.c"
click node_dynreg "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dynamic_register/dynreg.c"
click node_mqtt "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/mqtt/iotx_mqtt_client.c"
click node_mqtt_packet "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/mqtt/MQTTPacket.c"
click node_device_model "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_manager.c"
click node_dm_client "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_client.c"
click node_shadow "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_shadow.c"
click node_ota "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/ota/iotx_ota.c"
click node_ota_fetch "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/ota/ota_fetch.c"
click node_dev_bind "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_bind/impl/awss_bind.c"
click node_dev_reset "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_reset/dev_reset.c"
click node_coap_client "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/coap_cloud/iotx_coap_api.c"
click node_coap_server "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/coap_server/server/CoAPServer.c"
click node_alcs "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/alcs_client.c"
click node_http "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/http/iotx_http_api.c"
click node_http2 "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/http2/http2_api.c"
click node_infra "https://github.com/espressif/esp-aliyun/tree/master/iotkit-embedded/infra"
click node_nghttp2 "https://github.com/espressif/esp-aliyun/blob/master/wrappers/external_libs/nghttp2/nghttp2_session.c"
click node_root_ca "https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/certs/root_ca.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_prov,node_conn_mgr,node_device_sign,node_dynreg,node_dev_bind,node_dev_reset toneBlue
class node_mqtt,node_mqtt_packet,node_coap_client,node_coap_server,node_http,node_http2 toneAmber
class node_device_model,node_dm_client,node_shadow,node_ota,node_ota_fetch,node_alcs toneMint
class node_infra,node_nghttp2,node_root_ca toneRose
class node_user,node_cloud toneIndigo
```

## Components

### Device onboarding

- [Wi-Fi provisioning](https://github.com/espressif/esp-aliyun/tree/master/iotkit-embedded/wifi_provision): `iotkit-embedded/wifi_provision`
- [Connection manager](https://github.com/espressif/esp-aliyun/blob/master/conn_mgr/conn_mgr.c): `conn_mgr/conn_mgr.c`
- [Device signing](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_sign/dev_sign_mqtt.c): `iotkit-embedded/dev_sign/dev_sign_mqtt.c`
- [Dynamic registration](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dynamic_register/dynreg.c): `iotkit-embedded/dynamic_register/dynreg.c`
- [Device binding](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_bind/impl/awss_bind.c): `iotkit-embedded/dev_bind/impl/awss_bind.c`
- [Device reset](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_reset/dev_reset.c): `iotkit-embedded/dev_reset/dev_reset.c`

### Cloud connectivity

- [MQTT client](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/mqtt/iotx_mqtt_client.c): `iotkit-embedded/mqtt/iotx_mqtt_client.c`
- [MQTT packets](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/mqtt/MQTTPacket.c): `iotkit-embedded/mqtt/MQTTPacket.c`
- [Cloud CoAP](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/coap_cloud/iotx_coap_api.c): `iotkit-embedded/coap_cloud/iotx_coap_api.c`
- [CoAP server](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/coap_server/server/CoAPServer.c): `iotkit-embedded/coap_server/server/CoAPServer.c`
- [HTTP client](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/http/iotx_http_api.c): `iotkit-embedded/http/iotx_http_api.c`
- [HTTP/2 streams](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/http2/http2_api.c): `iotkit-embedded/http2/http2_api.c`

### Device services

- [Device model](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_manager.c): `iotkit-embedded/dev_model/dm_manager.c`
- [Device client](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_client.c): `iotkit-embedded/dev_model/dm_client.c`
- [Device shadow](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/dm_shadow.c): `iotkit-embedded/dev_model/dm_shadow.c`
- [Firmware OTA](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/ota/iotx_ota.c): `iotkit-embedded/ota/iotx_ota.c`
- [OTA fetching](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/ota/ota_fetch.c): `iotkit-embedded/ota/ota_fetch.c`
- [Local ALCS](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/dev_model/alcs_client.c): `iotkit-embedded/dev_model/alcs_client.c`

### Shared platform

- [Runtime infrastructure](https://github.com/espressif/esp-aliyun/tree/master/iotkit-embedded/infra): `iotkit-embedded/infra`
- [HTTP/2 engine](https://github.com/espressif/esp-aliyun/blob/master/wrappers/external_libs/nghttp2/nghttp2_session.c): `wrappers/external_libs/nghttp2/nghttp2_session.c`
- [Root certificates](https://github.com/espressif/esp-aliyun/blob/master/iotkit-embedded/certs/root_ca.c): `iotkit-embedded/certs/root_ca.c`

### Other components

- **Device owner**
- **Alibaba IoT Hub**

## Connections

- Device owner → Wi-Fi provisioning: provides network
- Wi-Fi provisioning → Connection manager: enables connectivity (evidence: `conn_mgr/conn_mgr.c`)
- Connection manager → Device model: starts services (evidence: `conn_mgr/conn_mgr.c`)
- Device signing → Alibaba IoT Hub: authenticates
- Dynamic registration → Alibaba IoT Hub: registers device
- Device model → Device client: delegates requests
- Device client → MQTT client: sends cloud messages
- MQTT client → MQTT packets: encodes packets
- MQTT client → Alibaba IoT Hub: publishes and subscribes
- Alibaba IoT Hub → MQTT client: delivers messages
- Device model → Device shadow: manages state
- Device model → Firmware OTA: coordinates updates
- Firmware OTA → OTA fetching: fetches firmware (evidence: `iotkit-embedded/ota/iotx_ota.c`)
- Device binding → Alibaba IoT Hub: binds device
- Device reset → MQTT client: uses messaging (evidence: `iotkit-embedded/dev_reset/dev_reset.c`)
- Cloud CoAP → Alibaba IoT Hub: communicates by CoAP
- CoAP server → Local ALCS: serves local resources (evidence: `iotkit-embedded/dev_model/alcs_client.c`)
- HTTP client → Alibaba IoT Hub: sends HTTP requests
- HTTP/2 streams → HTTP/2 engine: uses protocol engine
- Device signing → Runtime infrastructure: uses hashing (evidence: `iotkit-embedded/dev_sign/dev_sign_mqtt.c`)
- HTTP client → Runtime infrastructure: uses HTTP transport (evidence: `iotkit-embedded/http/iotx_http_api.c`)
- HTTP/2 streams → Runtime infrastructure: uses transport (evidence: `iotkit-embedded/http2/http2_api.c`)
- Alibaba IoT Hub → Root certificates: TLS trust anchor
