# milosz275/pico-realtime-webserver architecture

> Architecture diagram of the GitHub repository milosz275/pico-realtime-webserver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/milosz275/pico-realtime-webserver
- Repository: https://github.com/milosz275/pico-realtime-webserver

## Overview

##### Project Type and Purpose
- The project is an embedded, full-stack real-time web server designed specifically for the Raspberry Pi Pico W.
- It leverages FreeRTOS Kernel for real-time task management along with a lightweight webserver capability.
- The server handles both static file serving (HTML/SSI files found in src/fs) and dynamic content via CGI/SSI mechanisms, along with simple authentication features.
- Dependencies such as pico-sdk, pico-extras, and the freertos-kernel are integrated as submodules, indicating a tightly coupled embedded environment.

##### Analyzing the File Structure
- Top-Level Directories:
- “include”: Contains all header files (e.g., FreeRTOSConfig.h, cgi.h, lwipopts.h, realtime_webserver.h) that define configurations and interfaces.
- “lib”: Holds submodules and dependencies like freertos-kernel, pico-sdk, and pico-extras.
- “src”: Contains the application source code including main.c and modules for CGI, realtime webserver operations, SSI, and state management.
- “assets”: Likely stores the project’s logo and other static assets used for documentation or UI assets.
- “cmake” and “CMakeLists.txt”: Denote a CMake-based build system, which is supported by GitHub workflow files for CMake builds, CodeQL checks, and Doxygen documentation.
- Build and Configuration:
- The presence of “build.sh” and CMake configurations indicate an automated build process that generates a UF2 file for flashing onto the Pico W.
- The README also indicates that a wifi_credentials.h (to be created by the user) is required for network configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Raspberry Pi Pico W"]:::hardware
    B["FreeRTOS Kernel"]:::os
    C["Webserver Module"]:::app
    D["CGI Handler"]:::app
    E["SSI Handler"]:::app
    F["State Management"]:::app
    G["File System Module"]:::app
    H["Network Stack (LWIP)"]:::network
    I["Configuration Module"]:::config
    J["Build Environment"]:::build
    K["External Dependencies"]:::external

    %% Hardware and OS
    A -->|"runs"| B

    %% Application Modules under FreeRTOS
    B -->|"hosts"| C
    B -->|"hosts"| D
    B -->|"hosts"| E
    B -->|"hosts"| F
    B -->|"hosts"| G

    %% Webserver interactions
    C -->|"handles_HTTP"| H
    C -->|"invokes_CGI"| D
    C -->|"includes_SSI"| E
    G -->|"serves_static"| C

    %% Configuration impact
    I -->|"configures"| B
    I -->|"configures"| H

    %% Build and Dependency
    J -->|"builds"| B
    J -->|"integrates"| K

    %% Click Events
    click B "https://github.com/milosz275/pico-realtime-webserver/tree/main/lib/freertos-kernel"
    
    click C "https://github.com/milosz275/pico-realtime-webserver/blob/main/src/realtime_webserver.c"
    click C "https://github.com/milosz275/pico-realtime-webserver/blob/main/include/realtime_webserver.h"
    
    click D "https://github.com/milosz275/pico-realtime-webserver/blob/main/src/cgi.c"
    click D "https://github.com/milosz275/pico-realtime-webserver/blob/main/include/cgi.h"
    
    click E "https://github.com/milosz275/pico-realtime-webserver/blob/main/src/ssi.c"
    click E "https://github.com/milosz275/pico-realtime-webserver/blob/main/include/ssi.h"
    
    click F "https://github.com/milosz275/pico-realtime-webserver/blob/main/src/state.c"
    click F "https://github.com/milosz275/pico-realtime-webserver/blob/main/include/state.h"
    
    click G "https://github.com/milosz275/pico-realtime-webserver/tree/main/src/fs"
    
    click H "https://github.com/milosz275/pico-realtime-webserver/blob/main/include/lwipopts.h"
    
    click I "https://github.com/milosz275/pico-realtime-webserver/blob/main/include/FreeRTOSConfig.h"
    click I "https://github.com/milosz275/pico-realtime-webserver/blob/main/wifi_credentials.h"
    
    click J "https://github.com/milosz275/pico-realtime-webserver/blob/main/CMakeLists.txt"
    click J "https://github.com/milosz275/pico-realtime-webserver/blob/main/build.sh"
    click J "https://github.com/milosz275/pico-realtime-webserver/tree/main/cmake"
    
    click K "https://github.com/milosz275/pico-realtime-webserver/tree/main/lib/pico-sdk"
    click K "https://github.com/milosz275/pico-realtime-webserver/tree/main/lib/pico-extras"

    %% Styles
    classDef hardware fill:#f9d9a1,stroke:#e08b2c,stroke-width:2px;
    classDef os fill:#d1e8ff,stroke:#5b9bd5,stroke-width:2px;
    classDef app fill:#d5e8d4,stroke:#82b366,stroke-width:2px;
    classDef network fill:#fce5cd,stroke:#f4b183,stroke-width:2px;
    classDef config fill:#ead1dc,stroke:#b4a7d6,stroke-width:2px;
    classDef build fill:#fff2cc,stroke:#f1c232,stroke-width:2px;
    classDef external fill:#eadfc4,stroke:#93c47d,stroke-width:2px;
```
