# mosoulzz/cppagentrag architecture

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

- Interactive diagram: https://gitdiagram.com/mosoulzz/cppagentrag
- Repository: https://github.com/mosoulzz/cppagentrag

## Overview

CppAgentRAG is a browser-facing C++ knowledge-base and agent question-answering service. The main workflow is authenticated document upload, asynchronous parsing/chunking/filtering/embedding and indexing, followed by query routing, hybrid retrieval, reranking, answer generation and citation checks; users also manage documents and sessions and can stream answers or request speech. README-documented platform capabilities are included, but their unsampled wiring is not inferred. Edge evidence is limited to the shown excerpts and explicit README descriptions.

Main entry points: [`apps/chatserver/src/rag/RagEngine.cpp`](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RagEngine.cpp) (RAG engine), [`apps/chatserver/include/features/rag/api`](https://github.com/mosoulzz/cppagentrag/tree/main/apps/chatserver/include/features/rag/api) (RAG handlers), [`apps/chatserver/src/rag/IngestPipeline.cpp`](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/IngestPipeline.cpp) (Ingest pipeline), [`apps/chatserver/src/ChatServer.cpp`](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/ChatServer.cpp) (HTTP application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser experience"]
  node_ragpage["RAG page<br/>[RagPage.tsx]"]
  node_ragapi["RAG API client<br/>[ragApi.ts]"]
end

subgraph group_app["Application and APIs"]
  node_server["HTTP application<br/>[ChatServer.cpp]"]
  node_auth["Authentication"]
  node_handlers["RAG handlers"]
end

subgraph group_rag["Knowledge and RAG"]
  node_jobs["Upload jobs"]
  node_ingest["Ingest pipeline<br/>[IngestPipeline.cpp]"]
  node_library[("Document library<br/>[DocumentLibrary.h]")]
  node_retrieval["Hybrid retrieval"]
  node_engine["RAG engine<br/>[RagEngine.cpp]"]
  node_agent["Agent tools<br/>[RagAgent.cpp]"]
  node_memory[("Conversation memory")]
  node_trash[("Trash and audit<br/>[TrashBin.cpp]")]
end

subgraph group_ai["AI capabilities"]
  node_llm["Model client<br/>[LlmClient.cpp]"]
  node_embedding["Embedding client"]
  node_parser["Document parser<br/>[DocumentParser.cpp]"]
end

subgraph group_platform["Platform services"]
  node_milvus[("Milvus index<br/>[MilvusClient.cpp]")]
  node_mysql[("MySQL persistence")]
  node_redis[("Redis services<br/>[RedisClient.cpp]")]
  node_sessions[("Shared sessions")]
  node_tts["Sambert speech<br/>[SambertTts.cpp]"]
  node_rabbit["RabbitMQ<br/>[MQManager.cpp]"]
end

node_browser(("User"))
node_modelservice(("LLM providers"))
node_sambert(("Sambert service"))

node_browser -->|"uses"| node_ragpage
node_ragpage -->|"requests"| node_ragapi
node_ragapi -.->|"calls API"| node_server
node_server -.->|"serves"| node_auth
node_server -.->|"routes"| node_handlers
node_handlers -.->|"manages uploads"| node_jobs
node_jobs -.->|"runs ingest"| node_engine
node_engine -->|"delegates ingest"| node_ingest
node_ingest -->|"parses"| node_parser
node_ingest -->|"embeds chunks"| node_embedding
node_ingest -->|"writes documents"| node_library
node_ingest -->|"upserts vectors"| node_milvus
node_engine -->|"retrieves"| node_retrieval
node_retrieval -.->|"reads chunks"| node_library
node_retrieval -.->|"vector search"| node_milvus
node_engine -->|"generates answer"| node_llm
node_engine -->|"runs agent"| node_agent
node_engine -->|"reads and writes"| node_memory
node_handlers -.->|"manages documents"| node_trash
node_handlers -.->|"serves history"| node_memory
node_handlers -.->|"requests speech"| node_tts
node_tts -.->|"synthesizes"| node_sambert
node_llm -.->|"calls models"| node_modelservice
node_embedding -.->|"requests vectors"| node_modelservice
node_sessions -->|"stores sessions"| node_redis
node_handlers -.->|"uses sessions"| node_sessions
node_engine -.->|"persists messages"| node_mysql
node_engine -.->|"optional async writes"| node_rabbit

click node_ragpage "https://github.com/mosoulzz/cppagentrag/blob/main/frontend/web/src/pages/RagPage.tsx"
click node_ragapi "https://github.com/mosoulzz/cppagentrag/blob/main/frontend/web/src/ragApi.ts"
click node_server "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/ChatServer.cpp"
click node_auth "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/features/auth/api/AuthenticatedHandler.cpp"
click node_handlers "https://github.com/mosoulzz/cppagentrag/tree/main/apps/chatserver/include/features/rag/api"
click node_jobs "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/UploadJobManager.cpp"
click node_ingest "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/IngestPipeline.cpp"
click node_library "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/include/rag/DocumentLibrary.h"
click node_retrieval "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RetrievalPipeline.cpp"
click node_engine "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RagEngine.cpp"
click node_agent "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RagAgent.cpp"
click node_memory "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/ConversationMemory.cpp"
click node_trash "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/TrashBin.cpp"
click node_llm "https://github.com/mosoulzz/cppagentrag/blob/main/libs/ai-core/src/LlmClient.cpp"
click node_embedding "https://github.com/mosoulzz/cppagentrag/blob/main/libs/ai-core/src/EmbeddingClient.cpp"
click node_parser "https://github.com/mosoulzz/cppagentrag/blob/main/libs/ai-core/src/DocumentParser.cpp"
click node_milvus "https://github.com/mosoulzz/cppagentrag/blob/main/libs/storage/src/milvus/MilvusClient.cpp"
click node_mysql "https://github.com/mosoulzz/cppagentrag/tree/main/libs/storage/include/mysql"
click node_redis "https://github.com/mosoulzz/cppagentrag/blob/main/libs/storage/src/redis/RedisClient.cpp"
click node_sessions "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/session/RedisSessionStorage.cpp"
click node_tts "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/features/tts/SambertTts.cpp"
click node_rabbit "https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/infra/mq/MQManager.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_ragpage,node_ragapi,node_browser toneBlue
class node_server,node_auth,node_handlers toneAmber
class node_jobs,node_ingest,node_library,node_retrieval,node_engine,node_agent,node_memory,node_trash toneMint
class node_llm,node_embedding,node_parser toneRose
class node_milvus,node_mysql,node_redis,node_sessions,node_tts,node_rabbit,node_modelservice,node_sambert toneIndigo
```

## Components

### Browser experience

- [RAG page](https://github.com/mosoulzz/cppagentrag/blob/main/frontend/web/src/pages/RagPage.tsx): `frontend/web/src/pages/RagPage.tsx`
- [RAG API client](https://github.com/mosoulzz/cppagentrag/blob/main/frontend/web/src/ragApi.ts): `frontend/web/src/ragApi.ts`

### Application and APIs

- [HTTP application](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/ChatServer.cpp): `apps/chatserver/src/ChatServer.cpp`
- [Authentication](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/features/auth/api/AuthenticatedHandler.cpp): `apps/chatserver/src/features/auth/api/AuthenticatedHandler.cpp`
- [RAG handlers](https://github.com/mosoulzz/cppagentrag/tree/main/apps/chatserver/include/features/rag/api): `apps/chatserver/include/features/rag/api`

### Knowledge and RAG

- [Upload jobs](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/UploadJobManager.cpp): `apps/chatserver/src/rag/UploadJobManager.cpp`
- [Ingest pipeline](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/IngestPipeline.cpp): `apps/chatserver/src/rag/IngestPipeline.cpp`
- [Document library](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/include/rag/DocumentLibrary.h): `apps/chatserver/include/rag/DocumentLibrary.h`
- [Hybrid retrieval](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RetrievalPipeline.cpp): `apps/chatserver/src/rag/RetrievalPipeline.cpp`
- [RAG engine](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RagEngine.cpp): `apps/chatserver/src/rag/RagEngine.cpp`
- [Agent tools](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/RagAgent.cpp): `apps/chatserver/src/rag/RagAgent.cpp`
- [Conversation memory](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/ConversationMemory.cpp): `apps/chatserver/src/rag/ConversationMemory.cpp`
- [Trash and audit](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/rag/TrashBin.cpp): `apps/chatserver/src/rag/TrashBin.cpp`

### AI capabilities

- [Model client](https://github.com/mosoulzz/cppagentrag/blob/main/libs/ai-core/src/LlmClient.cpp): `libs/ai-core/src/LlmClient.cpp`
- [Embedding client](https://github.com/mosoulzz/cppagentrag/blob/main/libs/ai-core/src/EmbeddingClient.cpp): `libs/ai-core/src/EmbeddingClient.cpp`
- [Document parser](https://github.com/mosoulzz/cppagentrag/blob/main/libs/ai-core/src/DocumentParser.cpp): `libs/ai-core/src/DocumentParser.cpp`

### Platform services

- [Milvus index](https://github.com/mosoulzz/cppagentrag/blob/main/libs/storage/src/milvus/MilvusClient.cpp): `libs/storage/src/milvus/MilvusClient.cpp`
- [MySQL persistence](https://github.com/mosoulzz/cppagentrag/tree/main/libs/storage/include/mysql): `libs/storage/include/mysql`
- [Redis services](https://github.com/mosoulzz/cppagentrag/blob/main/libs/storage/src/redis/RedisClient.cpp): `libs/storage/src/redis/RedisClient.cpp`
- [Shared sessions](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/session/RedisSessionStorage.cpp): `apps/chatserver/src/session/RedisSessionStorage.cpp`
- [Sambert speech](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/features/tts/SambertTts.cpp): `apps/chatserver/src/features/tts/SambertTts.cpp`
- [RabbitMQ](https://github.com/mosoulzz/cppagentrag/blob/main/apps/chatserver/src/infra/mq/MQManager.cpp): `apps/chatserver/src/infra/mq/MQManager.cpp`

### Other components

- **User**
- **LLM providers**
- **Sambert service**

## Connections

- User → RAG page: uses (evidence: `README.md`)
- RAG page → RAG API client: requests (evidence: `frontend/web/src/pages/RagPage.tsx`)
- RAG API client → HTTP application: calls API (evidence: `README.md`)
- HTTP application → Authentication: serves (evidence: `README.md`)
- HTTP application → RAG handlers: routes (evidence: `README.md`)
- RAG handlers → Upload jobs: manages uploads (evidence: `README.md`)
- Upload jobs → RAG engine: runs ingest (evidence: `README.md`)
- RAG engine → Ingest pipeline: delegates ingest (evidence: `apps/chatserver/src/rag/RagEngine.cpp`)
- Ingest pipeline → Document parser: parses (evidence: `apps/chatserver/src/rag/IngestPipeline.cpp`)
- Ingest pipeline → Embedding client: embeds chunks (evidence: `apps/chatserver/src/rag/IngestPipeline.cpp`)
- Ingest pipeline → Document library: writes documents (evidence: `apps/chatserver/src/rag/IngestPipeline.cpp`)
- Ingest pipeline → Milvus index: upserts vectors (evidence: `apps/chatserver/src/rag/IngestPipeline.cpp`)
- RAG engine → Hybrid retrieval: retrieves (evidence: `apps/chatserver/src/rag/RagEngine.cpp`)
- Hybrid retrieval → Document library: reads chunks (evidence: `README.md`)
- Hybrid retrieval → Milvus index: vector search (evidence: `README.md`)
- RAG engine → Model client: generates answer (evidence: `apps/chatserver/src/rag/RagEngine.cpp`)
- RAG engine → Agent tools: runs agent (evidence: `apps/chatserver/src/rag/RagEngine.cpp`)
- RAG engine → Conversation memory: reads and writes (evidence: `apps/chatserver/src/rag/RagEngine.cpp`)
- RAG handlers → Trash and audit: manages documents (evidence: `README.md`)
- RAG handlers → Conversation memory: serves history (evidence: `README.md`)
- RAG handlers → Sambert speech: requests speech (evidence: `README.md`)
- Sambert speech → Sambert service: synthesizes (evidence: `README.md`)
- Model client → LLM providers: calls models (evidence: `README.md`)
- Embedding client → LLM providers: requests vectors (evidence: `README.md`)
- Shared sessions → Redis services: stores sessions (evidence: `apps/chatserver/src/session/RedisSessionStorage.cpp`)
- RAG handlers → Shared sessions: uses sessions (evidence: `README.md`)
- RAG engine → MySQL persistence: persists messages (evidence: `README.md`)
- RAG engine → RabbitMQ: optional async writes (evidence: `README.md`)
