# dilipkumar56/local-ai-rag architecture

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

- Interactive diagram: https://gitdiagram.com/dilipkumar56/local-ai-rag
- Repository: https://github.com/dilipkumar56/local-ai-rag

## Overview

The repository contains two separate document-grounded Azure assistants: a local CLI over user-supplied text/PDF files, and a Streamlit AZ-104 tutor over curated Microsoft Learn pages. Both ingest and retrieve document chunks from Chroma, then produce answers with source citations; the hosted tutor additionally supports index refresh and chat history. The graph shows the main documented workflows and the sampled call relationships. The README documents model providers and Learn content scope; unsampled modules and optional tools are not expanded.

Main entry points: [`app/hosted_rag.py`](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/hosted_rag.py) (Study answer/index), [`app/rag.py`](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.py) (Grounded answers), [`app/streamlit_app.py`](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/streamlit_app.py) (Streamlit chat UI), [`data`](https://github.com/dilipkumar56/local-ai-rag/tree/main/data) (Local Chroma index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_local["Local CLI Assistant"]
  node_cli["CLI chat loop<br/>[main.py]"]
  node_local_answer["Grounded answers<br/>[rag.py]"]
  node_local_ingest["Local ingestion<br/>[vector_db.py]"]
end

subgraph group_hosted["Hosted AZ-104 Tutor"]
  node_study_ui["Streamlit chat UI<br/>[streamlit_app.py]"]
  node_hosted_rag["Study answer/index<br/>[hosted_rag.py]"]
  node_learn_sources["Learn fetch and chunk<br/>[az104_sources.py]"]
  node_hosted_store[("AZ-104 Chroma index")]
end

subgraph group_shared["Document Retrieval"]
  node_file_loader["Text/PDF loading<br/>[documents.py]"]
  node_local_store[("Local Chroma index")]
  node_local_retrieval["Local search<br/>[rag.py]"]
  node_citation["Source citations<br/>[rag.py]"]
end

node_learner(("CLI user"))
node_ollama["Ollama models"]
node_web_user(("Study assistant user"))
node_learn["Microsoft Learn"]
node_gemini["Gemini API"]

node_learner -->|"asks"| node_cli
node_cli -->|"calls"| node_local_answer
node_local_answer -->|"retrieves"| node_local_retrieval
node_local_retrieval -->|"searches"| node_local_store
node_local_answer -->|"embeds and answers"| node_ollama
node_local_answer -->|"formats"| node_citation
node_local_ingest -->|"loads and splits"| node_file_loader
node_local_ingest -->|"writes chunks"| node_local_store
node_file_loader -.->|"supplies chunks"| node_local_store
node_web_user -->|"asks"| node_study_ui
node_study_ui -->|"calls"| node_hosted_rag
node_hosted_rag -->|"loads and splits"| node_learn_sources
node_learn_sources -->|"fetches pages"| node_learn
node_hosted_rag -->|"indexes and searches"| node_hosted_store
node_hosted_rag -->|"embeds and generates"| node_gemini
node_hosted_rag -->|"returns answer and sources"| node_study_ui
node_study_ui -->|"shows citations"| node_web_user

click node_cli "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/main.py"
click node_local_answer "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.py"
click node_local_ingest "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/vector_db.py"
click node_file_loader "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/documents.py"
click node_local_store "https://github.com/dilipkumar56/local-ai-rag/tree/main/data"
click node_study_ui "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/streamlit_app.py"
click node_hosted_rag "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/hosted_rag.py"
click node_learn_sources "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/az104_sources.py"
click node_hosted_store "https://github.com/dilipkumar56/local-ai-rag/tree/main/data"
click node_local_retrieval "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.py"
click node_citation "https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.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_cli,node_local_answer,node_local_ingest,node_learner,node_web_user toneBlue
class node_study_ui,node_hosted_rag,node_learn_sources,node_hosted_store toneAmber
class node_file_loader,node_local_store,node_local_retrieval,node_citation,node_gemini toneMint
class node_ollama,node_learn toneIndigo
```

## Components

### Local CLI Assistant

- [CLI chat loop](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/main.py): `app/main.py`
- [Grounded answers](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.py): `app/rag.py`
- [Local ingestion](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/vector_db.py): `app/vector_db.py`

### Hosted AZ-104 Tutor

- [Streamlit chat UI](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Study answer/index](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/hosted_rag.py): `app/hosted_rag.py`
- [Learn fetch and chunk](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/az104_sources.py): `app/az104_sources.py`
- [AZ-104 Chroma index](https://github.com/dilipkumar56/local-ai-rag/tree/main/data): `data`

### Document Retrieval

- [Text/PDF loading](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/documents.py): `app/documents.py`
- [Local Chroma index](https://github.com/dilipkumar56/local-ai-rag/tree/main/data): `data`
- [Local search](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.py): `app/rag.py`
- [Source citations](https://github.com/dilipkumar56/local-ai-rag/blob/main/app/rag.py): `app/rag.py`

### Other components

- **CLI user**
- **Ollama models**
- **Study assistant user**
- **Microsoft Learn**
- **Gemini API**

## Connections

- CLI user → CLI chat loop: asks (evidence: `Readme.md`)
- CLI chat loop → Grounded answers: calls (evidence: `app/main.py`)
- Grounded answers → Local search: retrieves (evidence: `app/rag.py`)
- Local search → Local Chroma index: searches (evidence: `app/rag.py`)
- Grounded answers → Ollama models: embeds and answers (evidence: `Readme.md`)
- Grounded answers → Source citations: formats (evidence: `app/rag.py`)
- Local ingestion → Text/PDF loading: loads and splits (evidence: `app/vector_db.py`)
- Local ingestion → Local Chroma index: writes chunks (evidence: `app/vector_db.py`)
- Text/PDF loading → Local Chroma index: supplies chunks
- Study assistant user → Streamlit chat UI: asks (evidence: `Readme.md`)
- Streamlit chat UI → Study answer/index: calls (evidence: `app/streamlit_app.py`)
- Study answer/index → Learn fetch and chunk: loads and splits (evidence: `app/hosted_rag.py`)
- Learn fetch and chunk → Microsoft Learn: fetches pages (evidence: `app/az104_sources.py`)
- Study answer/index → AZ-104 Chroma index: indexes and searches (evidence: `app/hosted_rag.py`)
- Study answer/index → Gemini API: embeds and generates (evidence: `app/hosted_rag.py`)
- Study answer/index → Streamlit chat UI: returns answer and sources (evidence: `app/streamlit_app.py`)
- Streamlit chat UI → Study assistant user: shows citations (evidence: `app/streamlit_app.py`)
