# vinodbavage31/agentic-rag- architecture

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

- Interactive diagram: https://gitdiagram.com/vinodbavage31/agentic-rag-
- Repository: https://github.com/vinodbavage31/agentic-rag-

## Overview

WMF QA is a FastAPI-backed agentic RAG platform for answering Vrutti FPO questions, with a Streamlit interface and a document-ingestion capability. The main workflow routes a query, optionally retrieves and grades evidence, rewrites weak searches, then synthesizes a persona-aware answer and verifies citations. Separate trace data supports execution inspection. The graph follows the README and available excerpts; ingestion internals and some runtime wiring are not shown, so uncertain connections are omitted or marked unverified.

Main entry points: [`app/pipeline/agent.py`](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/agent.py) (RAG orchestrator), [`app/main.py`](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/main.py) (FastAPI API), [`app/pipeline/llm.py`](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/llm.py) (LLM client), [`app/core/database.py`](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/database.py) (Corpus database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["User access"]
  node_frontend["Streamlit UI<br/>[streamlit_app.py]"]
  node_api_service["FastAPI API<br/>[main.py]"]
end

subgraph group_rag["RAG workflow"]
  node_orchestrator["RAG orchestrator<br/>[agent.py]"]
  node_router["Query router<br/>[router.py]"]
  node_retriever["Hybrid retrieval<br/>[retrieval.py]"]
  node_grader["Relevance grader<br/>[grader.py]"]
  node_prompt_defs["RAG prompts<br/>[prompts.py]"]
end

subgraph group_corpus["Document corpus"]
  node_embedding["Embedding model<br/>[embedding.py]"]
  node_ingestion["Document ingestion<br/>[ingestion.py]"]
end

subgraph group_storage["Persistence"]
  node_documents[("Document records<br/>[document.py]")]
  node_chunks[("Chunk records<br/>[document_chunk.py]")]
  node_primary_db[("Corpus database<br/>[database.py]")]
  node_trace_records[("Trace records<br/>[trace.py]")]
  node_trace_db[("Trace database<br/>[trace_database.py]")]
end

subgraph group_integrations["Model services"]
  node_settings["Runtime settings<br/>[config.py]"]
  node_llm_client["LLM client<br/>[llm.py]"]
end

node_user(("Questioner"))
node_llm_provider["LLM provider"]
node_docling["Docling parser"]
node_postgres[("PostgreSQL")]

node_user -.->|"asks"| node_frontend
node_frontend -.->|"submits query"| node_api_service
node_api_service -->|"runs pipeline"| node_orchestrator
node_api_service -->|"routes query"| node_router
node_orchestrator -->|"classifies"| node_router
node_orchestrator -->|"retrieves chunks"| node_retriever
node_orchestrator -->|"grades chunks"| node_grader
node_orchestrator -->|"uses prompts"| node_prompt_defs
node_router -->|"classifies with"| node_llm_client
node_grader -->|"grades with"| node_llm_client
node_orchestrator -.->|"synthesizes with"| node_llm_client
node_llm_client -->|"calls"| node_llm_provider
node_retriever -->|"searches"| node_primary_db
node_ingestion -.->|"extracts with"| node_docling
node_ingestion -.->|"embeds chunks"| node_embedding
node_embedding -.->|"stores vectors"| node_chunks
node_documents -.->|"persists in"| node_primary_db
node_chunks -.->|"persists in"| node_primary_db
node_orchestrator -->|"records stages"| node_trace_records
node_trace_records -->|"stored in"| node_trace_db
node_api_service -->|"opens session"| node_primary_db
node_api_service -->|"opens session"| node_trace_db
node_primary_db -.->|"stores corpus"| node_postgres
node_trace_db -->|"stores traces"| node_postgres
node_router -->|"reads config"| node_settings
node_llm_client -->|"selects provider"| node_settings

click node_frontend "https://github.com/vinodbavage31/agentic-rag-/blob/main/streamlit_app.py"
click node_api_service "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/main.py"
click node_orchestrator "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/agent.py"
click node_router "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/router.py"
click node_retriever "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/retrieval.py"
click node_grader "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/grader.py"
click node_prompt_defs "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/prompts.py"
click node_embedding "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/embedding.py"
click node_ingestion "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/ingestion.py"
click node_documents "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/models/document.py"
click node_chunks "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/models/document_chunk.py"
click node_primary_db "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/database.py"
click node_trace_records "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/models/trace.py"
click node_trace_db "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/trace_database.py"
click node_settings "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/config.py"
click node_llm_client "https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/llm.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_frontend,node_api_service toneBlue
class node_orchestrator,node_router,node_retriever,node_grader,node_prompt_defs,node_postgres toneAmber
class node_embedding,node_ingestion toneMint
class node_documents,node_chunks,node_primary_db,node_trace_records,node_trace_db toneRose
class node_settings,node_llm_client,node_user,node_llm_provider,node_docling toneIndigo
```

## Components

### User access

- [Streamlit UI](https://github.com/vinodbavage31/agentic-rag-/blob/main/streamlit_app.py): `streamlit_app.py`
- [FastAPI API](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/main.py): `app/main.py`

### RAG workflow

- [RAG orchestrator](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/agent.py): `app/pipeline/agent.py`
- [Query router](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/router.py): `app/pipeline/router.py`
- [Hybrid retrieval](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/retrieval.py): `app/pipeline/retrieval.py`
- [Relevance grader](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/grader.py): `app/pipeline/grader.py`
- [RAG prompts](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/prompts.py): `app/pipeline/prompts.py`

### Document corpus

- [Embedding model](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/embedding.py): `app/pipeline/embedding.py`
- [Document ingestion](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/ingestion.py): `app/pipeline/ingestion.py`

### Persistence

- [Document records](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/models/document.py): `app/models/document.py`
- [Chunk records](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/models/document_chunk.py): `app/models/document_chunk.py`
- [Corpus database](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/database.py): `app/core/database.py`
- [Trace records](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/models/trace.py): `app/models/trace.py`
- [Trace database](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/trace_database.py): `app/core/trace_database.py`

### Model services

- [Runtime settings](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/core/config.py): `app/core/config.py`
- [LLM client](https://github.com/vinodbavage31/agentic-rag-/blob/main/app/pipeline/llm.py): `app/pipeline/llm.py`

### Other components

- **Questioner**
- **LLM provider**
- **Docling parser**
- **PostgreSQL**

## Connections

- Questioner → Streamlit UI: asks
- Streamlit UI → FastAPI API: submits query
- FastAPI API → RAG orchestrator: runs pipeline (evidence: `app/main.py`)
- FastAPI API → Query router: routes query (evidence: `app/main.py`)
- RAG orchestrator → Query router: classifies (evidence: `app/pipeline/agent.py`)
- RAG orchestrator → Hybrid retrieval: retrieves chunks (evidence: `app/pipeline/agent.py`)
- RAG orchestrator → Relevance grader: grades chunks (evidence: `app/pipeline/agent.py`)
- RAG orchestrator → RAG prompts: uses prompts (evidence: `app/pipeline/agent.py`)
- Query router → LLM client: classifies with (evidence: `app/pipeline/router.py`)
- Relevance grader → LLM client: grades with (evidence: `app/pipeline/grader.py`)
- RAG orchestrator → LLM client: synthesizes with (evidence: `app/pipeline/agent.py`)
- LLM client → LLM provider: calls (evidence: `app/pipeline/llm.py`)
- Hybrid retrieval → Corpus database: searches (evidence: `app/pipeline/retrieval.py`)
- Document ingestion → Docling parser: extracts with (evidence: `readme.md`)
- Document ingestion → Embedding model: embeds chunks (evidence: `readme.md`)
- Embedding model → Chunk records: stores vectors (evidence: `readme.md`)
- Document records → Corpus database: persists in (evidence: `app/models/document.py`)
- Chunk records → Corpus database: persists in (evidence: `app/models/document_chunk.py`)
- RAG orchestrator → Trace records: records stages (evidence: `app/pipeline/agent.py`)
- Trace records → Trace database: stored in (evidence: `readme.md`)
- FastAPI API → Corpus database: opens session (evidence: `app/main.py`)
- FastAPI API → Trace database: opens session (evidence: `app/main.py`)
- Corpus database → PostgreSQL: stores corpus (evidence: `readme.md`)
- Trace database → PostgreSQL: stores traces (evidence: `readme.md`)
- Query router → Runtime settings: reads config (evidence: `app/pipeline/router.py`)
- LLM client → Runtime settings: selects provider (evidence: `app/pipeline/llm.py`)
