# smc0478/webc architecture

> Architecture diagram of the GitHub repository smc0478/webc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/smc0478/webc
- Repository: https://github.com/smc0478/webc

## Overview

##### Main Components

a) Core Library Components (libwebc):
- Network Layer (net.c/h)
- HTTP Protocol Handler (http.c/h)
- Request Handler (request.c/h)
- Response Handler (response.c/h)
- Data Structures
- Dictionary (dict.c/h)
- (list.c/h)
- Web Server Core (webc.c/h)

b) External Interface:
- Client Applications
- Network Interface
- Dynamic Loading Interface (shown by dlopen example)

**[Client Applications Layer]**
- ↕
**[LibWebC Interface Layer]**
- ↕
**[Core Processing Layer]**
- ↕
**[Network Layer]**
- ↕
**[Operating System/Socket Layer]**

##### Component Relationships

- How external applications interact with libwebc
- Request/response flow through the system
- Demonstrate how the data structures (dict and list) support other components
- Dynamic loading capability demonstrated in the examples

##### Specific Elements

a) Main Components:
**[Client Application] → [LibWebC Interface (webc.h)]**
- ↓
**[Request Handler] ←→ [HTTP Protocol Handler] ←→ [Response Handler]**
- ↑               ↑    ↓                        ↑
- [Dict]──[List]   ↓                       |
- ↓                       ↓
- [Network Handler]
- ↓
- [OS Socket Interface]

b) Key Processes:
- Incoming request flow
- Response generation and return path
- Data structure usage
- Dynamic library loading (from example)

##### Integration points for client applications

This design should reflect both the current implementation and accommodate the planned features from the TODO list, making it valuable for both current understanding and future development.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Applications Layer
    subgraph ClientLayer
        Client["Client Applications"]
        DLOpen["Dynamic Loading Interface"]:::example
        BasicExample["Basic Usage Example"]:::example
    end

    %% LibWebC Interface Layer
    subgraph InterfaceLayer
        WebCCore["Web Server Core"]:::core
        MainEntry["Main Program Entry"]:::core
    end

    %% Core Processing Layer
    subgraph CoreLayer
        HTTPHandler["HTTP Protocol Handler"]:::core
        RequestHandler["Request Handler"]:::core
        ResponseHandler["Response Handler"]:::core
    end

    %% Data Structures Layer
    subgraph DataLayer
        Dict["Dictionary"]:::data
        List["List"]:::data
    end

    %% Network Layer
    subgraph NetworkLayer
        NetHandler["Network Handler"]:::network
    end

    %% OS Layer
    subgraph OSLayer
        Socket["OS Socket Interface"]:::system
    end

    %% Relationships
    Client --> WebCCore
    DLOpen --> WebCCore
    BasicExample --> WebCCore
    WebCCore --> MainEntry
    MainEntry --> HTTPHandler
    HTTPHandler --> RequestHandler
    HTTPHandler --> ResponseHandler
    RequestHandler --> Dict
    RequestHandler --> List
    ResponseHandler --> Dict
    ResponseHandler --> List
    HTTPHandler --> NetHandler
    NetHandler --> Socket

    %% Click Events
    click WebCCore "https://github.com/smc0478/webc/blob/main/src/webc.c"
    click MainEntry "https://github.com/smc0478/webc/blob/main/src/main.c"
    click HTTPHandler "https://github.com/smc0478/webc/blob/main/src/http.c"
    click RequestHandler "https://github.com/smc0478/webc/blob/main/src/request.c"
    click ResponseHandler "https://github.com/smc0478/webc/blob/main/src/response.c"
    click Dict "https://github.com/smc0478/webc/blob/main/src/dict.c"
    click List "https://github.com/smc0478/webc/blob/main/src/list.c"
    click NetHandler "https://github.com/smc0478/webc/blob/main/src/net.c"
    click DLOpen "https://github.com/smc0478/webc/tree/main/example/dlopen/"
    click BasicExample "https://github.com/smc0478/webc/tree/main/example/hello/"

    %% Styles
    classDef core fill:#2374ab
    classDef data fill:#ffd700
    classDef network fill:#ff6b6b
    classDef system fill:#808080
    classDef example fill:#98c1d9

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Data Structures"]:::data
        L3["Network Components"]:::network
        L4["System Interface"]:::system
        L5["Example Interfaces"]:::example
    end
```
