# ad2486/raw-clang-crud architecture

> Architecture diagram of the GitHub repository ad2486/raw-clang-crud, 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/ad2486/raw-clang-crud
- Repository: https://github.com/ad2486/raw-clang-crud

## Overview

raw-crud is a C CRUD HTTP server for user records. A client request is accepted by the TCP server, queued to a worker, parsed as HTTP, routed to a user operation, and answered with JSON; SQLite persists the records. The graph separates connection handling, request/response protocol, CRUD routing, JSON conversion, concurrency, and persistence. README documents all five user endpoints; the sampled server code shows routing and module calls. External SQLite and cJSON are shown as dependencies; no other integrations are documented.

Main entry points: [`server.c`](https://github.com/ad2486/raw-clang-crud/blob/main/server.c) (TCP server and router), [`http.c`](https://github.com/ad2486/raw-clang-crud/blob/main/http.c) (HTTP parser and responder), [`db.c`](https://github.com/ad2486/raw-clang-crud/blob/main/db.c) (User persistence), [`json.c`](https://github.com/ad2486/raw-clang-crud/blob/main/json.c) (User JSON conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_connections["TCP connections"]
  node_server["TCP server and router<br/>[server.c]"]
end

subgraph group_requests["HTTP protocol"]
  node_http["HTTP parser and responder<br/>[http.c]"]
end

subgraph group_crud["User CRUD"]
end

subgraph group_conversion["JSON conversion"]
  node_user_json["User JSON conversion<br/>[json.c]"]
  node_cjson["cJSON parser"]
end

subgraph group_concurrency["Worker pool"]
  node_pool["Thread pool<br/>[pool.c]"]
end

subgraph group_persistence["SQLite persistence"]
  node_db_layer["User persistence<br/>[db.c]"]
  node_sqlite[("SQLite database")]
end

node_client(("HTTP client"))

node_client -->|"opens connection"| node_server
node_server -->|"enqueues client"| node_pool
node_pool -->|"dispatches handler"| node_server
node_server -->|"reads request"| node_http
node_server -->|"opens database"| node_db_layer
node_server -->|"runs CRUD"| node_db_layer
node_server -->|"parses and serializes"| node_user_json
node_user_json -->|"parses input"| node_cjson
node_server -->|"sends responses"| node_http
node_db_layer -->|"reads and writes"| node_sqlite
node_http -->|"returns response"| node_client

click node_server "https://github.com/ad2486/raw-clang-crud/blob/main/server.c"
click node_http "https://github.com/ad2486/raw-clang-crud/blob/main/http.c"
click node_user_json "https://github.com/ad2486/raw-clang-crud/blob/main/json.c"
click node_pool "https://github.com/ad2486/raw-clang-crud/blob/main/pool.c"
click node_db_layer "https://github.com/ad2486/raw-clang-crud/blob/main/db.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_server,node_client toneBlue
class node_http toneAmber
class node_user_json,node_cjson toneRose
class node_pool toneIndigo
class node_db_layer,node_sqlite toneTeal
```

## Components

### TCP connections

- [TCP server and router](https://github.com/ad2486/raw-clang-crud/blob/main/server.c): `server.c`

### HTTP protocol

- [HTTP parser and responder](https://github.com/ad2486/raw-clang-crud/blob/main/http.c): `http.c`

### JSON conversion

- [User JSON conversion](https://github.com/ad2486/raw-clang-crud/blob/main/json.c): `json.c`
- **cJSON parser**

### Worker pool

- [Thread pool](https://github.com/ad2486/raw-clang-crud/blob/main/pool.c): `pool.c`

### SQLite persistence

- [User persistence](https://github.com/ad2486/raw-clang-crud/blob/main/db.c): `db.c`
- **SQLite database**

### Other components

- **HTTP client**

## Connections

- HTTP client → TCP server and router: opens connection (evidence: `README.md`)
- TCP server and router → Thread pool: enqueues client (evidence: `server.c`)
- Thread pool → TCP server and router: dispatches handler (evidence: `pool.c`)
- TCP server and router → HTTP parser and responder: reads request (evidence: `server.c`)
- TCP server and router → User persistence: opens database (evidence: `server.c`)
- TCP server and router → User persistence: runs CRUD (evidence: `server.c`)
- TCP server and router → User JSON conversion: parses and serializes (evidence: `server.c`)
- User JSON conversion → cJSON parser: parses input (evidence: `json.c`)
- TCP server and router → HTTP parser and responder: sends responses (evidence: `server.c`)
- User persistence → SQLite database: reads and writes (evidence: `db.c`)
- HTTP parser and responder → HTTP client: returns response (evidence: `http.c`)
