# biraj21/http-server-in-c architecture

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

- Interactive diagram: https://gitdiagram.com/biraj21/http-server-in-c
- Repository: https://github.com/biraj21/http-server-in-c

## Overview

This repository is a small, single-file HTTP/1.1 server. A client sends a request to the listening server; each accepted connection is handled on a worker thread, which parses the request and dispatches it to simple routes or file operations before sending a response. The excerpt shows root and echo responses, file download/upload handling, and a growable-string helper. The source is partial, so details of omitted code and additional route behavior are not inferred.

Main entry points: [`src/server.c`](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c) (Connection worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["HTTP server"]
  node_listener["TCP listener<br/>[server.c]"]
  node_worker["Connection worker<br/>[server.c]"]
end

subgraph group_handling["Request handling"]
  node_parser["Request parsing<br/>[server.c]"]
  node_routes["Route responses<br/>[server.c]"]
  node_file_ops["File operations<br/>[server.c]"]
  node_public_files[("Public file store")]
  node_bstring["Growable strings<br/>[server.c]"]
end

node_client(("HTTP client"))

node_client -->|"sends HTTP"| node_listener
node_listener -->|"dispatches connections"| node_worker
node_worker -->|"parses request"| node_parser
node_worker -->|"dispatches routes"| node_routes
node_routes -->|"handles file paths"| node_file_ops
node_file_ops -->|"reads and writes"| node_public_files
node_worker -->|"builds request data"| node_bstring
node_file_ops -->|"builds paths and responses"| node_bstring

click node_listener "https://github.com/biraj21/http-server-in-c/blob/main/src/server.c"
click node_worker "https://github.com/biraj21/http-server-in-c/blob/main/src/server.c"
click node_parser "https://github.com/biraj21/http-server-in-c/blob/main/src/server.c"
click node_routes "https://github.com/biraj21/http-server-in-c/blob/main/src/server.c"
click node_file_ops "https://github.com/biraj21/http-server-in-c/blob/main/src/server.c"
click node_bstring "https://github.com/biraj21/http-server-in-c/blob/main/src/server.c"

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_listener,node_worker,node_client toneBlue
class node_parser,node_routes,node_file_ops,node_public_files,node_bstring toneAmber
```

## Components

### HTTP server

- [TCP listener](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c): `src/server.c`
- [Connection worker](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c): `src/server.c`

### Request handling

- [Request parsing](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c): `src/server.c`
- [Route responses](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c): `src/server.c`
- [File operations](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c): `src/server.c`
- **Public file store**
- [Growable strings](https://github.com/biraj21/http-server-in-c/blob/main/src/server.c): `src/server.c`

### Other components

- **HTTP client**

## Connections

- HTTP client → TCP listener: sends HTTP (evidence: `README.md`)
- TCP listener → Connection worker: dispatches connections (evidence: `src/server.c`)
- Connection worker → Request parsing: parses request (evidence: `src/server.c`)
- Connection worker → Route responses: dispatches routes (evidence: `src/server.c`)
- Route responses → File operations: handles file paths (evidence: `src/server.c`)
- File operations → Public file store: reads and writes (evidence: `src/server.c`)
- Connection worker → Growable strings: builds request data (evidence: `src/server.c`)
- File operations → Growable strings: builds paths and responses (evidence: `src/server.c`)
