# yemreaycicek/webserv architecture

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

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

## Overview

webserv is a non-blocking HTTP/1.1 server. Its principal workflow is: load and parse configuration, create listening sockets, accept clients, parse requests, select server/location behavior, then return an HTTP response or run CGI. The README documents static files, directory listings, uploads, redirects, error pages, and body limits as additional request-handling capabilities. Source excerpts show the main wiring and CGI streaming; several runtime implementation details are unsampled, so those links are omitted or marked unverified.

Main entry points: [`src/exec/Server.cpp`](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Server.cpp) (Server coordinator), [`src/exec/Executor.cpp`](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Executor.cpp) (Request executor), [`src/config/Lexer.cpp`](https://github.com/yemreaycicek/webserv/blob/main/src/config/Lexer.cpp) (Config lexer), [`src/config/Parser.cpp`](https://github.com/yemreaycicek/webserv/blob/main/src/config/Parser.cpp) (Config parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Configuration"]
  node_arguments["Config arguments<br/>[arg.cpp]"]
  node_lexer["Config lexer<br/>[Lexer.cpp]"]
  node_parser["Config parser<br/>[Parser.cpp]"]
  node_router["Server router<br/>[Router.cpp]"]
end

subgraph group_http["HTTP Model"]
  node_request["HTTP request<br/>[Request.cpp]"]
end

subgraph group_runtime["Event Runtime"]
  node_connection["Client connection<br/>[Connection.cpp]"]
  node_poller["Poll event loop<br/>[Poller.cpp]"]
  node_server["Server coordinator<br/>[Server.cpp]"]
end

subgraph group_handling["Request Handling"]
  node_executor["Request executor<br/>[Executor.cpp]"]
  node_resolver["Path resolver<br/>[Resolver.cpp]"]
  node_responses["Response builder"]
  node_cgi["CGI process<br/>[Cgi.cpp]"]
end

subgraph group_network["Networking"]
  node_listen["Listening sockets<br/>[ListenSocket.cpp]"]
  node_socket["Socket primitives<br/>[Socket.cpp]"]
end

node_client(("HTTP client"))

node_client -->|"sends requests"| node_server
node_arguments -->|"provides config"| node_lexer
node_lexer -->|"tokenizes for"| node_parser
node_parser -->|"configures"| node_router
node_router -->|"configures"| node_server
node_server -->|"creates listeners"| node_listen
node_listen -->|"extends"| node_socket
node_server -->|"registers descriptors"| node_poller
node_server -->|"creates connections"| node_connection
node_connection -->|"parses input"| node_request
node_server -->|"executes requests"| node_executor
node_executor -.->|"resolves paths"| node_resolver
node_executor -.->|"builds responses"| node_responses
node_server -->|"starts and relays"| node_cgi
node_executor -.->|"identifies CGI requests"| node_cgi
node_server -->|"writes responses"| node_client

click node_arguments "https://github.com/yemreaycicek/webserv/blob/main/src/utils/arg.cpp"
click node_lexer "https://github.com/yemreaycicek/webserv/blob/main/src/config/Lexer.cpp"
click node_parser "https://github.com/yemreaycicek/webserv/blob/main/src/config/Parser.cpp"
click node_router "https://github.com/yemreaycicek/webserv/blob/main/src/config/Router.cpp"
click node_request "https://github.com/yemreaycicek/webserv/blob/main/src/http/Request.cpp"
click node_connection "https://github.com/yemreaycicek/webserv/blob/main/src/exec/Connection.cpp"
click node_poller "https://github.com/yemreaycicek/webserv/blob/main/src/exec/Poller.cpp"
click node_server "https://github.com/yemreaycicek/webserv/blob/main/src/exec/Server.cpp"
click node_executor "https://github.com/yemreaycicek/webserv/blob/main/src/exec/Executor.cpp"
click node_resolver "https://github.com/yemreaycicek/webserv/blob/main/src/exec/Resolver.cpp"
click node_responses "https://github.com/yemreaycicek/webserv/blob/main/src/exec/ResponseBuilder.cpp"
click node_cgi "https://github.com/yemreaycicek/webserv/blob/main/src/exec/Cgi.cpp"
click node_listen "https://github.com/yemreaycicek/webserv/blob/main/src/net/ListenSocket.cpp"
click node_socket "https://github.com/yemreaycicek/webserv/blob/main/src/net/Socket.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_arguments,node_lexer,node_parser,node_router,node_client toneBlue
class node_request toneAmber
class node_connection,node_poller,node_server toneMint
class node_executor,node_resolver,node_responses,node_cgi toneRose
class node_listen,node_socket toneIndigo
```

## Components

### Configuration

- [Config arguments](https://github.com/yemreaycicek/webserv/blob/main/src/utils/arg.cpp): `src/utils/arg.cpp`
- [Config lexer](https://github.com/yemreaycicek/webserv/blob/main/src/config/Lexer.cpp): `src/config/Lexer.cpp`
- [Config parser](https://github.com/yemreaycicek/webserv/blob/main/src/config/Parser.cpp): `src/config/Parser.cpp`
- [Server router](https://github.com/yemreaycicek/webserv/blob/main/src/config/Router.cpp): `src/config/Router.cpp`

### HTTP Model

- [HTTP request](https://github.com/yemreaycicek/webserv/blob/main/src/http/Request.cpp): `src/http/Request.cpp`

### Event Runtime

- [Client connection](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Connection.cpp): `src/exec/Connection.cpp`
- [Poll event loop](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Poller.cpp): `src/exec/Poller.cpp`
- [Server coordinator](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Server.cpp): `src/exec/Server.cpp`

### Request Handling

- [Request executor](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Executor.cpp): `src/exec/Executor.cpp`
- [Path resolver](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Resolver.cpp): `src/exec/Resolver.cpp`
- [Response builder](https://github.com/yemreaycicek/webserv/blob/main/src/exec/ResponseBuilder.cpp): `src/exec/ResponseBuilder.cpp`
- [CGI process](https://github.com/yemreaycicek/webserv/blob/main/src/exec/Cgi.cpp): `src/exec/Cgi.cpp`

### Networking

- [Listening sockets](https://github.com/yemreaycicek/webserv/blob/main/src/net/ListenSocket.cpp): `src/net/ListenSocket.cpp`
- [Socket primitives](https://github.com/yemreaycicek/webserv/blob/main/src/net/Socket.cpp): `src/net/Socket.cpp`

### Other components

- **HTTP client**

## Connections

- HTTP client → Server coordinator: sends requests
- Config arguments → Config lexer: provides config
- Config lexer → Config parser: tokenizes for
- Config parser → Server router: configures
- Server router → Server coordinator: configures
- Server coordinator → Listening sockets: creates listeners (evidence: `src/exec/Server.cpp`)
- Listening sockets → Socket primitives: extends
- Server coordinator → Poll event loop: registers descriptors (evidence: `src/exec/Server.cpp`)
- Server coordinator → Client connection: creates connections (evidence: `src/exec/Server.cpp`)
- Client connection → HTTP request: parses input
- Server coordinator → Request executor: executes requests (evidence: `src/exec/Server.cpp`)
- Request executor → Path resolver: resolves paths
- Request executor → Response builder: builds responses
- Server coordinator → CGI process: starts and relays (evidence: `src/exec/Server.cpp`)
- Request executor → CGI process: identifies CGI requests
- Server coordinator → HTTP client: writes responses
