# ammaryaqoob/document-assistant-rag-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/ammaryaqoob/document-assistant-rag-pipeline
- Repository: https://github.com/ammaryaqoob/document-assistant-rag-pipeline

## Overview

This is a FastAPI document-assistant with two user-facing paths: chat requests are routed to a chat service, while RAG requests ingest a text document, retrieve relevant chunks, and generate an answer from that context. The RAG implementation separates document reading/chunking, embeddings, and vector storage; both chat and RAG use an OpenAI-compatible local model service. The graph follows relationships visible in the excerpts and README; the test route and configuration are not expanded because their behavior is not shown.

Main entry points: [`app/services/rag.py`](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/services/rag.py) (RAG service), [`app/main.py`](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/main.py) (FastAPI app), [`app/routers/chat.py`](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/chat.py) (Chat route), [`app/routers/rag.py`](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/rag.py) (RAG routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_app["FastAPI app<br/>[main.py]"]
  node_chat_route["Chat route<br/>[chat.py]"]
  node_rag_route["RAG routes<br/>[rag.py]"]
  node_test_route["Test route<br/>[test.py]"]
end

subgraph group_chat["Chat"]
  node_chat_service["Chat service<br/>[chat.py]"]
  node_chat_schema["Chat schemas<br/>[chat.py]"]
end

subgraph group_rag["Document RAG"]
  node_rag_service["RAG service<br/>[rag.py]"]
  node_text_reader["Document reader<br/>[textreader.py]"]
  node_source_doc["Sample document<br/>[test.txt]"]
end

subgraph group_infra["Model and storage"]
  node_embedding["Embedding client<br/>[embedding.py]"]
  node_vector_store[("Chroma collection<br/>[chromedb.py]")]
  node_model_service["Local model API"]
end

node_user(("API user"))

node_user -->|"sends requests"| node_app
node_app -->|"registers"| node_chat_route
node_app -->|"registers"| node_rag_route
node_app -->|"registers"| node_test_route
node_chat_route -->|"validates with"| node_chat_schema
node_chat_route -->|"calls"| node_chat_service
node_chat_service -->|"uses"| node_chat_schema
node_chat_service -->|"requests completions"| node_model_service
node_rag_route -->|"calls"| node_rag_service
node_rag_route -->|"ingests"| node_source_doc
node_rag_service -->|"chunks documents"| node_text_reader
node_rag_service -->|"embeds text"| node_embedding
node_rag_service -->|"queries and upserts"| node_vector_store
node_rag_service -->|"requests completions"| node_model_service
node_embedding -->|"requests embeddings"| node_model_service

click node_app "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/main.py"
click node_chat_route "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/chat.py"
click node_rag_route "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/rag.py"
click node_test_route "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/test.py"
click node_chat_service "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/services/chat.py"
click node_chat_schema "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/interface/chat.py"
click node_rag_service "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/services/rag.py"
click node_text_reader "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/readhandler/textreader.py"
click node_source_doc "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/files/test.txt"
click node_embedding "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/embeddings/embedding.py"
click node_vector_store "https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/database/chromedb.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_chat_route,node_rag_route,node_test_route,node_user toneBlue
class node_chat_service,node_chat_schema toneAmber
class node_rag_service,node_text_reader,node_source_doc toneMint
class node_embedding,node_vector_store,node_model_service toneRose
```

## Components

### API

- [FastAPI app](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/main.py): `app/main.py`
- [Chat route](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/chat.py): `app/routers/chat.py`
- [RAG routes](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/rag.py): `app/routers/rag.py`
- [Test route](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/routers/test.py): `app/routers/test.py`

### Chat

- [Chat service](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/services/chat.py): `app/services/chat.py`
- [Chat schemas](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/interface/chat.py): `app/interface/chat.py`

### Document RAG

- [RAG service](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/services/rag.py): `app/services/rag.py`
- [Document reader](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/readhandler/textreader.py): `app/readhandler/textreader.py`
- [Sample document](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/files/test.txt): `app/files/test.txt`

### Model and storage

- [Embedding client](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/embeddings/embedding.py): `app/embeddings/embedding.py`
- [Chroma collection](https://github.com/ammaryaqoob/document-assistant-rag-pipeline/blob/main/app/database/chromedb.py): `app/database/chromedb.py`
- **Local model API**

### Other components

- **API user**

## Connections

- API user → FastAPI app: sends requests
- FastAPI app → Chat route: registers (evidence: `app/main.py`)
- FastAPI app → RAG routes: registers (evidence: `app/main.py`)
- FastAPI app → Test route: registers (evidence: `app/main.py`)
- Chat route → Chat schemas: validates with (evidence: `app/routers/chat.py`)
- Chat route → Chat service: calls (evidence: `app/routers/chat.py`)
- Chat service → Chat schemas: uses (evidence: `app/services/chat.py`)
- Chat service → Local model API: requests completions (evidence: `app/services/chat.py`)
- RAG routes → RAG service: calls (evidence: `app/routers/rag.py`)
- RAG routes → Sample document: ingests (evidence: `app/routers/rag.py`)
- RAG service → Document reader: chunks documents (evidence: `app/services/rag.py`)
- RAG service → Embedding client: embeds text (evidence: `app/services/rag.py`)
- RAG service → Chroma collection: queries and upserts (evidence: `app/services/rag.py`)
- RAG service → Local model API: requests completions (evidence: `app/services/rag.py`)
- Embedding client → Local model API: requests embeddings (evidence: `app/embeddings/embedding.py`)
