# 06dhanushbe/rag_as_a_service architecture

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

- Interactive diagram: https://gitdiagram.com/06dhanushbe/rag_as_a_service
- Repository: https://github.com/06dhanushbe/rag_as_a_service

## Overview

Rag as a Service lets dashboard owners authenticate, manage knowledge bases and API keys, upload documents, and inspect usage; API consumers submit RAG queries and receive generated answers. The backend ingests PDFs into chunks and vectors, then retrieves and generates query responses. The graph preserves the documented frontend capabilities and the indexed backend modules. Some routes and subsystems were not excerpted, so their documented links are cited to the README; unsampled implementation details are not inferred.

Main entry points: [`frontend/src/App.jsx`](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/App.jsx) (Console router), [`frontend/src/apiClient.js`](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/apiClient.js) (API client), [`app/api/rag.py`](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/rag.py) (RAG query route), [`app/rag/service.py`](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/service.py) (Query orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Admin console"]
  node_app["Console router<br/>[App.jsx]"]
  node_client["API client<br/>[apiClient.js]"]
  node_kbui["Knowledge-base UI"]
  node_keysui["API-key UI"]
  node_usageui["Usage dashboard<br/>[UsagePage.jsx]"]
  node_docsui["Query tester<br/>[DocsPage.jsx]"]
end

subgraph group_api["Backend API"]
  node_auth["Authentication routes<br/>[auth.py]"]
  node_keyapi["API-key routes<br/>[api_keys.py]"]
  node_kbapi["Knowledge-base routes<br/>[kb.py]"]
  node_upload["Upload routes<br/>[upload.py]"]
  node_documents["Document routes<br/>[documents.py]"]
  node_ragapi["RAG query route<br/>[rag.py]"]
  node_usageapi["Usage routes<br/>[usage.py]"]
end

subgraph group_rag["RAG runtime"]
  node_ingest["Ingestion coordinator"]
  node_loader["PDF loader<br/>[loader.py]"]
  node_chunker["Text chunker<br/>[chunker.py]"]
  node_indexer["Vector indexer<br/>[indexer.py]"]
  node_ragservice["Query orchestrator<br/>[service.py]"]
  node_retriever["Vector retriever<br/>[retriever.py]"]
  node_reranker["Result reranker<br/>[reranker.py]"]
  node_context["Context builder<br/>[context_builder.py]"]
  node_generator["Answer generator<br/>[generator.py]"]
end

subgraph group_data["Persistence and providers"]
  node_db[("Relational database<br/>[database.py]")]
  node_qdrant[("Qdrant vector store<br/>[qdrant_client.py]")]
  node_embedding["Embedding provider<br/>[embedder.py]"]
  node_llm["LLM provider"]
  node_events["Usage event model<br/>[usage_event.py]"]
end

node_owner(("Dashboard owner"))
node_consumer(("API consumer"))

node_owner -->|"manages through"| node_app
node_app -->|"requests data"| node_client
node_app -->|"routes to"| node_kbui
node_app -->|"routes to"| node_keysui
node_app -->|"routes to"| node_usageui
node_app -->|"routes to"| node_docsui
node_client -->|"calls API"| node_auth
node_client -->|"calls API"| node_kbapi
node_client -->|"calls API"| node_keyapi
node_client -->|"uploads files"| node_upload
node_client -->|"requests metrics"| node_usageapi
node_consumer -->|"submits query"| node_ragapi
node_ragapi -->|"checks mappings"| node_db
node_ragapi -->|"calls query"| node_ragservice
node_ragapi -->|"logs usage"| node_events
node_ragapi -->|"returns answer"| node_consumer
node_upload -.->|"starts ingestion"| node_ingest
node_ingest -->|"loads PDF"| node_loader
node_ingest -->|"splits pages"| node_chunker
node_ingest -->|"indexes chunks"| node_indexer
node_indexer -->|"embeds chunks"| node_embedding
node_indexer -->|"stores vectors"| node_qdrant
node_ragservice -->|"retrieves chunks"| node_retriever
node_ragservice -->|"reranks results"| node_reranker
node_ragservice -->|"builds context"| node_context
node_ragservice -->|"generates answer"| node_generator
node_retriever -->|"searches vectors"| node_qdrant
node_retriever -->|"embeds question"| node_embedding
node_generator -.->|"requests completion"| node_llm
node_usageapi -->|"reads metrics"| node_events
node_db -->|"provides model base"| node_events

click node_app "https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/App.jsx"
click node_client "https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/apiClient.js"
click node_kbui "https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/KnowledgeBasePage.jsx"
click node_keysui "https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/ApiManagementPage.jsx"
click node_usageui "https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/UsagePage.jsx"
click node_docsui "https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/DocsPage.jsx"
click node_auth "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/auth.py"
click node_keyapi "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/api_keys.py"
click node_kbapi "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/kb.py"
click node_upload "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/upload.py"
click node_documents "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/documents.py"
click node_ragapi "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/rag.py"
click node_usageapi "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/usage.py"
click node_ingest "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion_service.py"
click node_loader "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/loader.py"
click node_chunker "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/chunker.py"
click node_indexer "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/indexer.py"
click node_ragservice "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/service.py"
click node_retriever "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/retrieval/retriever.py"
click node_reranker "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/retrieval/reranker.py"
click node_context "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/retrieval/context_builder.py"
click node_generator "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/llm/generator.py"
click node_db "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/core/database.py"
click node_qdrant "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/vectorstore/qdrant_client.py"
click node_embedding "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/embedder.py"
click node_events "https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/models/usage_event.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_app,node_client,node_kbui,node_keysui,node_usageui,node_docsui toneBlue
class node_auth,node_keyapi,node_kbapi,node_upload,node_documents,node_ragapi,node_usageapi toneAmber
class node_ingest,node_loader,node_chunker,node_indexer,node_ragservice,node_retriever,node_reranker,node_context,node_generator,node_consumer toneMint
class node_db,node_qdrant,node_embedding,node_llm,node_events toneRose
class node_owner toneIndigo
```

## Components

### Admin console

- [Console router](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/apiClient.js): `frontend/src/apiClient.js`
- [Knowledge-base UI](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/KnowledgeBasePage.jsx): `frontend/src/pages/KnowledgeBasePage.jsx`
- [API-key UI](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/ApiManagementPage.jsx): `frontend/src/pages/ApiManagementPage.jsx`
- [Usage dashboard](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/UsagePage.jsx): `frontend/src/pages/UsagePage.jsx`
- [Query tester](https://github.com/06dhanushbe/rag_as_a_service/blob/main/frontend/src/pages/DocsPage.jsx): `frontend/src/pages/DocsPage.jsx`

### Backend API

- [Authentication routes](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/auth.py): `app/api/auth.py`
- [API-key routes](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/api_keys.py): `app/api/api_keys.py`
- [Knowledge-base routes](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/kb.py): `app/api/kb.py`
- [Upload routes](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/upload.py): `app/api/upload.py`
- [Document routes](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/documents.py): `app/api/documents.py`
- [RAG query route](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/rag.py): `app/api/rag.py`
- [Usage routes](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/api/usage.py): `app/api/usage.py`

### RAG runtime

- [Ingestion coordinator](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion_service.py): `app/rag/ingestion_service.py`
- [PDF loader](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/loader.py): `app/rag/ingestion/loader.py`
- [Text chunker](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/chunker.py): `app/rag/ingestion/chunker.py`
- [Vector indexer](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/indexer.py): `app/rag/ingestion/indexer.py`
- [Query orchestrator](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/service.py): `app/rag/service.py`
- [Vector retriever](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/retrieval/retriever.py): `app/rag/retrieval/retriever.py`
- [Result reranker](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/retrieval/reranker.py): `app/rag/retrieval/reranker.py`
- [Context builder](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/retrieval/context_builder.py): `app/rag/retrieval/context_builder.py`
- [Answer generator](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/llm/generator.py): `app/rag/llm/generator.py`

### Persistence and providers

- [Relational database](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/core/database.py): `app/core/database.py`
- [Qdrant vector store](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/vectorstore/qdrant_client.py): `app/rag/vectorstore/qdrant_client.py`
- [Embedding provider](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/rag/ingestion/embedder.py): `app/rag/ingestion/embedder.py`
- **LLM provider**
- [Usage event model](https://github.com/06dhanushbe/rag_as_a_service/blob/main/app/models/usage_event.py): `app/models/usage_event.py`

### Other components

- **Dashboard owner**
- **API consumer**

## Connections

- Dashboard owner → Console router: manages through
- Console router → API client: requests data (evidence: `frontend/src/App.jsx`)
- Console router → Knowledge-base UI: routes to (evidence: `frontend/src/App.jsx`)
- Console router → API-key UI: routes to (evidence: `frontend/src/App.jsx`)
- Console router → Usage dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Console router → Query tester: routes to (evidence: `frontend/src/App.jsx`)
- API client → Authentication routes: calls API
- API client → Knowledge-base routes: calls API
- API client → API-key routes: calls API
- API client → Upload routes: uploads files
- API client → Usage routes: requests metrics
- API consumer → RAG query route: submits query
- RAG query route → Relational database: checks mappings (evidence: `app/api/rag.py`)
- RAG query route → Query orchestrator: calls query (evidence: `app/api/rag.py`)
- RAG query route → Usage event model: logs usage (evidence: `app/api/rag.py`)
- RAG query route → API consumer: returns answer (evidence: `app/api/rag.py`)
- Upload routes → Ingestion coordinator: starts ingestion
- Ingestion coordinator → PDF loader: loads PDF (evidence: `app/rag/ingestion_service.py`)
- Ingestion coordinator → Text chunker: splits pages (evidence: `app/rag/ingestion_service.py`)
- Ingestion coordinator → Vector indexer: indexes chunks (evidence: `app/rag/ingestion_service.py`)
- Vector indexer → Embedding provider: embeds chunks (evidence: `app/rag/ingestion/indexer.py`)
- Vector indexer → Qdrant vector store: stores vectors (evidence: `app/rag/ingestion/indexer.py`)
- Query orchestrator → Vector retriever: retrieves chunks (evidence: `app/rag/service.py`)
- Query orchestrator → Result reranker: reranks results (evidence: `app/rag/service.py`)
- Query orchestrator → Context builder: builds context (evidence: `app/rag/service.py`)
- Query orchestrator → Answer generator: generates answer (evidence: `app/rag/service.py`)
- Vector retriever → Qdrant vector store: searches vectors (evidence: `app/rag/retrieval/retriever.py`)
- Vector retriever → Embedding provider: embeds question (evidence: `app/rag/retrieval/retriever.py`)
- Answer generator → LLM provider: requests completion
- Usage routes → Usage event model: reads metrics (evidence: `app/api/usage.py`)
- Relational database → Usage event model: provides model base (evidence: `app/models/usage_event.py`)
