# norsaje/celerity architecture

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

- Interactive diagram: https://gitdiagram.com/norsaje/celerity
- Repository: https://github.com/norsaje/celerity

## Overview

Celerity is a C++ multimodal search tool. Its main workflow accepts text, images, video, or audio; converts inputs to CLIP embeddings (audio first passes through transcription); then searches or updates an IVF-PQ index. CSV-based index building and search are also supported. The graph includes the documented model/runtime and ingestion capabilities, plus the declared gateway, metadata, cache, and generation components. Gateway internals are only declared in the excerpts, so those relationships are marked unverified rather than treated as confirmed calls.

Main entry points: [`src/main.cpp`](https://github.com/norsaje/celerity/blob/main/src/main.cpp) (Command router), [`src/server/Gateway.cpp`](https://github.com/norsaje/celerity/blob/main/src/server/Gateway.cpp) (Gateway), [`src/dl/encoders/ClipEncoder.cpp`](https://github.com/norsaje/celerity/blob/main/src/dl/encoders/ClipEncoder.cpp) (CLIP encoder), [`src/ann/SearchEngine.cpp`](https://github.com/norsaje/celerity/blob/main/src/ann/SearchEngine.cpp) (Search engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_main["Command router<br/>[main.cpp]"]
end

subgraph group_ingest["Ingestion and embeddings"]
  node_video["Video sampling<br/>[VideoIngestor.cpp]"]
  node_audio["Audio transcription"]
  node_clip["CLIP encoder<br/>[ClipEncoder.cpp]"]
  node_onnx["ONNX runner<br/>[OnnxRunner.cpp]"]
  node_tokenizer["Python tokenizer<br/>[clip_tokenize.py]"]
  node_transcribe_tool["Whisper tool<br/>[transcribe.py]"]
end

subgraph group_ann["Vector search"]
  node_search["Search engine<br/>[SearchEngine.cpp]"]
  node_ivfpq[("IVF-PQ index<br/>[IndexIVFPQ.cpp]")]
  node_kmeans["K-means<br/>[KMeans.cpp]"]
  node_pq["Product quantizer"]
  node_faiss["FAISS provider<br/>[FaissIndex.cpp]"]
end

subgraph group_service["Service components"]
  node_gateway["Gateway<br/>[Gateway.cpp]"]
  node_metadata[("Metadata store<br/>[MetadataDB.cpp]")]
  node_cache["KV cache pager<br/>[KVCachePager.cpp]"]
  node_generator["Generator<br/>[Generator.cpp]"]
end

node_user(("CLI user"))

node_user -->|"runs commands"| node_main
node_main -->|"encodes image/text"| node_clip
node_main -->|"ingests video"| node_video
node_video -->|"encodes frames"| node_clip
node_main -->|"transcribes audio"| node_audio
node_main -->|"encodes transcript"| node_clip
node_audio -->|"invokes tool"| node_transcribe_tool
node_clip -->|"runs models"| node_onnx
node_clip -.->|"tokenizes text"| node_tokenizer
node_main -->|"trains, loads, updates"| node_search
node_main -->|"searches vectors"| node_search
node_search -->|"delegates index work"| node_ivfpq
node_ivfpq -->|"uses clustering"| node_kmeans
node_ivfpq -->|"uses quantizer"| node_pq
node_gateway -.->|"declares dependency"| node_search
node_gateway -.->|"declares dependency"| node_video
node_gateway -.->|"declares dependency"| node_metadata
node_gateway -.->|"declares dependency"| node_cache
node_gateway -.->|"declares dependency"| node_generator

click node_main "https://github.com/norsaje/celerity/blob/main/src/main.cpp"
click node_video "https://github.com/norsaje/celerity/blob/main/src/ingest/VideoIngestor.cpp"
click node_audio "https://github.com/norsaje/celerity/blob/main/src/ingest/AudioTranscriber.cpp"
click node_clip "https://github.com/norsaje/celerity/blob/main/src/dl/encoders/ClipEncoder.cpp"
click node_onnx "https://github.com/norsaje/celerity/blob/main/src/dl/onnx/OnnxRunner.cpp"
click node_tokenizer "https://github.com/norsaje/celerity/blob/main/tools/clip_tokenize.py"
click node_transcribe_tool "https://github.com/norsaje/celerity/blob/main/tools/transcribe.py"
click node_search "https://github.com/norsaje/celerity/blob/main/src/ann/SearchEngine.cpp"
click node_ivfpq "https://github.com/norsaje/celerity/blob/main/src/ann/IndexIVFPQ.cpp"
click node_kmeans "https://github.com/norsaje/celerity/blob/main/src/ann/KMeans.cpp"
click node_pq "https://github.com/norsaje/celerity/blob/main/src/ann/ProductQuantizer.cpp"
click node_faiss "https://github.com/norsaje/celerity/blob/main/src/ann/faiss/FaissIndex.cpp"
click node_gateway "https://github.com/norsaje/celerity/blob/main/src/server/Gateway.cpp"
click node_metadata "https://github.com/norsaje/celerity/blob/main/src/storage/MetadataDB.cpp"
click node_cache "https://github.com/norsaje/celerity/blob/main/src/gen/KVCachePager.cpp"
click node_generator "https://github.com/norsaje/celerity/blob/main/src/gen/Generator.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_main,node_user toneBlue
class node_video,node_audio,node_clip,node_onnx,node_tokenizer,node_transcribe_tool toneAmber
class node_search,node_ivfpq,node_kmeans,node_pq,node_faiss toneMint
class node_gateway,node_metadata,node_cache,node_generator toneRose
```

## Components

### CLI workflow

- [Command router](https://github.com/norsaje/celerity/blob/main/src/main.cpp): `src/main.cpp`

### Ingestion and embeddings

- [Video sampling](https://github.com/norsaje/celerity/blob/main/src/ingest/VideoIngestor.cpp): `src/ingest/VideoIngestor.cpp`
- [Audio transcription](https://github.com/norsaje/celerity/blob/main/src/ingest/AudioTranscriber.cpp): `src/ingest/AudioTranscriber.cpp`
- [CLIP encoder](https://github.com/norsaje/celerity/blob/main/src/dl/encoders/ClipEncoder.cpp): `src/dl/encoders/ClipEncoder.cpp`
- [ONNX runner](https://github.com/norsaje/celerity/blob/main/src/dl/onnx/OnnxRunner.cpp): `src/dl/onnx/OnnxRunner.cpp`
- [Python tokenizer](https://github.com/norsaje/celerity/blob/main/tools/clip_tokenize.py): `tools/clip_tokenize.py`
- [Whisper tool](https://github.com/norsaje/celerity/blob/main/tools/transcribe.py): `tools/transcribe.py`

### Vector search

- [Search engine](https://github.com/norsaje/celerity/blob/main/src/ann/SearchEngine.cpp): `src/ann/SearchEngine.cpp`
- [IVF-PQ index](https://github.com/norsaje/celerity/blob/main/src/ann/IndexIVFPQ.cpp): `src/ann/IndexIVFPQ.cpp`
- [K-means](https://github.com/norsaje/celerity/blob/main/src/ann/KMeans.cpp): `src/ann/KMeans.cpp`
- [Product quantizer](https://github.com/norsaje/celerity/blob/main/src/ann/ProductQuantizer.cpp): `src/ann/ProductQuantizer.cpp`
- [FAISS provider](https://github.com/norsaje/celerity/blob/main/src/ann/faiss/FaissIndex.cpp): `src/ann/faiss/FaissIndex.cpp`

### Service components

- [Gateway](https://github.com/norsaje/celerity/blob/main/src/server/Gateway.cpp): `src/server/Gateway.cpp`
- [Metadata store](https://github.com/norsaje/celerity/blob/main/src/storage/MetadataDB.cpp): `src/storage/MetadataDB.cpp`
- [KV cache pager](https://github.com/norsaje/celerity/blob/main/src/gen/KVCachePager.cpp): `src/gen/KVCachePager.cpp`
- [Generator](https://github.com/norsaje/celerity/blob/main/src/gen/Generator.cpp): `src/gen/Generator.cpp`

### Other components

- **CLI user**

## Connections

- CLI user → Command router: runs commands (evidence: `src/main.cpp`)
- Command router → CLIP encoder: encodes image/text (evidence: `src/main.cpp`)
- Command router → Video sampling: ingests video (evidence: `src/main.cpp`)
- Video sampling → CLIP encoder: encodes frames (evidence: `src/ingest/VideoIngestor.cpp`)
- Command router → Audio transcription: transcribes audio (evidence: `src/main.cpp`)
- Command router → CLIP encoder: encodes transcript (evidence: `src/main.cpp`)
- Audio transcription → Whisper tool: invokes tool (evidence: `README.md`)
- CLIP encoder → ONNX runner: runs models
- CLIP encoder → Python tokenizer: tokenizes text (evidence: `README.md`)
- Command router → Search engine: trains, loads, updates (evidence: `src/main.cpp`)
- Command router → Search engine: searches vectors (evidence: `src/main.cpp`)
- Search engine → IVF-PQ index: delegates index work (evidence: `src/ann/SearchEngine.cpp`)
- IVF-PQ index → K-means: uses clustering
- IVF-PQ index → Product quantizer: uses quantizer
- Gateway → Search engine: declares dependency
- Gateway → Video sampling: declares dependency
- Gateway → Metadata store: declares dependency
- Gateway → KV cache pager: declares dependency
- Gateway → Generator: declares dependency
