# yosskavo/webserv architecture

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

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

## Overview

Webserv is a non-blocking HTTP/1.1 server configured with NGINX-style files. The principal workflow is: a browser sends a request; the server loads configuration, parses and routes the request, then serves a file, performs a mutation, or invokes CGI before returning an HTTP response. The graph also preserves documented uploads, auto-indexing, cookies, custom errors and the test dashboard. Runtime wiring beyond the excerpts is limited; documented capability links cite the README rather than implying that unsampled implementation details were inspected.

Main entry points: [`server/Server_response.cpp`](https://github.com/yosskavo/webserv/blob/main/server/Server_response.cpp) (Response building), [`server/Server_route.cpp`](https://github.com/yosskavo/webserv/blob/main/server/Server_route.cpp) (Virtual-host routing), [`server/Server_static.cpp`](https://github.com/yosskavo/webserv/blob/main/server/Server_static.cpp) (Static files), [`server/Server_cgi.cpp`](https://github.com/yosskavo/webserv/blob/main/server/Server_cgi.cpp) (CGI process handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Startup and configuration"]
  node_main["Server entry<br/>[main.cpp]"]
  node_config["Config parser<br/>[parce.cpp]"]
  node_configfile["Server configuration<br/>[site.conf]"]
end

subgraph group_http["HTTP server"]
  node_listener["Poll and sockets<br/>[Server_core.cpp]"]
  node_request["Request parsing<br/>[headers.cpp]"]
  node_cookies["Cookie parsing<br/>[cookies.cpp]"]
  node_routing["Virtual-host routing<br/>[Server_route.cpp]"]
  node_response["Response building"]
end

subgraph group_content["Content and execution"]
  node_static["Static files<br/>[Server_static.cpp]"]
  node_index["Directory indexing<br/>[Server_static.cpp]"]
  node_modify["POST and DELETE<br/>[Server_modify.cpp]"]
  node_filesystem[("Site and uploads")]
  node_cgi["CGI process handling<br/>[Server_cgi.cpp]"]
  node_cgiheaders["CGI output parsing<br/>[cgi.cpp]"]
  node_scripts["Python and PHP scripts"]
  node_errors["Error pages"]
end

subgraph group_experience["Browser and sessions"]
  node_dashboard["Test dashboard<br/>[index.html]"]
  node_session["Cookie session UI<br/>[cookies.js]"]
end

node_browser(("Browser"))

node_browser -->|"opens"| node_dashboard
node_dashboard -->|"sends requests"| node_browser
node_main -->|"parses config"| node_config
node_configfile -->|"provides directives"| node_config
node_main -->|"starts server"| node_listener
node_browser -->|"sends HTTP"| node_listener
node_listener -.->|"reads request"| node_request
node_request -->|"parses cookies"| node_cookies
node_request -.->|"routes request"| node_routing
node_routing -->|"serves GET"| node_static
node_routing -->|"dispatches methods"| node_modify
node_static -->|"reads files"| node_filesystem
node_static -->|"generates listings"| node_index
node_modify -->|"uploads or deletes"| node_filesystem
node_routing -->|"dispatches CGI"| node_cgi
node_cgi -->|"executes scripts"| node_scripts
node_cgi -->|"parses output"| node_cgiheaders
node_static -.->|"builds response"| node_response
node_modify -.->|"builds response"| node_response
node_cgi -->|"builds response"| node_response
node_response -->|"uses custom errors"| node_errors
node_response -.->|"returns HTTP"| node_browser
node_cookies -->|"supports sessions"| node_session

click node_main "https://github.com/yosskavo/webserv/blob/main/main.cpp"
click node_config "https://github.com/yosskavo/webserv/blob/main/parce/file/parce.cpp"
click node_configfile "https://github.com/yosskavo/webserv/blob/main/config/site.conf"
click node_listener "https://github.com/yosskavo/webserv/blob/main/server/Server_core.cpp"
click node_request "https://github.com/yosskavo/webserv/blob/main/parce/request/headers.cpp"
click node_cookies "https://github.com/yosskavo/webserv/blob/main/parce/request/cookies.cpp"
click node_routing "https://github.com/yosskavo/webserv/blob/main/server/Server_route.cpp"
click node_response "https://github.com/yosskavo/webserv/blob/main/server/Server_response.cpp"
click node_static "https://github.com/yosskavo/webserv/blob/main/server/Server_static.cpp"
click node_index "https://github.com/yosskavo/webserv/blob/main/server/Server_static.cpp"
click node_modify "https://github.com/yosskavo/webserv/blob/main/server/Server_modify.cpp"
click node_filesystem "https://github.com/yosskavo/webserv/tree/main/site"
click node_cgi "https://github.com/yosskavo/webserv/blob/main/server/Server_cgi.cpp"
click node_cgiheaders "https://github.com/yosskavo/webserv/blob/main/parce/cgi/cgi.cpp"
click node_scripts "https://github.com/yosskavo/webserv/tree/main/site/cgi"
click node_errors "https://github.com/yosskavo/webserv/tree/main/site/errors"
click node_dashboard "https://github.com/yosskavo/webserv/blob/main/site/index.html"
click node_session "https://github.com/yosskavo/webserv/blob/main/site/cookies.js"

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_main,node_config,node_configfile,node_browser toneBlue
class node_listener,node_request,node_cookies,node_routing,node_response toneAmber
class node_static,node_index,node_modify,node_filesystem,node_cgi,node_cgiheaders,node_scripts,node_errors toneMint
class node_dashboard,node_session toneRose
```

## Components

### Startup and configuration

- [Server entry](https://github.com/yosskavo/webserv/blob/main/main.cpp): `main.cpp`
- [Config parser](https://github.com/yosskavo/webserv/blob/main/parce/file/parce.cpp): `parce/file/parce.cpp`
- [Server configuration](https://github.com/yosskavo/webserv/blob/main/config/site.conf): `config/site.conf`

### HTTP server

- [Poll and sockets](https://github.com/yosskavo/webserv/blob/main/server/Server_core.cpp): `server/Server_core.cpp`
- [Request parsing](https://github.com/yosskavo/webserv/blob/main/parce/request/headers.cpp): `parce/request/headers.cpp`
- [Cookie parsing](https://github.com/yosskavo/webserv/blob/main/parce/request/cookies.cpp): `parce/request/cookies.cpp`
- [Virtual-host routing](https://github.com/yosskavo/webserv/blob/main/server/Server_route.cpp): `server/Server_route.cpp`
- [Response building](https://github.com/yosskavo/webserv/blob/main/server/Server_response.cpp): `server/Server_response.cpp`

### Content and execution

- [Static files](https://github.com/yosskavo/webserv/blob/main/server/Server_static.cpp): `server/Server_static.cpp`
- [Directory indexing](https://github.com/yosskavo/webserv/blob/main/server/Server_static.cpp): `server/Server_static.cpp`
- [POST and DELETE](https://github.com/yosskavo/webserv/blob/main/server/Server_modify.cpp): `server/Server_modify.cpp`
- [Site and uploads](https://github.com/yosskavo/webserv/tree/main/site): `site`
- [CGI process handling](https://github.com/yosskavo/webserv/blob/main/server/Server_cgi.cpp): `server/Server_cgi.cpp`
- [CGI output parsing](https://github.com/yosskavo/webserv/blob/main/parce/cgi/cgi.cpp): `parce/cgi/cgi.cpp`
- [Python and PHP scripts](https://github.com/yosskavo/webserv/tree/main/site/cgi): `site/cgi`
- [Error pages](https://github.com/yosskavo/webserv/tree/main/site/errors): `site/errors`

### Browser and sessions

- [Test dashboard](https://github.com/yosskavo/webserv/blob/main/site/index.html): `site/index.html`
- [Cookie session UI](https://github.com/yosskavo/webserv/blob/main/site/cookies.js): `site/cookies.js`

### Other components

- **Browser**

## Connections

- Browser → Test dashboard: opens (evidence: `README.md`)
- Test dashboard → Browser: sends requests (evidence: `README.md`)
- Server entry → Config parser: parses config (evidence: `main.cpp`)
- Server configuration → Config parser: provides directives (evidence: `README.md`)
- Server entry → Poll and sockets: starts server (evidence: `main.cpp`)
- Browser → Poll and sockets: sends HTTP (evidence: `README.md`)
- Poll and sockets → Request parsing: reads request
- Request parsing → Cookie parsing: parses cookies (evidence: `parce/request/headers.cpp`)
- Request parsing → Virtual-host routing: routes request
- Virtual-host routing → Static files: serves GET (evidence: `README.md`)
- Virtual-host routing → POST and DELETE: dispatches methods (evidence: `README.md`)
- Static files → Site and uploads: reads files (evidence: `README.md`)
- Static files → Directory indexing: generates listings (evidence: `README.md`)
- POST and DELETE → Site and uploads: uploads or deletes (evidence: `README.md`)
- Virtual-host routing → CGI process handling: dispatches CGI (evidence: `README.md`)
- CGI process handling → Python and PHP scripts: executes scripts (evidence: `server/Server_cgi.cpp`)
- CGI process handling → CGI output parsing: parses output (evidence: `parce/cgi/cgi.cpp`)
- Static files → Response building: builds response
- POST and DELETE → Response building: builds response
- CGI process handling → Response building: builds response (evidence: `server/Server_cgi.cpp`)
- Response building → Error pages: uses custom errors (evidence: `README.md`)
- Response building → Browser: returns HTTP
- Cookie parsing → Cookie session UI: supports sessions (evidence: `README.md`)
