# brianmarulanda/ai-document-assistant-rag architecture

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

- Interactive diagram: https://gitdiagram.com/brianmarulanda/ai-document-assistant-rag
- Repository: https://github.com/brianmarulanda/ai-document-assistant-rag

## Overview

This is a local RAG document assistant. Its main workflow ingests a PDF, splits it into chunks, embeds and persists them, then accepts questions, retrieves relevant chunks, and generates answers with a local Ollama model. Users can query through the Streamlit chat interface or a command-line sample; the UI also displays source excerpts. The graph focuses on runtime modules shown in the excerpts. The README documents the local model and storage choices; no separate source for those services is present in the tree.

Main entry points: [`src/retriever/query_engine.py`](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/retriever/query_engine.py) (RAG query engine), [`run_ingest.py`](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/run_ingest.py) (Ingestion runner), [`src/vectorstore/store.py`](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/vectorstore/store.py) (Vector store manager), [`app.py`](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/app.py) (Streamlit chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Document ingestion"]
  node_ingest_runner["Ingestion runner<br/>[run_ingest.py]"]
  node_pdf_loader["PDF loader and splitter<br/>[loader.py]"]
  node_vector_manager["Vector store manager<br/>[store.py]"]
end

subgraph group_retrieval["Query and answers"]
  node_query_engine["RAG query engine<br/>[query_engine.py]"]
end

subgraph group_interfaces["User interfaces"]
  node_streamlit_app["Streamlit chat<br/>[app.py]"]
  node_cli_query["CLI query runner<br/>[run_query.py]"]
end

subgraph group_local_services["Local services"]
  node_embedding_model["Embedding model"]
  node_chroma[("Persistent Chroma store")]
  node_ollama["Ollama LLM"]
end

node_user(("User"))
node_pdf["Input PDF"]

node_user -->|"starts ingestion"| node_ingest_runner
node_ingest_runner -->|"loads and splits"| node_pdf_loader
node_pdf -->|"provides PDF"| node_pdf_loader
node_ingest_runner -->|"indexes chunks"| node_vector_manager
node_vector_manager -->|"embeds chunks"| node_embedding_model
node_vector_manager -->|"persists vectors"| node_chroma
node_user -->|"asks questions"| node_streamlit_app
node_user -->|"runs sample query"| node_cli_query
node_streamlit_app -->|"submits question"| node_query_engine
node_cli_query -->|"submits question"| node_query_engine
node_query_engine -->|"embeds query"| node_embedding_model
node_query_engine -->|"retrieves chunks"| node_chroma
node_query_engine -->|"generates answer"| node_ollama

click node_ingest_runner "https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/run_ingest.py"
click node_pdf_loader "https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/ingester/loader.py"
click node_vector_manager "https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/vectorstore/store.py"
click node_streamlit_app "https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/app.py"
click node_cli_query "https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/run_query.py"
click node_query_engine "https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/retriever/query_engine.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_ingest_runner,node_pdf_loader,node_vector_manager,node_user toneBlue
class node_query_engine toneAmber
class node_streamlit_app,node_cli_query toneMint
class node_embedding_model,node_chroma,node_ollama toneRose
class node_pdf toneIndigo
```

## Components

### Document ingestion

- [Ingestion runner](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/run_ingest.py): `run_ingest.py`
- [PDF loader and splitter](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/ingester/loader.py): `src/ingester/loader.py`
- [Vector store manager](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/vectorstore/store.py): `src/vectorstore/store.py`

### Query and answers

- [RAG query engine](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/src/retriever/query_engine.py): `src/retriever/query_engine.py`

### User interfaces

- [Streamlit chat](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/app.py): `app.py`
- [CLI query runner](https://github.com/brianmarulanda/ai-document-assistant-rag/blob/main/run_query.py): `run_query.py`

### Local services

- **Embedding model**
- **Persistent Chroma store**
- **Ollama LLM**

### Other components

- **User**
- **Input PDF**

## Connections

- User → Ingestion runner: starts ingestion (evidence: `README.md`)
- Ingestion runner → PDF loader and splitter: loads and splits (evidence: `run_ingest.py`)
- Input PDF → PDF loader and splitter: provides PDF
- Ingestion runner → Vector store manager: indexes chunks (evidence: `run_ingest.py`)
- Vector store manager → Embedding model: embeds chunks (evidence: `src/vectorstore/store.py`)
- Vector store manager → Persistent Chroma store: persists vectors (evidence: `src/vectorstore/store.py`)
- User → Streamlit chat: asks questions (evidence: `README.md`)
- User → CLI query runner: runs sample query (evidence: `README.md`)
- Streamlit chat → RAG query engine: submits question (evidence: `app.py`)
- CLI query runner → RAG query engine: submits question (evidence: `run_query.py`)
- RAG query engine → Embedding model: embeds query (evidence: `src/retriever/query_engine.py`)
- RAG query engine → Persistent Chroma store: retrieves chunks (evidence: `src/retriever/query_engine.py`)
- RAG query engine → Ollama LLM: generates answer (evidence: `src/retriever/query_engine.py`)
