# nopnop2002/esp-idf-ftpserver architecture

> Architecture diagram of the GitHub repository nopnop2002/esp-idf-ftpserver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nopnop2002/esp-idf-ftpserver
- Repository: https://github.com/nopnop2002/esp-idf-ftpserver

## Overview

##### Project type and purpose
- This is an embedded‐firmware component for the Espressif ESP32 family, built on the ESP-IDF framework. It implements an FTP server over Wi-Fi, exposing a FATFS or LittleFS filesystem layer on either internal flash or external SD cards.

##### File structure
- Top level:
- CMakeLists.txt, LICENSE, README.md – standard ESP-IDF component root.
- `partitions_example*.csv`, `sdkconfig.defaults` – default partition tables and SDK-config.
- `main/` directory:
- CMakeLists.txt, component.mk, idf_component.yml, Kconfig.projbuild – build and configuration metadata for this component.
- `main.c` – application entry point that sets up Wi-Fi and launches the FTP task.
- `ftp.c`, `ftp.h` – core FTP server implementation interacting with VFS and TCP/IP.

##### README for architectural insights
- Configuration via `menuconfig`: selection of filesystem backend (FATFS vs LittleFS, on-flash vs SDSPI vs SDMMC).
- Wi-Fi can operate in Station or Access Point mode.
- Only passive‐mode FTP is supported.
- Uses ESP-IDF’s lwIP TCP/IP stack and VFS abstraction for filesystem operations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration
    subgraph "Configuration"
        cfg1["Kconfig/menuconfig"]:::config
        cfg2["sdkconfig.defaults"]:::config
        cfg3["partitions_example.csv"]:::config
        cfg4["partitions_example_fatfs.csv"]:::config
        cfg5["partitions_example_littlefs.csv"]:::config
        cfg6["README.md"]:::config
        cfg7["LICENSE"]:::config
    end

    %% Build Configuration
    subgraph "Build Configuration"
        bc1["CMakeLists.txt"]:::config
        bc2["main/CMakeLists.txt"]:::config
        bc3["main/component.mk"]:::config
        bc4["main/idf_component.yml"]:::config
    end

    %% Application Layer
    subgraph "Application Layer"
        app1["main.c"]:::app
        app2["ftp.c (FTP Task)"]:::app
        app3["ftp.h"]:::app
    end

    %% ESP-IDF Framework
    subgraph "ESP-IDF Framework"
        subgraph "Real-Time OS"
            rtos["FreeRTOS"]:::framework
        end
        subgraph "Networking"
            wifi["Wi-Fi Driver"]:::framework
            lwip["lwIP Stack"]:::framework
        end
        subgraph "Storage Abstraction"
            vfs["VFS"]:::framework
            fs1["FATFS/LittleFS"]:::framework
            drv["SDSPI/SDMMC Drivers"]:::framework
        end
    end

    %% Hardware Layer
    subgraph "Hardware Layer"
        hw1["ESP32 SoC"]:::hardware
        hw2["External SD Card"]:::hardware
    end

    %% External Entities
    client["FTP Client"]:::external

    %% Connections
    cfg1 -->|configures| wifi
    cfg1 -->|selects FS| fs1
    cfg2 -->|default settings| wifi
    cfg2 -->|default FS config| fs1
    cfg3 -->|partition layout| fs1
    cfg4 -->|partition layout| fs1
    cfg5 -->|partition layout| fs1

    bc1 -->|builds| fs1
    bc2 -->|builds| fs1
    bc3 -->|builds| fs1
    bc4 -->|builds| fs1

    client -->|connects| lwip
    app1 -->|initializes| wifi
    app1 -->|starts task| app2
    lwip -->|TCP port 21| app2
    app2 -->|VFS calls| vfs
    vfs -->|dispatch| fs1
    fs1 -->|flash operations| hw1
    fs1 -->|storage access| drv
    drv -->|SPI/SDMMC| hw2

    %% Click Events
    click cfg1 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/Kconfig.projbuild"
    click cfg2 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/sdkconfig.defaults"
    click cfg3 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/partitions_example.csv"
    click cfg4 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/partitions_example_fatfs.csv"
    click cfg5 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/partitions_example_littlefs.csv"
    click cfg6 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/README.md"
    click cfg7 "https://github.com/nopnop2002/esp-idf-ftpserver/tree/main/LICENSE"
    click bc1 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/CMakeLists.txt"
    click bc2 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/CMakeLists.txt"
    click bc3 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/component.mk"
    click bc4 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/idf_component.yml"
    click app1 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/main.c"
    click app2 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/ftp.c"
    click app3 "https://github.com/nopnop2002/esp-idf-ftpserver/blob/main/main/ftp.h"

    %% Styles
    classDef config fill:#f9f,stroke:#333,stroke-width:1px
    classDef app fill:#9f9,stroke:#333,stroke-width:1px
    classDef framework fill:#99f,stroke:#333,stroke-width:1px
    classDef hardware fill:#ccc,stroke:#333,stroke-width:1px
    classDef external fill:#ff9,stroke:#333,stroke-width:1px
```
