# aircoookie/wled architecture

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

- Interactive diagram: https://gitdiagram.com/aircoookie/wled
- Repository: https://github.com/aircoookie/wled

## Overview

##### Main Components

a. Hardware Layer:
- ESP32/ESP8266 Controller
- LED Strip Interfaces (Multiple outputs - up to 10 for ESP32)
- Various Supported LED Types (WS2812B, WS2811, SK6812, WS2801, APA102)
- Optional Hardware Components (IR receivers, sensors from usermods)

b. Core Software Components:
- LED Control System (wled00/led.cpp, FX.cpp)
- Network Stack (wled00/network.cpp)
- Web Server (wled00/wled_server.cpp)
- File System (for configuration storage)
- Update System (OTA)

c. Interface Layer:
- Web Interface (data/ directory contents)
- JSON/HTTP API
- MQTT Client
- Real-time Protocols (E1.31, Art-Net, DDP, TPM2.net)
- Voice Control (Alexa)
- IR Remote Control

d. User Modifications:
- Usermod System (usermods/ directory)
- Custom Effects
- Hardware Extensions

##### Relationships and Data Flow

- Data flow from various inputs (web UI, API, MQTT) to the core controller
- LED control signals from controller to LED strips
- Network communications (both incoming and outgoing)
- Integration with external services (Philips Hue, MQTT broker, NTP)

##### Specific Implementation Details

- Multiple LED output capability
- Segment control system
- Effect processing pipeline
- Configuration storage and management
- Network failsafe mechanisms (AP mode)
- Update pathways

##### Key Features to Highlight

Create subsections showing:
- Effect System (100+ special effects)
- Preset Management
- Real-time Control Options
- Security Features
- Time-based Functions

##### External Integrations

Connections to:
- Mobile Apps
- Home Automation Systems
- External Control Software
- Time Servers
- Update Servers

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User_Interface_Layer
        WEB["Web Interface"]:::ui
        API["JSON/HTTP API"]:::ui
        MQTT["MQTT Client"]:::ui
        ALEXA["Alexa Integration"]:::ui
        IR["IR Remote Control"]:::ui
        MOBILE["Mobile Apps"]:::ui
    end

    subgraph Core_Processing_Layer
        LED["LED Control System"]:::core
        NET["Network Stack"]:::core
        WSERV["Web Server"]:::core
        FS["File System"]:::core
        CFG["Configuration Management"]:::core
        EFFECTS["Effect System"]:::core
        PIN["Pin Management"]:::core
        BUS["Bus Management"]:::core
    end

    subgraph Protocol_Layer
        E131["Real-time Protocols"]:::protocol
        ARTNET["Art-Net"]:::protocol
        DDP["DDP"]:::protocol
        TPM["TPM2.net"]:::protocol
    end

    subgraph Hardware_Layer
        ESP["ESP32/ESP8266"]:::hw
        LEDSTRIP["LED Strips"]:::hw
        SENSORS["Sensors"]:::hw
        IRREC["IR Receivers"]:::hw
    end

    subgraph External_Services
        NTP["Time Server"]:::ext
        OTA["Update Server"]:::ext
        BROKER["MQTT Broker"]:::ext
        HUE["Philips Hue"]:::ext
    end

    subgraph User_Modifications
        UMOD["Usermod System"]:::user
        CEFFECTS["Custom Effects"]:::user
        HWEXT["Hardware Extensions"]:::user
    end

    %% Connections
    WEB --> WSERV
    API --> WSERV
    MQTT --> NET
    ALEXA --> NET
    IR --> ESP

    WSERV --> LED
    NET --> LED
    LED --> BUS
    BUS --> PIN
    PIN --> LEDSTRIP

    E131 --> NET
    ARTNET --> NET
    DDP --> NET
    TPM --> NET

    NET --> BROKER
    NET --> NTP
    NET --> OTA
    NET --> HUE

    UMOD --> LED
    CEFFECTS --> EFFECTS
    HWEXT --> ESP

    EFFECTS --> LED
    CFG --> FS

    %% Click events
    click LED "https://github.com/Aircoookie/WLED/blob/main/wled00/led.cpp"
    click NET "https://github.com/Aircoookie/WLED/blob/main/wled00/network.cpp"
    click WSERV "https://github.com/Aircoookie/WLED/blob/main/wled00/wled_server.cpp"
    click FS "https://github.com/Aircoookie/WLED/blob/main/wled00/file.cpp"
    click WEB "https://github.com/Aircoookie/WLED/tree/main/wled00/data/"
    click MQTT "https://github.com/Aircoookie/WLED/blob/main/wled00/mqtt.cpp"
    click ALEXA "https://github.com/Aircoookie/WLED/blob/main/wled00/alexa.cpp"
    click IR "https://github.com/Aircoookie/WLED/blob/main/wled00/ir.cpp"
    click API "https://github.com/Aircoookie/WLED/blob/main/wled00/json.cpp"
    click UMOD "https://github.com/Aircoookie/WLED/tree/main/usermods/"
    click EFFECTS "https://github.com/Aircoookie/WLED/blob/main/wled00/FX_fcn.cpp"
    click CFG "https://github.com/Aircoookie/WLED/blob/main/wled00/cfg.cpp"
    click E131 "https://github.com/Aircoookie/WLED/blob/main/wled00/e131.cpp"
    click PIN "https://github.com/Aircoookie/WLED/blob/main/wled00/pin_manager.cpp"
    click BUS "https://github.com/Aircoookie/WLED/blob/main/wled00/bus_manager.cpp"

    %% Styles
    classDef core fill:#2374ab
    classDef ui fill:#48a9a6
    classDef protocol fill:#4b7f52
    classDef hw fill:#c1666b
    classDef ext fill:#d4b483
    classDef user fill:#9b6b9e

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["User Interface"]:::ui
        L3["Protocols"]:::protocol
        L4["Hardware"]:::hw
        L5["External Services"]:::ext
        L6["User Modifications"]:::user
    end
```
