# renatoa2508/minihttpd architecture

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

- Interactive diagram: https://gitdiagram.com/renatoa2508/minihttpd
- Repository: https://github.com/renatoa2508/minihttpd

## Overview

minihttpd is a small concurrent HTTP/1.1 GET server. A browser sends requests to the epoll-driven connection loop, which parses requests, resolves files under www, selects response metadata and MIME type, and sends headers and file bytes. The README documents persistent connections and status handling; source excerpts establish the main dispatch and helper calls. www contains the served client assets. The UI assets are not shown as explicitly linked, and unsampled response-body details are omitted.

Main entry points: [`src/main.c`](https://github.com/renatoa2508/minihttpd/blob/main/src/main.c) (Epoll connection loop), [`src/files.c`](https://github.com/renatoa2508/minihttpd/blob/main/src/files.c) (File lookup), [`src/server.c`](https://github.com/renatoa2508/minihttpd/blob/main/src/server.c) (TCP listener), [`src/http.c`](https://github.com/renatoa2508/minihttpd/blob/main/src/http.c) (Request parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_eventloop["Epoll connection loop<br/>[main.c]"]
  node_listener["TCP listener<br/>[server.c]"]
end

subgraph group_http["HTTP processing"]
  node_parser["Request parser<br/>[http.c]"]
  node_response["Response headers<br/>[http.c]"]
end

subgraph group_content["Static content"]
  node_file_lookup["File lookup<br/>[files.c]"]
  node_mime["MIME detection<br/>[mime.c]"]
  node_www_assets["Web assets<br/>[index.html]"]
  node_app_js["Browser script<br/>[app.js]"]
  node_styles["Web stylesheet<br/>[style.css]"]
end

node_browser(("Browser client"))

node_browser -->|"sends requests"| node_listener
node_eventloop -->|"creates listener"| node_listener
node_eventloop -->|"parses requests"| node_parser
node_eventloop -->|"requests files"| node_file_lookup
node_eventloop -->|"generates headers"| node_response
node_eventloop -->|"selects MIME"| node_mime
node_file_lookup -->|"reads served files"| node_www_assets
node_eventloop -->|"sends response"| node_browser
node_browser -.->|"loads script"| node_app_js
node_browser -.->|"loads stylesheet"| node_styles

click node_eventloop "https://github.com/renatoa2508/minihttpd/blob/main/src/main.c"
click node_listener "https://github.com/renatoa2508/minihttpd/blob/main/src/server.c"
click node_parser "https://github.com/renatoa2508/minihttpd/blob/main/src/http.c"
click node_response "https://github.com/renatoa2508/minihttpd/blob/main/src/http.c"
click node_file_lookup "https://github.com/renatoa2508/minihttpd/blob/main/src/files.c"
click node_mime "https://github.com/renatoa2508/minihttpd/blob/main/src/mime.c"
click node_www_assets "https://github.com/renatoa2508/minihttpd/blob/main/www/index.html"
click node_app_js "https://github.com/renatoa2508/minihttpd/blob/main/www/app.js"
click node_styles "https://github.com/renatoa2508/minihttpd/blob/main/www/style.css"

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_eventloop,node_listener,node_browser toneBlue
class node_parser,node_response toneAmber
class node_file_lookup,node_mime,node_www_assets,node_app_js,node_styles toneMint
```

## Components

### Server runtime

- [Epoll connection loop](https://github.com/renatoa2508/minihttpd/blob/main/src/main.c): `src/main.c`
- [TCP listener](https://github.com/renatoa2508/minihttpd/blob/main/src/server.c): `src/server.c`

### HTTP processing

- [Request parser](https://github.com/renatoa2508/minihttpd/blob/main/src/http.c): `src/http.c`
- [Response headers](https://github.com/renatoa2508/minihttpd/blob/main/src/http.c): `src/http.c`

### Static content

- [File lookup](https://github.com/renatoa2508/minihttpd/blob/main/src/files.c): `src/files.c`
- [MIME detection](https://github.com/renatoa2508/minihttpd/blob/main/src/mime.c): `src/mime.c`
- [Web assets](https://github.com/renatoa2508/minihttpd/blob/main/www/index.html): `www/index.html`
- [Browser script](https://github.com/renatoa2508/minihttpd/blob/main/www/app.js): `www/app.js`
- [Web stylesheet](https://github.com/renatoa2508/minihttpd/blob/main/www/style.css): `www/style.css`

### Other components

- **Browser client**

## Connections

- Browser client → TCP listener: sends requests (evidence: `README.md`)
- Epoll connection loop → TCP listener: creates listener (evidence: `src/main.c`)
- Epoll connection loop → Request parser: parses requests (evidence: `src/main.c`)
- Epoll connection loop → File lookup: requests files (evidence: `src/main.c`)
- Epoll connection loop → Response headers: generates headers (evidence: `src/main.c`)
- Epoll connection loop → MIME detection: selects MIME (evidence: `src/main.c`)
- File lookup → Web assets: reads served files (evidence: `src/files.c`)
- Epoll connection loop → Browser client: sends response (evidence: `src/main.c`)
- Browser client → Browser script: loads script
- Browser client → Web stylesheet: loads stylesheet
