# mohith292005/ragchatbot architecture

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

- Interactive diagram: https://gitdiagram.com/mohith292005/ragchatbot
- Repository: https://github.com/mohith292005/ragchatbot

## Overview

DocQuery is a document-chat product with two user interfaces: a React client backed by FastAPI and a Streamlit app that invokes the same RAG modules directly. The primary workflow uploads and extracts a document, chunks and indexes it, then retrieves relevant chunks for a grounded, cited LLM answer. The graph preserves ingestion, retrieval, generation, and both UI paths. The README documents broader formats and capabilities; source-level edges are limited to shown calls, while README evidence supports documented model behavior.

Main entry points: [`streamlit_app.py`](https://github.com/mohith292005/ragchatbot/blob/main/streamlit_app.py) (Streamlit UI), [`backend/api/main.py`](https://github.com/mohith292005/ragchatbot/blob/main/backend/api/main.py) (FastAPI routes), [`backend/ingest/vectorstore.py`](https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/vectorstore.py) (Vector store), [`backend/retriever/retriever.py`](https://github.com/mohith292005/ragchatbot/blob/main/backend/retriever/retriever.py) (Semantic retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_react["React chat UI<br/>[App.jsx]"]
  node_streamlit["Streamlit UI<br/>[streamlit_app.py]"]
end

subgraph group_api["API orchestration"]
  node_fastapi["FastAPI routes<br/>[main.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_extract["Text extraction<br/>[extractor.py]"]
  node_chunk["Chunking<br/>[chunker.py]"]
end

subgraph group_qa["Question answering"]
  node_retrieve["Semantic retrieval<br/>[retriever.py]"]
  node_answer["Grounded answer<br/>[llm.py]"]
end

subgraph group_storage["Persistence"]
  node_files["Uploaded files"]
  node_vector[("Vector store<br/>[vectorstore.py]")]
end

node_user(("User"))
node_openrouter{{"OpenRouter"}}

node_user -->|"uses"| node_react
node_user -->|"uses"| node_streamlit
node_react -->|"requests"| node_fastapi
node_fastapi -->|"writes upload"| node_files
node_fastapi -->|"extracts text"| node_extract
node_fastapi -->|"chunks text"| node_chunk
node_fastapi -->|"adds chunks"| node_vector
node_fastapi -->|"retrieves chunks"| node_retrieve
node_fastapi -->|"generates answer"| node_answer
node_streamlit -->|"writes upload"| node_files
node_streamlit -->|"extracts text"| node_extract
node_streamlit -->|"chunks text"| node_chunk
node_streamlit -->|"adds chunks"| node_vector
node_streamlit -->|"retrieves chunks"| node_retrieve
node_streamlit -->|"generates answer"| node_answer
node_retrieve -->|"queries"| node_vector
node_vector -->|"embeds chunks"| node_openrouter
node_answer -->|"requests completion"| node_openrouter

click node_react "https://github.com/mohith292005/ragchatbot/blob/main/frontend/src/App.jsx"
click node_streamlit "https://github.com/mohith292005/ragchatbot/blob/main/streamlit_app.py"
click node_fastapi "https://github.com/mohith292005/ragchatbot/blob/main/backend/api/main.py"
click node_files "https://github.com/mohith292005/ragchatbot/tree/main/data"
click node_extract "https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/extractor.py"
click node_chunk "https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/chunker.py"
click node_vector "https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/vectorstore.py"
click node_retrieve "https://github.com/mohith292005/ragchatbot/blob/main/backend/retriever/retriever.py"
click node_answer "https://github.com/mohith292005/ragchatbot/blob/main/backend/api/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_react,node_streamlit,node_user toneBlue
class node_fastapi toneAmber
class node_extract,node_chunk,node_openrouter toneMint
class node_retrieve,node_answer toneRose
class node_files,node_vector toneIndigo
```

## Components

### User interfaces

- [React chat UI](https://github.com/mohith292005/ragchatbot/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Streamlit UI](https://github.com/mohith292005/ragchatbot/blob/main/streamlit_app.py): `streamlit_app.py`

### API orchestration

- [FastAPI routes](https://github.com/mohith292005/ragchatbot/blob/main/backend/api/main.py): `backend/api/main.py`

### Document ingestion

- [Text extraction](https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/extractor.py): `backend/ingest/extractor.py`
- [Chunking](https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/chunker.py): `backend/ingest/chunker.py`

### Question answering

- [Semantic retrieval](https://github.com/mohith292005/ragchatbot/blob/main/backend/retriever/retriever.py): `backend/retriever/retriever.py`
- [Grounded answer](https://github.com/mohith292005/ragchatbot/blob/main/backend/api/llm.py): `backend/api/llm.py`

### Persistence

- [Uploaded files](https://github.com/mohith292005/ragchatbot/tree/main/data): `data`
- [Vector store](https://github.com/mohith292005/ragchatbot/blob/main/backend/ingest/vectorstore.py): `backend/ingest/vectorstore.py`

### Other components

- **User**
- **OpenRouter**

## Connections

- User → React chat UI: uses (evidence: `frontend/src/App.jsx`)
- User → Streamlit UI: uses (evidence: `README.md`)
- React chat UI → FastAPI routes: requests (evidence: `frontend/src/App.jsx`)
- FastAPI routes → Uploaded files: writes upload (evidence: `backend/api/main.py`)
- FastAPI routes → Text extraction: extracts text (evidence: `backend/api/main.py`)
- FastAPI routes → Chunking: chunks text (evidence: `backend/api/main.py`)
- FastAPI routes → Vector store: adds chunks (evidence: `backend/api/main.py`)
- FastAPI routes → Semantic retrieval: retrieves chunks (evidence: `backend/api/main.py`)
- FastAPI routes → Grounded answer: generates answer (evidence: `backend/api/main.py`)
- Streamlit UI → Uploaded files: writes upload (evidence: `streamlit_app.py`)
- Streamlit UI → Text extraction: extracts text (evidence: `streamlit_app.py`)
- Streamlit UI → Chunking: chunks text (evidence: `streamlit_app.py`)
- Streamlit UI → Vector store: adds chunks (evidence: `streamlit_app.py`)
- Streamlit UI → Semantic retrieval: retrieves chunks (evidence: `streamlit_app.py`)
- Streamlit UI → Grounded answer: generates answer (evidence: `streamlit_app.py`)
- Semantic retrieval → Vector store: queries (evidence: `backend/retriever/retriever.py`)
- Vector store → OpenRouter: embeds chunks (evidence: `README.md`)
- Grounded answer → OpenRouter: requests completion (evidence: `backend/api/llm.py`)
