# palliplease/rag-document-assistant architecture

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

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

## Overview

This is a local RAG assistant for answering questions about a college handbook. The documented workflow loads a PDF, splits it into chunks, and indexes them in Chroma; the Streamlit app then sends a question through a retrieval-and-generation chain and displays the answer. The chain retrieves relevant chunks, formats them as context, prompts a local Ollama model, and parses its response. The PDF itself is not present in the tree, so its source is represented by the ingestion code. The README also mentions a RAG chain and local operation; details below follow the sampled source.

Main entry points: [`chat.py`](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py) (QA chain setup), [`app.py`](https://github.com/palliplease/rag-document-assistant/blob/master/app.py) (Streamlit app), [`ingest.py`](https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py) (Vector indexing), [`vectordb`](https://github.com/palliplease/rag-document-assistant/tree/master/vectordb) (Chroma store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion"]
  node_ingest_runner["Ingest runner<br/>[ingest.py]"]
  node_pdf_loader["PDF loading<br/>[ingest.py]"]
  node_chunker["Text splitting<br/>[ingest.py]"]
  node_indexer["Vector indexing<br/>[ingest.py]"]
  node_embeddings["Ollama embeddings<br/>[ingest.py]"]
end

subgraph group_qa["Question answering"]
  node_vectordb[("Chroma store")]
  node_qa_builder["QA chain setup<br/>[chat.py]"]
  node_retriever["Similarity retriever<br/>[chat.py]"]
  node_formatter["Context formatter<br/>[chat.py]"]
  node_prompt["Prompt template<br/>[chat.py]"]
  node_llm["Ollama LLM<br/>[chat.py]"]
  node_parser["String parser<br/>[chat.py]"]
end

subgraph group_ui["User interface"]
  node_streamlit["Streamlit app<br/>[app.py]"]
end

node_user(("Student"))
node_pdf["Handbook PDF"]
node_ollama["Ollama runtime"]

node_ingest_runner -->|"calls"| node_pdf_loader
node_pdf_loader -->|"loads"| node_pdf
node_ingest_runner -->|"calls"| node_chunker
node_pdf_loader -->|"passes pages"| node_chunker
node_ingest_runner -->|"calls"| node_indexer
node_chunker -->|"passes chunks"| node_indexer
node_indexer -->|"requests vectors"| node_embeddings
node_embeddings -->|"embeds with"| node_ollama
node_indexer -->|"writes vectors"| node_vectordb
node_user -->|"asks"| node_streamlit
node_streamlit -->|"builds chain"| node_qa_builder
node_streamlit -->|"receives reference"| node_retriever
node_streamlit -->|"invokes chain"| node_qa_builder
node_qa_builder -->|"dispatches query"| node_retriever
node_retriever -->|"reads matches"| node_vectordb
node_qa_builder -->|"formats retrieved docs"| node_formatter
node_qa_builder -->|"fills template"| node_prompt
node_qa_builder -->|"sends prompt"| node_llm
node_llm -->|"runs model"| node_ollama
node_qa_builder -->|"parses output"| node_parser
node_parser -->|"returns answer"| node_streamlit

click node_ingest_runner "https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py"
click node_pdf_loader "https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py"
click node_chunker "https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py"
click node_indexer "https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py"
click node_embeddings "https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py"
click node_vectordb "https://github.com/palliplease/rag-document-assistant/tree/master/vectordb"
click node_streamlit "https://github.com/palliplease/rag-document-assistant/blob/master/app.py"
click node_qa_builder "https://github.com/palliplease/rag-document-assistant/blob/master/chat.py"
click node_retriever "https://github.com/palliplease/rag-document-assistant/blob/master/chat.py"
click node_formatter "https://github.com/palliplease/rag-document-assistant/blob/master/chat.py"
click node_prompt "https://github.com/palliplease/rag-document-assistant/blob/master/chat.py"
click node_llm "https://github.com/palliplease/rag-document-assistant/blob/master/chat.py"
click node_parser "https://github.com/palliplease/rag-document-assistant/blob/master/chat.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_chunker,node_indexer,node_embeddings toneBlue
class node_vectordb,node_qa_builder,node_retriever,node_formatter,node_prompt,node_llm,node_parser toneAmber
class node_streamlit toneMint
class node_user,node_pdf,node_ollama toneIndigo
```

## Components

### Ingestion

- [Ingest runner](https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py): `ingest.py`
- [PDF loading](https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py): `ingest.py`
- [Text splitting](https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py): `ingest.py`
- [Vector indexing](https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py): `ingest.py`
- [Ollama embeddings](https://github.com/palliplease/rag-document-assistant/blob/master/ingest.py): `ingest.py`

### Question answering

- [Chroma store](https://github.com/palliplease/rag-document-assistant/tree/master/vectordb): `vectordb`
- [QA chain setup](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py): `chat.py`
- [Similarity retriever](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py): `chat.py`
- [Context formatter](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py): `chat.py`
- [Prompt template](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py): `chat.py`
- [Ollama LLM](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py): `chat.py`
- [String parser](https://github.com/palliplease/rag-document-assistant/blob/master/chat.py): `chat.py`

### User interface

- [Streamlit app](https://github.com/palliplease/rag-document-assistant/blob/master/app.py): `app.py`

### Other components

- **Student**
- **Handbook PDF**
- **Ollama runtime**

## Connections

- Ingest runner → PDF loading: calls
- PDF loading → Handbook PDF: loads
- Ingest runner → Text splitting: calls
- PDF loading → Text splitting: passes pages
- Ingest runner → Vector indexing: calls
- Text splitting → Vector indexing: passes chunks
- Vector indexing → Ollama embeddings: requests vectors
- Ollama embeddings → Ollama runtime: embeds with
- Vector indexing → Chroma store: writes vectors
- Student → Streamlit app: asks
- Streamlit app → QA chain setup: builds chain
- Streamlit app → Similarity retriever: receives reference
- Streamlit app → QA chain setup: invokes chain
- QA chain setup → Similarity retriever: dispatches query
- Similarity retriever → Chroma store: reads matches
- QA chain setup → Context formatter: formats retrieved docs
- QA chain setup → Prompt template: fills template
- QA chain setup → Ollama LLM: sends prompt
- Ollama LLM → Ollama runtime: runs model
- QA chain setup → String parser: parses output
- String parser → Streamlit app: returns answer
