# makr-code/themisdb architecture

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

- Interactive diagram: https://gitdiagram.com/makr-code/themisdb
- Repository: https://github.com/makr-code/themisdb

## Overview

ThemisDB is a multi-model database with native AI/LLM capabilities. A principal workflow is a client request entering the server API, being parsed and translated into a query, then optimized and executed against indexes and persistent storage before results are returned. Separate product branches cover ingestion, temporal queries, and managed LLM inference. The graph uses the supplied excerpts, SOURCE INDEX references, and README; unsampled capabilities are shown only where documented, and uncertain connections are omitted.

Main entry points: [`src/query/query_engine.cpp`](https://github.com/makr-code/themisdb/blob/develop/src/query/query_engine.cpp) (Query engine), [`src/server/query_api_handler.cpp`](https://github.com/makr-code/themisdb/blob/develop/src/server/query_api_handler.cpp) (Query API), [`include/storage/rocksdb_wrapper.h`](https://github.com/makr-code/themisdb/blob/develop/include/storage/rocksdb_wrapper.h) (RocksDB storage), [`include/query/aql_translator.h`](https://github.com/makr-code/themisdb/blob/develop/include/query/aql_translator.h) (AQL translator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api_query["API and query"]
  node_api["Query API"]
  node_auth["API authentication<br/>[auth_middleware.h]"]
  node_parser["AQL parser<br/>[aql_parser.h]"]
  node_translator["AQL translator<br/>[aql_translator.h]"]
  node_optimizer["Query optimizer<br/>[query_optimizer.h]"]
  node_query["Query engine<br/>[query_engine.cpp]"]
  node_request["Request context<br/>[request_context.h]"]
end

subgraph group_data["Data and ingestion"]
  node_secondary["Secondary indexes<br/>[secondary_index.h]"]
  node_graphindex["Graph index<br/>[graph_index.h]"]
  node_entities["Data entities<br/>[base_entity.h]"]
  node_storage[("RocksDB storage<br/>[rocksdb_wrapper.h]")]
  node_ingestion["Source ingestion"]
  node_async_content["Async content ingestion"]
  node_temporal["Temporal queries"]
end

subgraph group_ai["AI and retrieval"]
  node_llm["LLM plugin manager"]
  node_vllm["Inference resources"]
end

subgraph group_operations["Operations"]
  node_metrics["LLM metrics<br/>[grafana_metrics.h]"]
  node_logs["Log search"]
end

node_client(("Client"))

node_client -->|"sends query"| node_api
node_api -->|"checks access"| node_auth
node_api -->|"parses AQL"| node_parser
node_api -->|"executes query"| node_query
node_api -->|"builds context"| node_request
node_translator -->|"uses AST"| node_parser
node_translator -->|"translates for"| node_query
node_query -->|"optimizes plan"| node_optimizer
node_query -->|"parses queries"| node_parser
node_query -->|"translates queries"| node_translator
node_query -->|"uses indexes"| node_secondary
node_query -->|"uses indexes"| node_graphindex
node_query -->|"reads records"| node_storage
node_query -->|"deserializes records"| node_entities
node_secondary -->|"uses storage"| node_storage
node_graphindex -->|"uses storage"| node_storage
node_ingestion -.->|"loads data"| node_storage
node_async_content -.->|"processes content"| node_ingestion
node_temporal -.->|"queries versions"| node_storage
node_llm -.->|"dispatches inference"| node_vllm
node_llm -->|"reports metrics"| node_metrics

click node_api "https://github.com/makr-code/themisdb/blob/develop/src/server/query_api_handler.cpp"
click node_auth "https://github.com/makr-code/themisdb/blob/develop/include/server/auth_middleware.h"
click node_parser "https://github.com/makr-code/themisdb/blob/develop/include/query/aql_parser.h"
click node_translator "https://github.com/makr-code/themisdb/blob/develop/include/query/aql_translator.h"
click node_optimizer "https://github.com/makr-code/themisdb/blob/develop/include/query/query_optimizer.h"
click node_query "https://github.com/makr-code/themisdb/blob/develop/src/query/query_engine.cpp"
click node_request "https://github.com/makr-code/themisdb/blob/develop/include/query/request_context.h"
click node_secondary "https://github.com/makr-code/themisdb/blob/develop/include/index/secondary_index.h"
click node_graphindex "https://github.com/makr-code/themisdb/blob/develop/include/index/graph_index.h"
click node_entities "https://github.com/makr-code/themisdb/blob/develop/include/storage/base_entity.h"
click node_storage "https://github.com/makr-code/themisdb/blob/develop/include/storage/rocksdb_wrapper.h"
click node_ingestion "https://github.com/makr-code/themisdb/blob/develop/src/ingestion/ingestion_manager.cpp"
click node_async_content "https://github.com/makr-code/themisdb/blob/develop/src/content/async_ingestion_worker.cpp"
click node_temporal "https://github.com/makr-code/themisdb/blob/develop/src/temporal/temporal_query_engine.cpp"
click node_llm "https://github.com/makr-code/themisdb/blob/develop/src/llm/llm_plugin_manager.cpp"
click node_vllm "https://github.com/makr-code/themisdb/blob/develop/src/acceleration/vllm_resource_manager.cpp"
click node_metrics "https://github.com/makr-code/themisdb/blob/develop/include/llm/grafana_metrics.h"
click node_logs "https://github.com/makr-code/themisdb/blob/develop/src/observability/log_search_engine.cpp"

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_api,node_auth,node_parser,node_translator,node_optimizer,node_query,node_request,node_client toneBlue
class node_secondary,node_graphindex,node_entities,node_storage,node_ingestion,node_async_content,node_temporal toneAmber
class node_llm,node_vllm toneMint
class node_metrics,node_logs toneRose
```

## Components

### API and query

- [Query API](https://github.com/makr-code/themisdb/blob/develop/src/server/query_api_handler.cpp): `src/server/query_api_handler.cpp`
- [API authentication](https://github.com/makr-code/themisdb/blob/develop/include/server/auth_middleware.h): `include/server/auth_middleware.h`
- [AQL parser](https://github.com/makr-code/themisdb/blob/develop/include/query/aql_parser.h): `include/query/aql_parser.h`
- [AQL translator](https://github.com/makr-code/themisdb/blob/develop/include/query/aql_translator.h): `include/query/aql_translator.h`
- [Query optimizer](https://github.com/makr-code/themisdb/blob/develop/include/query/query_optimizer.h): `include/query/query_optimizer.h`
- [Query engine](https://github.com/makr-code/themisdb/blob/develop/src/query/query_engine.cpp): `src/query/query_engine.cpp`
- [Request context](https://github.com/makr-code/themisdb/blob/develop/include/query/request_context.h): `include/query/request_context.h`

### Data and ingestion

- [Secondary indexes](https://github.com/makr-code/themisdb/blob/develop/include/index/secondary_index.h): `include/index/secondary_index.h`
- [Graph index](https://github.com/makr-code/themisdb/blob/develop/include/index/graph_index.h): `include/index/graph_index.h`
- [Data entities](https://github.com/makr-code/themisdb/blob/develop/include/storage/base_entity.h): `include/storage/base_entity.h`
- [RocksDB storage](https://github.com/makr-code/themisdb/blob/develop/include/storage/rocksdb_wrapper.h): `include/storage/rocksdb_wrapper.h`
- [Source ingestion](https://github.com/makr-code/themisdb/blob/develop/src/ingestion/ingestion_manager.cpp): `src/ingestion/ingestion_manager.cpp`
- [Async content ingestion](https://github.com/makr-code/themisdb/blob/develop/src/content/async_ingestion_worker.cpp): `src/content/async_ingestion_worker.cpp`
- [Temporal queries](https://github.com/makr-code/themisdb/blob/develop/src/temporal/temporal_query_engine.cpp): `src/temporal/temporal_query_engine.cpp`

### AI and retrieval

- [LLM plugin manager](https://github.com/makr-code/themisdb/blob/develop/src/llm/llm_plugin_manager.cpp): `src/llm/llm_plugin_manager.cpp`
- [Inference resources](https://github.com/makr-code/themisdb/blob/develop/src/acceleration/vllm_resource_manager.cpp): `src/acceleration/vllm_resource_manager.cpp`

### Operations

- [LLM metrics](https://github.com/makr-code/themisdb/blob/develop/include/llm/grafana_metrics.h): `include/llm/grafana_metrics.h`
- [Log search](https://github.com/makr-code/themisdb/blob/develop/src/observability/log_search_engine.cpp): `src/observability/log_search_engine.cpp`

### Other components

- **Client**

## Connections

- Client → Query API: sends query (evidence: `README.md`)
- Query API → API authentication: checks access (evidence: `src/server/query_api_handler.cpp`)
- Query API → AQL parser: parses AQL (evidence: `src/server/query_api_handler.cpp`)
- Query API → Query engine: executes query (evidence: `src/server/query_api_handler.cpp`)
- Query API → Request context: builds context (evidence: `src/server/query_api_handler.cpp`)
- AQL translator → AQL parser: uses AST (evidence: `include/query/aql_translator.h`)
- AQL translator → Query engine: translates for (evidence: `include/query/aql_translator.h`)
- Query engine → Query optimizer: optimizes plan (evidence: `src/query/query_engine.cpp`)
- Query engine → AQL parser: parses queries (evidence: `src/query/query_engine.cpp`)
- Query engine → AQL translator: translates queries (evidence: `src/query/query_engine.cpp`)
- Query engine → Secondary indexes: uses indexes (evidence: `src/query/query_engine.cpp`)
- Query engine → Graph index: uses indexes (evidence: `src/query/query_engine.cpp`)
- Query engine → RocksDB storage: reads records (evidence: `src/query/query_engine.cpp`)
- Query engine → Data entities: deserializes records (evidence: `src/query/query_engine.cpp`)
- Secondary indexes → RocksDB storage: uses storage (evidence: `include/index/secondary_index.h`)
- Graph index → RocksDB storage: uses storage (evidence: `include/index/graph_index.h`)
- Source ingestion → RocksDB storage: loads data
- Async content ingestion → Source ingestion: processes content
- Temporal queries → RocksDB storage: queries versions
- LLM plugin manager → Inference resources: dispatches inference
- LLM plugin manager → LLM metrics: reports metrics (evidence: `src/llm/llm_plugin_manager.cpp`)
