# aweh-github/webserv architecture

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

- Interactive diagram: https://gitdiagram.com/aweh-github/webserv
- Repository: https://github.com/aweh-github/webserv

## Overview

Webserv is a C++98, event-driven HTTP/1.1 server. Its main workflow is to load server/location configuration, accept connections, parse and route requests, then produce responses from files, directory listings, uploads, redirects, or CGI output. The README documents the supported methods, limits, and virtual-host behavior. The graph uses the sampled main loop and client/config excerpts where available; several feature links rely on README statements because their implementation excerpts were not provided.

Main entry points: [`src/Exec/Client.cpp`](https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp) (Client Connection), [`src/main.cpp`](https://github.com/aweh-github/webserv/blob/main/src/main.cpp) (Server Entry), [`src/Exec/WebServ.cpp`](https://github.com/aweh-github/webserv/blob/main/src/Exec/WebServ.cpp) (Poll Server), [`src/Exec/Get.cpp`](https://github.com/aweh-github/webserv/blob/main/src/Exec/Get.cpp) (GET Handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Configuration"]
  node_config_parse["Config Parser<br/>[__internal__.cpp]"]
  node_config_model["Server Config<br/>[Server.cpp]"]
  node_location_model["Location Config<br/>[Location.cpp]"]
end

subgraph group_runtime["Event Runtime"]
  node_main["Server Entry<br/>[main.cpp]"]
  node_webserv["Poll Server<br/>[WebServ.cpp]"]
  node_socket["Listening Socket<br/>[Socket.cpp]"]
end

subgraph group_http["HTTP Handling"]
  node_client["Client Connection<br/>[Client.cpp]"]
  node_routing["Host and Location Routing<br/>[Client.cpp]"]
  node_response["HTTP Responses<br/>[Response.cpp]"]
end

subgraph group_content["Content and CGI"]
  node_get["GET Handling<br/>[Get.cpp]"]
  node_index["Directory Index<br/>[Index.cpp]"]
  node_post["POST Uploads<br/>[Post.cpp]"]
  node_delete["DELETE Handling<br/>[Client.cpp]"]
  node_redirect["Redirect Handling<br/>[Redirection.cpp]"]
  node_cgi["CGI Execution<br/>[Cgi.cpp]"]
  node_webpage["Page Builder<br/>[WebPage.cpp]"]
end

node_operator(("Server Operator"))
node_filesystem[("Website Files")]
node_cgi_runtime{{"CGI Interpreter"}}

node_operator -->|"starts"| node_main
node_main -->|"parses config"| node_config_parse
node_config_parse -.->|"builds config"| node_config_model
node_config_model -->|"stores locations"| node_location_model
node_main -->|"starts server"| node_webserv
node_webserv -.->|"opens listeners"| node_socket
node_webserv -->|"dispatches events"| node_client
node_client -->|"selects host"| node_routing
node_routing -->|"looks up server"| node_config_model
node_routing -->|"selects location"| node_location_model
node_client -.->|"handles GET"| node_get
node_get -.->|"reads files"| node_filesystem
node_get -.->|"lists directories"| node_index
node_index -->|"builds listing"| node_webpage
node_client -.->|"handles POST"| node_post
node_post -.->|"stores uploads"| node_filesystem
node_client -.->|"handles DELETE"| node_delete
node_client -.->|"applies redirect"| node_redirect
node_client -.->|"runs CGI"| node_cgi
node_cgi -.->|"invokes interpreter"| node_cgi_runtime
node_client -.->|"builds response"| node_response
node_response -.->|"reads error pages"| node_filesystem

click node_main "https://github.com/aweh-github/webserv/blob/main/src/main.cpp"
click node_config_parse "https://github.com/aweh-github/webserv/blob/main/src/Config/__internal__.cpp"
click node_config_model "https://github.com/aweh-github/webserv/blob/main/src/Config/Server.cpp"
click node_location_model "https://github.com/aweh-github/webserv/blob/main/src/Config/Location.cpp"
click node_webserv "https://github.com/aweh-github/webserv/blob/main/src/Exec/WebServ.cpp"
click node_socket "https://github.com/aweh-github/webserv/blob/main/src/Exec/Socket.cpp"
click node_client "https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp"
click node_routing "https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp"
click node_get "https://github.com/aweh-github/webserv/blob/main/src/Exec/Get.cpp"
click node_index "https://github.com/aweh-github/webserv/blob/main/src/Exec/Index.cpp"
click node_post "https://github.com/aweh-github/webserv/blob/main/src/Exec/Post.cpp"
click node_delete "https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp"
click node_redirect "https://github.com/aweh-github/webserv/blob/main/src/Exec/Redirection.cpp"
click node_cgi "https://github.com/aweh-github/webserv/blob/main/src/Exec/Cgi.cpp"
click node_response "https://github.com/aweh-github/webserv/blob/main/src/Exec/Response.cpp"
click node_webpage "https://github.com/aweh-github/webserv/blob/main/src/Exec/WebPage.cpp"

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_config_parse,node_config_model,node_location_model toneBlue
class node_main,node_webserv,node_socket,node_filesystem toneAmber
class node_client,node_routing,node_response,node_operator toneMint
class node_get,node_index,node_post,node_delete,node_redirect,node_cgi,node_webpage toneRose
class node_cgi_runtime toneIndigo
```

## Components

### Configuration

- [Config Parser](https://github.com/aweh-github/webserv/blob/main/src/Config/__internal__.cpp): `src/Config/__internal__.cpp`
- [Server Config](https://github.com/aweh-github/webserv/blob/main/src/Config/Server.cpp): `src/Config/Server.cpp`
- [Location Config](https://github.com/aweh-github/webserv/blob/main/src/Config/Location.cpp): `src/Config/Location.cpp`

### Event Runtime

- [Server Entry](https://github.com/aweh-github/webserv/blob/main/src/main.cpp): `src/main.cpp`
- [Poll Server](https://github.com/aweh-github/webserv/blob/main/src/Exec/WebServ.cpp): `src/Exec/WebServ.cpp`
- [Listening Socket](https://github.com/aweh-github/webserv/blob/main/src/Exec/Socket.cpp): `src/Exec/Socket.cpp`

### HTTP Handling

- [Client Connection](https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp): `src/Exec/Client.cpp`
- [Host and Location Routing](https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp): `src/Exec/Client.cpp`
- [HTTP Responses](https://github.com/aweh-github/webserv/blob/main/src/Exec/Response.cpp): `src/Exec/Response.cpp`

### Content and CGI

- [GET Handling](https://github.com/aweh-github/webserv/blob/main/src/Exec/Get.cpp): `src/Exec/Get.cpp`
- [Directory Index](https://github.com/aweh-github/webserv/blob/main/src/Exec/Index.cpp): `src/Exec/Index.cpp`
- [POST Uploads](https://github.com/aweh-github/webserv/blob/main/src/Exec/Post.cpp): `src/Exec/Post.cpp`
- [DELETE Handling](https://github.com/aweh-github/webserv/blob/main/src/Exec/Client.cpp): `src/Exec/Client.cpp`
- [Redirect Handling](https://github.com/aweh-github/webserv/blob/main/src/Exec/Redirection.cpp): `src/Exec/Redirection.cpp`
- [CGI Execution](https://github.com/aweh-github/webserv/blob/main/src/Exec/Cgi.cpp): `src/Exec/Cgi.cpp`
- [Page Builder](https://github.com/aweh-github/webserv/blob/main/src/Exec/WebPage.cpp): `src/Exec/WebPage.cpp`

### Other components

- **Server Operator**
- **Website Files**
- **CGI Interpreter**

## Connections

- Server Operator → Server Entry: starts
- Server Entry → Config Parser: parses config (evidence: `src/main.cpp`)
- Config Parser → Server Config: builds config
- Server Config → Location Config: stores locations (evidence: `src/Config/Server.cpp`)
- Server Entry → Poll Server: starts server (evidence: `src/main.cpp`)
- Poll Server → Listening Socket: opens listeners
- Poll Server → Client Connection: dispatches events
- Client Connection → Host and Location Routing: selects host (evidence: `src/Exec/Client.cpp`)
- Host and Location Routing → Server Config: looks up server (evidence: `src/Exec/Client.cpp`)
- Host and Location Routing → Location Config: selects location (evidence: `src/Exec/Client.cpp`)
- Client Connection → GET Handling: handles GET
- GET Handling → Website Files: reads files
- GET Handling → Directory Index: lists directories
- Directory Index → Page Builder: builds listing (evidence: `src/Exec/Index.cpp`)
- Client Connection → POST Uploads: handles POST
- POST Uploads → Website Files: stores uploads
- Client Connection → DELETE Handling: handles DELETE (evidence: `src/Exec/Client.cpp`)
- Client Connection → Redirect Handling: applies redirect
- Client Connection → CGI Execution: runs CGI
- CGI Execution → CGI Interpreter: invokes interpreter
- Client Connection → HTTP Responses: builds response
- HTTP Responses → Website Files: reads error pages
