# ryzen7-hermes-cpu/local-rag-knowledge-base architecture

> Architecture diagram of the GitHub repository ryzen7-hermes-cpu/local-rag-knowledge-base, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ryzen7-hermes-cpu/local-rag-knowledge-base
- Repository: https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base

## Overview

Local RAG Knowledge Base collects documentation from repositories and web sources, indexes local Markdown/text content, and answers questions through retrieval-augmented chat. CLI and Streamlit are the user-facing entry points; both rely on RAGChatbot for initialization and question answering. The sampled implementation shows document loading and chunking, local embeddings with Chroma, and generation through Ollama. Downloader implementations are in one module; their individual source types are grouped. The README documents capabilities beyond the sampled code, so those are represented at the subsystem level.

Main entry points: [`src/knowledge_base_app/rag_chat.py`](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/rag_chat.py) (RAG chatbot), [`src/knowledge_base_app/cli.py`](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/cli.py) (CLI commands), [`app.py`](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/app.py) (Streamlit app), [`src/knowledge_base_app/downloaders/__init__.py`](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/downloaders/__init__.py) (Source downloaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_streamlit["Streamlit app<br/>[app.py]"]
end

subgraph group_acquisition["Source acquisition"]
  node_downloaders["Source downloaders<br/>[__init__.py]"]
  node_local_docs["Local documents"]
end

subgraph group_indexing["Ingestion and index"]
  node_loader["Document loader"]
  node_chunker["Chunk preparation"]
  node_vector_store["Vector store<br/>[vector_store.py]"]
  node_chroma[("Chroma index<br/>[vector_store.py]")]
end

subgraph group_qa["Retrieval and answers"]
  node_chatbot["RAG chatbot<br/>[rag_chat.py]"]
  node_retrieval["Similarity search<br/>[vector_store.py]"]
  node_ollama_client["Ollama client<br/>[local_llm.py]"]
  node_settings["Runtime settings<br/>[config.py]"]
end

node_cli_user(("CLI user"))
node_web_user(("Web user"))
node_external_sources(("GitHub and docs"))
node_embeddings["Sentence embeddings"]
node_ollama(("Ollama model"))

node_cli_user -->|"runs commands"| node_cli
node_web_user -->|"asks questions"| node_streamlit
node_cli -->|"dispatches download"| node_downloaders
node_downloaders -->|"fetches or clones"| node_external_sources
node_downloaders -->|"writes source files"| node_local_docs
node_cli -->|"starts ingest or chat"| node_chatbot
node_streamlit -->|"initializes and asks"| node_chatbot
node_chatbot -->|"loads local documents"| node_loader
node_loader -->|"reads files"| node_local_docs
node_chatbot -->|"prepares documents"| node_chunker
node_chatbot -->|"adds prepared documents"| node_vector_store
node_vector_store -->|"encodes documents"| node_embeddings
node_vector_store -->|"stores vectors"| node_chroma
node_chatbot -->|"searches question"| node_retrieval
node_retrieval -->|"encodes query"| node_embeddings
node_retrieval -->|"queries vectors"| node_chroma
node_chatbot -->|"generates answer"| node_ollama_client
node_ollama_client -->|"sends prompt"| node_ollama
node_chatbot -->|"reads configuration"| node_settings
node_cli -->|"reads defaults"| node_settings
node_streamlit -->|"reads defaults"| node_settings

click node_cli "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/cli.py"
click node_streamlit "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/app.py"
click node_downloaders "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/downloaders/__init__.py"
click node_chatbot "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/rag_chat.py"
click node_loader "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/document_pipeline.py"
click node_chunker "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/document_pipeline.py"
click node_vector_store "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/vector_store.py"
click node_chroma "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/vector_store.py"
click node_retrieval "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/vector_store.py"
click node_ollama_client "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/local_llm.py"
click node_settings "https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/config.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_streamlit,node_cli_user,node_web_user toneBlue
class node_downloaders,node_local_docs toneAmber
class node_loader,node_chunker,node_vector_store,node_chroma toneMint
class node_chatbot,node_retrieval,node_ollama_client,node_settings toneRose
class node_external_sources,node_embeddings,node_ollama toneIndigo
```

## Components

### User interfaces

- [CLI commands](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/cli.py): `src/knowledge_base_app/cli.py`
- [Streamlit app](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/app.py): `app.py`

### Source acquisition

- [Source downloaders](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/downloaders/__init__.py): `src/knowledge_base_app/downloaders/__init__.py`
- **Local documents**

### Ingestion and index

- [Document loader](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/document_pipeline.py): `src/knowledge_base_app/document_pipeline.py`
- [Chunk preparation](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/document_pipeline.py): `src/knowledge_base_app/document_pipeline.py`
- [Vector store](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/vector_store.py): `src/knowledge_base_app/vector_store.py`
- [Chroma index](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/vector_store.py): `src/knowledge_base_app/vector_store.py`

### Retrieval and answers

- [RAG chatbot](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/rag_chat.py): `src/knowledge_base_app/rag_chat.py`
- [Similarity search](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/vector_store.py): `src/knowledge_base_app/vector_store.py`
- [Ollama client](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/local_llm.py): `src/knowledge_base_app/local_llm.py`
- [Runtime settings](https://github.com/ryzen7-hermes-cpu/local-rag-knowledge-base/blob/main/src/knowledge_base_app/config.py): `src/knowledge_base_app/config.py`

### Other components

- **CLI user**
- **Web user**
- **GitHub and docs**
- **Sentence embeddings**
- **Ollama model**

## Connections

- CLI user → CLI commands: runs commands
- Web user → Streamlit app: asks questions
- CLI commands → Source downloaders: dispatches download
- Source downloaders → GitHub and docs: fetches or clones
- Source downloaders → Local documents: writes source files
- CLI commands → RAG chatbot: starts ingest or chat
- Streamlit app → RAG chatbot: initializes and asks
- RAG chatbot → Document loader: loads local documents
- Document loader → Local documents: reads files
- RAG chatbot → Chunk preparation: prepares documents
- RAG chatbot → Vector store: adds prepared documents
- Vector store → Sentence embeddings: encodes documents
- Vector store → Chroma index: stores vectors
- RAG chatbot → Similarity search: searches question
- Similarity search → Sentence embeddings: encodes query
- Similarity search → Chroma index: queries vectors
- RAG chatbot → Ollama client: generates answer
- Ollama client → Ollama model: sends prompt
- RAG chatbot → Runtime settings: reads configuration
- CLI commands → Runtime settings: reads defaults
- Streamlit app → Runtime settings: reads defaults
