# q-fis/forgedb architecture

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

- Interactive diagram: https://gitdiagram.com/q-fis/forgedb
- Repository: https://github.com/q-fis/forgedb

## Overview

ForgeDB is a small HTTP/JSON search database. Its intended workflow is a client submitting text chunks and embeddings, the server parsing and routing requests to the API, and the API using the Engine to store data or search by vector, keyword, or hybrid ranking. Persistence, concurrency, security, and load generation are additional product capabilities. The repository currently contains many contract headers and placeholder implementations; relationships beyond those headers and the README are therefore shown only where documented.

Main entry points: [`apps/forgedb.cpp`](https://github.com/q-fis/forgedb/blob/main/apps/forgedb.cpp) (ForgeDB server), [`src/conn/stub_server.cpp`](https://github.com/q-fis/forgedb/blob/main/src/conn/stub_server.cpp) (Connection server), [`src/pool/stub_engine.cpp`](https://github.com/q-fis/forgedb/blob/main/src/pool/stub_engine.cpp) (Engine), [`src/app/stub_api.cpp`](https://github.com/q-fis/forgedb/blob/main/src/app/stub_api.cpp) (JSON API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_forge_cli["Forge CLI<br/>[forge.cpp]"]
  node_python_client["Python client"]
  node_loadgen["Load generator<br/>[forge_load.cpp]"]
  node_client_lib["C++ client<br/>[stub_client.cpp]"]
end

subgraph group_request["Request handling"]
  node_forgedb["ForgeDB server<br/>[forgedb.cpp]"]
  node_config["Server config<br/>[app.hpp]"]
  node_http_parser["HTTP parser<br/>[stub_parser.cpp]"]
  node_http_router["HTTP router<br/>[stub_router.cpp]"]
  node_http_response["HTTP responses<br/>[stub_response.cpp]"]
  node_connection_server["Connection server<br/>[stub_server.cpp]"]
  node_socket_io["Socket I/O<br/>[stub_socket.cpp]"]
  node_api["JSON API<br/>[stub_api.cpp]"]
end

subgraph group_search["Search and storage"]
  node_engine["Engine<br/>[stub_engine.cpp]"]
  node_vector_index["Vector search"]
  node_keyword_index["Keyword search"]
  node_hybrid_rank["Hybrid ranking<br/>[stub_rrf.cpp]"]
  node_store[("Chunk store")]
  node_snapshots["Snapshots<br/>[stub_snapshot.cpp]"]
  node_wal[("Write-ahead log<br/>[wal.hpp]")]
end

subgraph group_operations["Operations"]
  node_executor["Executor<br/>[executor.hpp]"]
  node_thread_pool["Thread pool"]
  node_security["Security controls"]
  node_fake_server["Fake server<br/>[fake_server.py]"]
end

node_user(("Client / RAG"))

node_user -->|"issues commands"| node_forge_cli
node_user -->|"uses API"| node_python_client
node_user -->|"generates load"| node_loadgen
node_forge_cli -->|"sends HTTP/JSON"| node_forgedb
node_python_client -->|"sends HTTP/JSON"| node_forgedb
node_loadgen -->|"loads server"| node_forgedb
node_forgedb -->|"reads settings"| node_config
node_forgedb -->|"starts server"| node_connection_server
node_connection_server -->|"accepts connections"| node_socket_io
node_connection_server -->|"parses requests"| node_http_parser
node_connection_server -->|"dispatches work"| node_executor
node_connection_server -->|"invokes handler"| node_api
node_api -->|"routes endpoints"| node_http_router
node_api -->|"returns responses"| node_http_response
node_api -->|"calls operations"| node_engine
node_executor -.->|"runs tasks"| node_thread_pool
node_engine -->|"keeps rows"| node_store
node_engine -->|"updates and searches"| node_vector_index
node_engine -->|"updates and searches"| node_keyword_index
node_engine -.->|"persists writes"| node_wal
node_store -.->|"snapshots data"| node_snapshots
node_vector_index -->|"parallelizes search"| node_executor
node_keyword_index -->|"merges rankings"| node_hybrid_rank
node_forgedb -.->|"applies protections"| node_security
node_forge_cli -->|"uses client"| node_client_lib
node_user -->|"tests API locally"| node_fake_server

click node_forge_cli "https://github.com/q-fis/forgedb/blob/main/apps/forge.cpp"
click node_loadgen "https://github.com/q-fis/forgedb/blob/main/apps/forge_load.cpp"
click node_forgedb "https://github.com/q-fis/forgedb/blob/main/apps/forgedb.cpp"
click node_config "https://github.com/q-fis/forgedb/blob/main/include/forge/app.hpp"
click node_http_parser "https://github.com/q-fis/forgedb/blob/main/src/http/stub_parser.cpp"
click node_http_router "https://github.com/q-fis/forgedb/blob/main/src/http/stub_router.cpp"
click node_http_response "https://github.com/q-fis/forgedb/blob/main/src/http/stub_response.cpp"
click node_connection_server "https://github.com/q-fis/forgedb/blob/main/src/conn/stub_server.cpp"
click node_socket_io "https://github.com/q-fis/forgedb/blob/main/src/conn/stub_socket.cpp"
click node_api "https://github.com/q-fis/forgedb/blob/main/src/app/stub_api.cpp"
click node_executor "https://github.com/q-fis/forgedb/blob/main/include/forge/executor.hpp"
click node_thread_pool "https://github.com/q-fis/forgedb/blob/main/src/pool/stub_thread_pool.cpp"
click node_security "https://github.com/q-fis/forgedb/blob/main/src/sec/stub_rate_limiter.cpp"
click node_engine "https://github.com/q-fis/forgedb/blob/main/src/pool/stub_engine.cpp"
click node_vector_index "https://github.com/q-fis/forgedb/blob/main/src/vec/stub_flat_index.cpp"
click node_keyword_index "https://github.com/q-fis/forgedb/blob/main/src/kw/stub_keyword_index.cpp"
click node_hybrid_rank "https://github.com/q-fis/forgedb/blob/main/src/kw/stub_rrf.cpp"
click node_store "https://github.com/q-fis/forgedb/blob/main/src/snap/stub_memory_store.cpp"
click node_snapshots "https://github.com/q-fis/forgedb/blob/main/src/snap/stub_snapshot.cpp"
click node_wal "https://github.com/q-fis/forgedb/blob/main/include/forge/wal.hpp"
click node_client_lib "https://github.com/q-fis/forgedb/blob/main/src/cli/stub_client.cpp"
click node_fake_server "https://github.com/q-fis/forgedb/blob/main/tools/fake_server.py"

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_forge_cli,node_python_client,node_loadgen,node_client_lib,node_user toneBlue
class node_forgedb,node_config,node_http_parser,node_http_router,node_http_response,node_connection_server,node_socket_io,node_api toneAmber
class node_engine,node_vector_index,node_keyword_index,node_hybrid_rank,node_store,node_snapshots,node_wal toneMint
class node_executor,node_thread_pool,node_security,node_fake_server toneRose
```

## Components

### Clients

- [Forge CLI](https://github.com/q-fis/forgedb/blob/main/apps/forge.cpp): `apps/forge.cpp`
- **Python client**
- [Load generator](https://github.com/q-fis/forgedb/blob/main/apps/forge_load.cpp): `apps/forge_load.cpp`
- [C++ client](https://github.com/q-fis/forgedb/blob/main/src/cli/stub_client.cpp): `src/cli/stub_client.cpp`

### Request handling

- [ForgeDB server](https://github.com/q-fis/forgedb/blob/main/apps/forgedb.cpp): `apps/forgedb.cpp`
- [Server config](https://github.com/q-fis/forgedb/blob/main/include/forge/app.hpp): `include/forge/app.hpp`
- [HTTP parser](https://github.com/q-fis/forgedb/blob/main/src/http/stub_parser.cpp): `src/http/stub_parser.cpp`
- [HTTP router](https://github.com/q-fis/forgedb/blob/main/src/http/stub_router.cpp): `src/http/stub_router.cpp`
- [HTTP responses](https://github.com/q-fis/forgedb/blob/main/src/http/stub_response.cpp): `src/http/stub_response.cpp`
- [Connection server](https://github.com/q-fis/forgedb/blob/main/src/conn/stub_server.cpp): `src/conn/stub_server.cpp`
- [Socket I/O](https://github.com/q-fis/forgedb/blob/main/src/conn/stub_socket.cpp): `src/conn/stub_socket.cpp`
- [JSON API](https://github.com/q-fis/forgedb/blob/main/src/app/stub_api.cpp): `src/app/stub_api.cpp`

### Search and storage

- [Engine](https://github.com/q-fis/forgedb/blob/main/src/pool/stub_engine.cpp): `src/pool/stub_engine.cpp`
- [Vector search](https://github.com/q-fis/forgedb/blob/main/src/vec/stub_flat_index.cpp): `src/vec/stub_flat_index.cpp`
- [Keyword search](https://github.com/q-fis/forgedb/blob/main/src/kw/stub_keyword_index.cpp): `src/kw/stub_keyword_index.cpp`
- [Hybrid ranking](https://github.com/q-fis/forgedb/blob/main/src/kw/stub_rrf.cpp): `src/kw/stub_rrf.cpp`
- [Chunk store](https://github.com/q-fis/forgedb/blob/main/src/snap/stub_memory_store.cpp): `src/snap/stub_memory_store.cpp`
- [Snapshots](https://github.com/q-fis/forgedb/blob/main/src/snap/stub_snapshot.cpp): `src/snap/stub_snapshot.cpp`
- [Write-ahead log](https://github.com/q-fis/forgedb/blob/main/include/forge/wal.hpp): `include/forge/wal.hpp`

### Operations

- [Executor](https://github.com/q-fis/forgedb/blob/main/include/forge/executor.hpp): `include/forge/executor.hpp`
- [Thread pool](https://github.com/q-fis/forgedb/blob/main/src/pool/stub_thread_pool.cpp): `src/pool/stub_thread_pool.cpp`
- [Security controls](https://github.com/q-fis/forgedb/blob/main/src/sec/stub_rate_limiter.cpp): `src/sec/stub_rate_limiter.cpp`
- [Fake server](https://github.com/q-fis/forgedb/blob/main/tools/fake_server.py): `tools/fake_server.py`

### Other components

- **Client / RAG**

## Connections

- Client / RAG → Forge CLI: issues commands (evidence: `README.md`)
- Client / RAG → Python client: uses API (evidence: `README.md`)
- Client / RAG → Load generator: generates load (evidence: `README.md`)
- Forge CLI → ForgeDB server: sends HTTP/JSON (evidence: `README.md`)
- Python client → ForgeDB server: sends HTTP/JSON (evidence: `README.md`)
- Load generator → ForgeDB server: loads server (evidence: `README.md`)
- ForgeDB server → Server config: reads settings (evidence: `include/forge/app.hpp`)
- ForgeDB server → Connection server: starts server (evidence: `README.md`)
- Connection server → Socket I/O: accepts connections (evidence: `README.md`)
- Connection server → HTTP parser: parses requests
- Connection server → Executor: dispatches work
- Connection server → JSON API: invokes handler
- JSON API → HTTP router: routes endpoints
- JSON API → HTTP responses: returns responses
- JSON API → Engine: calls operations
- Executor → Thread pool: runs tasks
- Engine → Chunk store: keeps rows
- Engine → Vector search: updates and searches
- Engine → Keyword search: updates and searches
- Engine → Write-ahead log: persists writes (evidence: `README.md`)
- Chunk store → Snapshots: snapshots data (evidence: `README.md`)
- Vector search → Executor: parallelizes search
- Keyword search → Hybrid ranking: merges rankings
- ForgeDB server → Security controls: applies protections (evidence: `README.md`)
- Forge CLI → C++ client: uses client (evidence: `src/cli/stub_client.cpp`)
- Client / RAG → Fake server: tests API locally (evidence: `README.md`)
