# tanishk-dot/rag-based-doc-analyst- architecture

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

- Interactive diagram: https://gitdiagram.com/tanishk-dot/rag-based-doc-analyst-
- Repository: https://github.com/tanishk-dot/rag-based-doc-analyst-

## Overview

This is an enterprise hybrid RAG knowledge assistant: users submit documents for ingestion and ask questions over the resulting knowledge base. The documented core stages are document processing and embedding, vector-plus-BM25 retrieval, optional reranking, and answer evaluation. The API also exposes routing, citation, context-verification, and multi-document reasoning capabilities. The graph combines README-described architecture with relationships visible in sampled routes, retriever, and ingestion excerpts; unsampled implementation details are not inferred.

Main entry points: [`app/api/routes.py`](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/api/routes.py) (FastAPI routes), [`app/ingestion/processor.py`](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/processor.py) (Document processing), [`app/retrieval/retriever.py`](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/retriever.py) (Hybrid retrieval), [`app/workflows/langgraph_workflow.py`](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/workflows/langgraph_workflow.py) (LangGraph workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_api["FastAPI routes<br/>[routes.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_ingest["Ingestion"]
  node_validation["File validation<br/>[validators.py]"]
  node_extract["Document extraction<br/>[extractors.py]"]
  node_process["Document processing<br/>[processor.py]"]
  node_embed["Embedding generation<br/>[generator.py]"]
end

subgraph group_retrieve["Retrieval"]
  node_vectorstore[("Vector storage<br/>[storage.py]")]
  node_bm25[("BM25 index<br/>[bm25.py]")]
  node_router["Query routing<br/>[query_router.py]"]
  node_retriever["Hybrid retrieval<br/>[retriever.py]"]
  node_rerank["Reranking<br/>[reranking.py]"]
  node_workflow["LangGraph workflow"]
  node_metadata["Metadata filtering<br/>[metadata_filter.py]"]
end

subgraph group_quality["Answer quality"]
  node_verify["Context verification"]
  node_citation["Citation generation"]
  node_reasoner["Document reasoning"]
  node_evaluation["Quality evaluation<br/>[ragas_evaluator.py]"]
end

subgraph group_platform["Platform"]
  node_settings["Configuration<br/>[settings.py]"]
end

node_user(("Knowledge user"))

node_user -->|"submits queries"| node_api
node_api -->|"validates requests"| node_schemas
node_api -->|"validates uploads"| node_validation
node_api -->|"ingests documents"| node_process
node_process -->|"extracts content"| node_extract
node_process -->|"generates embeddings"| node_embed
node_process -->|"stores vectors"| node_vectorstore
node_process -->|"indexes chunks"| node_bm25
node_api -->|"requests retrieval"| node_retriever
node_retriever -->|"searches vectors"| node_vectorstore
node_retriever -->|"searches keywords"| node_bm25
node_retriever -->|"requests strategy"| node_router
node_workflow -->|"routes queries"| node_router
node_workflow -->|"retrieves context"| node_retriever
node_workflow -->|"reranks results"| node_rerank
node_api -->|"requests reranking"| node_rerank
node_api -->|"filters results"| node_metadata
node_api -->|"verifies context"| node_verify
node_api -->|"generates citations"| node_citation
node_api -->|"reasons across documents"| node_reasoner
node_api -->|"evaluates answers"| node_evaluation
node_api -.->|"loads settings"| node_settings

click node_api "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/api/routes.py"
click node_schemas "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/models/schemas.py"
click node_validation "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/validators.py"
click node_extract "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/extractors.py"
click node_process "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/processor.py"
click node_embed "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/embedding/generator.py"
click node_vectorstore "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/storage.py"
click node_bm25 "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/bm25.py"
click node_router "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/routing/query_router.py"
click node_retriever "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/retriever.py"
click node_rerank "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/reranking.py"
click node_workflow "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/workflows/langgraph_workflow.py"
click node_metadata "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/metadata_filter.py"
click node_verify "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/context_verifier.py"
click node_citation "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/citation_generator.py"
click node_reasoner "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/reasoning/multi_document_reasoner.py"
click node_evaluation "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/evaluation/ragas_evaluator.py"
click node_settings "https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/config/settings.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_api,node_schemas,node_user toneBlue
class node_validation,node_extract,node_process,node_embed toneAmber
class node_vectorstore,node_bm25,node_router,node_retriever,node_rerank,node_workflow,node_metadata toneMint
class node_verify,node_citation,node_reasoner,node_evaluation toneRose
class node_settings toneIndigo
```

## Components

### API entry

- [FastAPI routes](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/api/routes.py): `app/api/routes.py`
- [Request schemas](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/models/schemas.py): `app/models/schemas.py`

### Ingestion

- [File validation](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/validators.py): `app/ingestion/validators.py`
- [Document extraction](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/extractors.py): `app/ingestion/extractors.py`
- [Document processing](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/ingestion/processor.py): `app/ingestion/processor.py`
- [Embedding generation](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/embedding/generator.py): `app/embedding/generator.py`

### Retrieval

- [Vector storage](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/storage.py): `app/retrieval/storage.py`
- [BM25 index](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/bm25.py): `app/retrieval/bm25.py`
- [Query routing](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/routing/query_router.py): `app/routing/query_router.py`
- [Hybrid retrieval](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/retriever.py): `app/retrieval/retriever.py`
- [Reranking](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/reranking.py): `app/retrieval/reranking.py`
- [LangGraph workflow](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/workflows/langgraph_workflow.py): `app/workflows/langgraph_workflow.py`
- [Metadata filtering](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/metadata_filter.py): `app/retrieval/metadata_filter.py`

### Answer quality

- [Context verification](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/context_verifier.py): `app/retrieval/context_verifier.py`
- [Citation generation](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/retrieval/citation_generator.py): `app/retrieval/citation_generator.py`
- [Document reasoning](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/reasoning/multi_document_reasoner.py): `app/reasoning/multi_document_reasoner.py`
- [Quality evaluation](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/evaluation/ragas_evaluator.py): `app/evaluation/ragas_evaluator.py`

### Platform

- [Configuration](https://github.com/tanishk-dot/rag-based-doc-analyst-/blob/main/app/config/settings.py): `app/config/settings.py`

### Other components

- **Knowledge user**

## Connections

- Knowledge user → FastAPI routes: submits queries (evidence: `README.md`)
- FastAPI routes → Request schemas: validates requests (evidence: `app/api/routes.py`)
- FastAPI routes → File validation: validates uploads (evidence: `app/api/routes.py`)
- FastAPI routes → Document processing: ingests documents (evidence: `app/api/routes.py`)
- Document processing → Document extraction: extracts content (evidence: `app/ingestion/processor.py`)
- Document processing → Embedding generation: generates embeddings (evidence: `README.md`)
- Document processing → Vector storage: stores vectors (evidence: `app/ingestion/processor.py`)
- Document processing → BM25 index: indexes chunks (evidence: `app/ingestion/processor.py`)
- FastAPI routes → Hybrid retrieval: requests retrieval (evidence: `app/api/routes.py`)
- Hybrid retrieval → Vector storage: searches vectors (evidence: `app/retrieval/retriever.py`)
- Hybrid retrieval → BM25 index: searches keywords (evidence: `README.md`)
- Hybrid retrieval → Query routing: requests strategy (evidence: `app/retrieval/retriever.py`)
- LangGraph workflow → Query routing: routes queries (evidence: `app/workflows/langgraph_workflow.py`)
- LangGraph workflow → Hybrid retrieval: retrieves context (evidence: `app/workflows/langgraph_workflow.py`)
- LangGraph workflow → Reranking: reranks results (evidence: `app/workflows/langgraph_workflow.py`)
- FastAPI routes → Reranking: requests reranking (evidence: `app/api/routes.py`)
- FastAPI routes → Metadata filtering: filters results (evidence: `app/api/routes.py`)
- FastAPI routes → Context verification: verifies context (evidence: `app/api/routes.py`)
- FastAPI routes → Citation generation: generates citations (evidence: `app/api/routes.py`)
- FastAPI routes → Document reasoning: reasons across documents (evidence: `app/api/routes.py`)
- FastAPI routes → Quality evaluation: evaluates answers (evidence: `app/api/routes.py`)
- FastAPI routes → Configuration: loads settings (evidence: `README.md`)
