# ayushpeterlakra/vector_database_design_for_rag_system architecture

> Architecture diagram of the GitHub repository ayushpeterlakra/vector_database_design_for_rag_system, 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/ayushpeterlakra/vector_database_design_for_rag_system
- Repository: https://github.com/ayushpeterlakra/vector_database_design_for_rag_system

## Overview

PrecisionRAG is a Qdrant-backed passage retrieval product for MS MARCO and internal documents. Its main workflow is a user search through the web UI and FastAPI, then dense/BM25 retrieval, optional fusion and reranking, and ranked results; users can also request cited AI answers. Separate capabilities include offline corpus indexing, metadata/topic filters, live document updates with version history, and benchmark dashboards. Edges reflect the README and shown source references; some internal implementations, including API handlers and indexing details, were not fully excerpted.

Main entry points: [`precisionrag/retriever.py`](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/retriever.py) (Retrieval pipeline), [`api/main.py`](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/api/main.py) (FastAPI service), [`precisionrag/updates.py`](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/updates.py) (Live updates), [`precisionrag/store.py`](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/store.py) (Qdrant store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_query["Search and answers"]
  node_web["Web UI<br/>[app.js]"]
  node_api["FastAPI service<br/>[main.py]"]
  node_retriever["Retrieval pipeline<br/>[retriever.py]"]
  node_encoders["Text encoders<br/>[encoders.py]"]
  node_fusion["Rank fusion<br/>[fusion.py]"]
  node_reranker["Cross-encoder<br/>[rerank.py]"]
  node_answer["Cited answers<br/>[answer.py]"]
  node_cache[("Result cache<br/>[cache.py]")]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_index["Index and storage"]
  node_indexer["Corpus indexing<br/>[build_index.py]"]
  node_corpus["Corpus preparation<br/>[data.py]"]
  node_store[("Qdrant store<br/>[store.py]")]
end

subgraph group_updates["Tags and updates"]
  node_tags["Metadata tagging<br/>[tags.py]"]
  node_updater["Live updates<br/>[updates.py]"]
  node_changelog[("Version history<br/>[changelog.py]")]
end

subgraph group_insight["Evaluation and reporting"]
  node_dashboard["Dashboard data<br/>[dashboard.py]"]
  node_metrics["Retrieval metrics<br/>[metrics.py]"]
  node_results[("Measurement files<br/>[results.py]")]
  node_benchmark["IR evaluation<br/>[eval_ir.py]"]
end

node_user(("Search user"))
node_groq["Groq API"]
node_qdrant[("Qdrant<br/>external system")]

node_user -->|"searches"| node_web
node_web -->|"calls API"| node_api
node_api -->|"dispatches search"| node_retriever
node_api -->|"checks and stores"| node_cache
node_api -->|"requests answer"| node_answer
node_api -->|"routes updates"| node_updater
node_api -->|"serves dashboard"| node_dashboard
node_retriever -->|"encodes queries"| node_encoders
node_retriever -->|"searches candidates"| node_store
node_retriever -->|"fuses rankings"| node_fusion
node_retriever -->|"reranks candidates"| node_reranker
node_retriever -->|"gets topic suggestions"| node_tags
node_answer -->|"generates answer"| node_groq
node_indexer -->|"prepares passages"| node_corpus
node_indexer -->|"creates vectors"| node_encoders
node_indexer -->|"writes index"| node_store
node_store -->|"reads and writes"| node_qdrant
node_updater -->|"re-embeds documents"| node_encoders
node_updater -->|"upserts and deletes"| node_store
node_updater -->|"assigns metadata"| node_tags
node_updater -->|"records versions"| node_changelog
node_tags -->|"uses dense vectors"| node_encoders
node_benchmark -->|"evaluates modes"| node_retriever
node_benchmark -->|"computes scores"| node_metrics
node_benchmark -->|"saves measurements"| node_results
node_dashboard -->|"reads measurements"| node_results
node_api -->|"loads settings"| node_config
node_retriever -->|"loads profiles"| node_config

click node_web "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/web/app.js"
click node_api "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/api/main.py"
click node_retriever "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/retriever.py"
click node_encoders "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/encoders.py"
click node_fusion "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/fusion.py"
click node_reranker "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/rerank.py"
click node_answer "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/answer.py"
click node_indexer "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/scripts/build_index.py"
click node_corpus "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/data.py"
click node_store "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/store.py"
click node_tags "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/tags.py"
click node_updater "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/updates.py"
click node_changelog "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/changelog.py"
click node_cache "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/cache.py"
click node_config "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/config.py"
click node_dashboard "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/dashboard.py"
click node_metrics "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/metrics.py"
click node_results "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/results.py"
click node_benchmark "https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/scripts/eval_ir.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_web,node_api,node_retriever,node_encoders,node_fusion,node_reranker,node_answer,node_cache,node_config,node_user toneBlue
class node_indexer,node_corpus,node_store,node_qdrant toneAmber
class node_tags,node_updater,node_changelog,node_groq toneMint
class node_dashboard,node_metrics,node_results,node_benchmark toneRose
```

## Components

### Search and answers

- [Web UI](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/web/app.js): `web/app.js`
- [FastAPI service](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/api/main.py): `api/main.py`
- [Retrieval pipeline](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/retriever.py): `precisionrag/retriever.py`
- [Text encoders](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/encoders.py): `precisionrag/encoders.py`
- [Rank fusion](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/fusion.py): `precisionrag/fusion.py`
- [Cross-encoder](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/rerank.py): `precisionrag/rerank.py`
- [Cited answers](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/answer.py): `precisionrag/answer.py`
- [Result cache](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/cache.py): `precisionrag/cache.py`
- [Runtime settings](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/config.py): `precisionrag/config.py`

### Index and storage

- [Corpus indexing](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/scripts/build_index.py): `scripts/build_index.py`
- [Corpus preparation](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/data.py): `precisionrag/data.py`
- [Qdrant store](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/store.py): `precisionrag/store.py`

### Tags and updates

- [Metadata tagging](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/tags.py): `precisionrag/tags.py`
- [Live updates](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/updates.py): `precisionrag/updates.py`
- [Version history](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/changelog.py): `precisionrag/changelog.py`

### Evaluation and reporting

- [Dashboard data](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/dashboard.py): `precisionrag/dashboard.py`
- [Retrieval metrics](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/metrics.py): `precisionrag/metrics.py`
- [Measurement files](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/precisionrag/results.py): `precisionrag/results.py`
- [IR evaluation](https://github.com/ayushpeterlakra/vector_database_design_for_rag_system/blob/main/scripts/eval_ir.py): `scripts/eval_ir.py`

### Other components

- **Search user**
- **Groq API**
- **Qdrant**: external system

## Connections

- Search user → Web UI: searches (evidence: `README.md`)
- Web UI → FastAPI service: calls API (evidence: `README.md`)
- FastAPI service → Retrieval pipeline: dispatches search (evidence: `api/main.py`)
- FastAPI service → Result cache: checks and stores (evidence: `api/main.py`)
- FastAPI service → Cited answers: requests answer (evidence: `api/main.py`)
- FastAPI service → Live updates: routes updates (evidence: `api/main.py`)
- FastAPI service → Dashboard data: serves dashboard (evidence: `api/main.py`)
- Retrieval pipeline → Text encoders: encodes queries (evidence: `precisionrag/retriever.py`)
- Retrieval pipeline → Qdrant store: searches candidates (evidence: `precisionrag/retriever.py`)
- Retrieval pipeline → Rank fusion: fuses rankings (evidence: `precisionrag/retriever.py`)
- Retrieval pipeline → Cross-encoder: reranks candidates (evidence: `precisionrag/retriever.py`)
- Retrieval pipeline → Metadata tagging: gets topic suggestions (evidence: `precisionrag/retriever.py`)
- Cited answers → Groq API: generates answer (evidence: `README.md`)
- Corpus indexing → Corpus preparation: prepares passages (evidence: `scripts/build_index.py`)
- Corpus indexing → Text encoders: creates vectors (evidence: `scripts/build_index.py`)
- Corpus indexing → Qdrant store: writes index (evidence: `scripts/build_index.py`)
- Qdrant store → Qdrant: reads and writes (evidence: `precisionrag/store.py`)
- Live updates → Text encoders: re-embeds documents (evidence: `precisionrag/updates.py`)
- Live updates → Qdrant store: upserts and deletes (evidence: `precisionrag/updates.py`)
- Live updates → Metadata tagging: assigns metadata (evidence: `precisionrag/updates.py`)
- Live updates → Version history: records versions (evidence: `precisionrag/updates.py`)
- Metadata tagging → Text encoders: uses dense vectors (evidence: `precisionrag/tags.py`)
- IR evaluation → Retrieval pipeline: evaluates modes (evidence: `scripts/eval_ir.py`)
- IR evaluation → Retrieval metrics: computes scores (evidence: `scripts/eval_ir.py`)
- IR evaluation → Measurement files: saves measurements (evidence: `scripts/eval_ir.py`)
- Dashboard data → Measurement files: reads measurements (evidence: `precisionrag/dashboard.py`)
- FastAPI service → Runtime settings: loads settings (evidence: `api/main.py`)
- Retrieval pipeline → Runtime settings: loads profiles (evidence: `precisionrag/retriever.py`)
