# barabol/crest architecture

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

- Interactive diagram: https://gitdiagram.com/barabol/crest
- Repository: https://github.com/barabol/crest

## Overview

Crest is a small C REST API framework: an application registers method-and-path handlers, starts the server, and each client request is parsed and dispatched to a callback that returns a response. The framework also exposes path/query/header/cookie access and response-header/cookie helpers, plus in-memory user-defined sessions. The excerpts show the request callback and response-send path; some parser and startup details are omitted, so the graph leaves uncertain internal wiring out.

Main entry points: [`crest.c`](https://github.com/barabol/crest/blob/main/crest.c) (Request dispatch), [`crest.h`](https://github.com/barabol/crest/blob/main/crest.h) (Request fields)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["HTTP server"]
  node_startup["Server startup<br/>[crest.c]"]
  node_listener["Socket and workers<br/>[crest.c]"]
  node_dispatch["Request dispatch<br/>[crest.c]"]
end

subgraph group_routing["Endpoint routing"]
  node_registration["Handler registration<br/>[crest.c]"]
  node_route_table[("Route and method tables<br/>[crest.c]")]
end

subgraph group_httpdata["Request and response"]
  node_request_parse["Request parsing<br/>[crest.c]"]
  node_request_data["Request fields<br/>[crest.h]"]
  node_request_access["Request accessors<br/>[crest.c]"]
  node_response_build["Response helpers<br/>[crest.c]"]
  node_response_data["Response fields<br/>[crest.h]"]
  node_response_send["Response serialization<br/>[crest.c]"]
end

subgraph group_sessions["Session state"]
  node_session_api["Session API<br/>[crest.c]"]
  node_session_store[("Session store<br/>[crest.c]")]
end

node_client(("HTTP client"))
node_handler["Application handler"]

node_client -->|"connects"| node_listener
node_startup -->|"starts"| node_listener
node_listener -->|"receives request"| node_request_parse
node_request_parse -->|"populates"| node_request_data
node_request_parse -->|"dispatches"| node_dispatch
node_registration -->|"registers routes"| node_route_table
node_dispatch -->|"looks up route"| node_route_table
node_dispatch -->|"invokes"| node_handler
node_dispatch -->|"passes request"| node_request_data
node_handler -->|"reads request"| node_request_access
node_request_access -->|"reads fields"| node_request_data
node_handler -->|"builds response"| node_response_build
node_response_build -->|"creates"| node_response_data
node_handler -->|"uses sessions"| node_session_api
node_session_api -->|"reads or writes"| node_session_store
node_dispatch -->|"sends response"| node_response_send
node_response_send -->|"serializes"| node_response_data
node_response_send -->|"returns HTTP response"| node_client

click node_startup "https://github.com/barabol/crest/blob/main/crest.c"
click node_listener "https://github.com/barabol/crest/blob/main/crest.c"
click node_dispatch "https://github.com/barabol/crest/blob/main/crest.c"
click node_registration "https://github.com/barabol/crest/blob/main/crest.c"
click node_route_table "https://github.com/barabol/crest/blob/main/crest.c"
click node_request_parse "https://github.com/barabol/crest/blob/main/crest.c"
click node_request_data "https://github.com/barabol/crest/blob/main/crest.h"
click node_request_access "https://github.com/barabol/crest/blob/main/crest.c"
click node_response_build "https://github.com/barabol/crest/blob/main/crest.c"
click node_response_data "https://github.com/barabol/crest/blob/main/crest.h"
click node_response_send "https://github.com/barabol/crest/blob/main/crest.c"
click node_session_api "https://github.com/barabol/crest/blob/main/crest.c"
click node_session_store "https://github.com/barabol/crest/blob/main/crest.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_startup,node_listener,node_dispatch,node_client toneBlue
class node_registration,node_route_table toneAmber
class node_request_parse,node_request_data,node_request_access,node_response_build,node_response_data,node_response_send,node_handler toneMint
class node_session_api,node_session_store toneRose
```

## Components

### HTTP server

- [Server startup](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Socket and workers](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Request dispatch](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`

### Endpoint routing

- [Handler registration](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Route and method tables](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`

### Request and response

- [Request parsing](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Request fields](https://github.com/barabol/crest/blob/main/crest.h): `crest.h`
- [Request accessors](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Response helpers](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Response fields](https://github.com/barabol/crest/blob/main/crest.h): `crest.h`
- [Response serialization](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`

### Session state

- [Session API](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`
- [Session store](https://github.com/barabol/crest/blob/main/crest.c): `crest.c`

### Other components

- **HTTP client**
- **Application handler**

## Connections

- HTTP client → Socket and workers: connects
- Server startup → Socket and workers: starts
- Socket and workers → Request parsing: receives request
- Request parsing → Request fields: populates
- Request parsing → Request dispatch: dispatches
- Handler registration → Route and method tables: registers routes
- Request dispatch → Route and method tables: looks up route
- Request dispatch → Application handler: invokes
- Request dispatch → Request fields: passes request
- Application handler → Request accessors: reads request
- Request accessors → Request fields: reads fields
- Application handler → Response helpers: builds response
- Response helpers → Response fields: creates
- Application handler → Session API: uses sessions
- Session API → Session store: reads or writes
- Request dispatch → Response serialization: sends response
- Response serialization → Response fields: serializes
- Response serialization → HTTP client: returns HTTP response
