# jjwheatley/mini-rag architecture

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

- Interactive diagram: https://gitdiagram.com/jjwheatley/mini-rag
- Repository: https://github.com/jjwheatley/mini-rag

## Overview

Mini-RAG is an Obsidian plugin for chatting with a local Ollama model using selected vault notes as context. Users open a chat from the command palette or file menus; the plugin loads note or folder context, builds a searchable embedding index, retrieves relevant excerpts for questions, and displays streamed responses. It also supports context-free chats, model/settings management, summaries, and saving conversations. Relationships reflect the shown source references and README; some details of unsampled implementations are omitted.

Main entry points: [`main.ts`](https://github.com/jjwheatley/mini-rag/blob/main/main.ts) (Plugin lifecycle), [`src/classes/chat-window.ts`](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/chat-window.ts) (Chat view), [`src/classes/contextualizer.ts`](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/contextualizer.ts) (Context assembly), [`src/classes/ollama-wrapper.ts`](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ollama-wrapper.ts) (Ollama client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Plugin entry"]
  node_plugin["Plugin lifecycle<br/>[main.ts]"]
  node_menus["Context menus<br/>[menu-manager.ts]"]
end

subgraph group_rag["Context retrieval"]
  node_context["Context assembly<br/>[contextualizer.ts]"]
  node_index["Vector index<br/>[vector-index.ts]"]
end

subgraph group_chat["Chat experience"]
  node_chatview["Chat view<br/>[chat-window.ts]"]
  node_conversation["Conversation display"]
  node_input["Chat input<br/>[chat-input.ts]"]
  node_buttons["Chat actions<br/>[chat-buttons.ts]"]
  node_messages["Message history<br/>[chat-messages.ts]"]
  node_loading["Loading indicator"]
  node_saveas["Save-as modal"]
end

subgraph group_config["Settings and models"]
  node_ollama["Ollama client<br/>[ollama-wrapper.ts]"]
  node_settings["Plugin settings<br/>[settings-tab.ts]"]
  node_defaults["Default settings<br/>[defaults.ts]"]
end

subgraph group_storage["Vault persistence"]
  node_vaultfiles["Vault file access<br/>[file-manager.ts]"]
  node_cache[("Embedding cache<br/>[contextualizer.ts]")]
  node_chatfiles[("Saved chats<br/>[file-manager.ts]")]
  node_format["Chat export formatting<br/>[utils.ts]"]
end

node_user(("Obsidian user"))
node_ollamaserver{{"Local Ollama"}}

node_user -->|"opens chat"| node_menus
node_user -->|"opens panel"| node_plugin
node_menus -->|"loads context"| node_plugin
node_plugin -->|"registers view"| node_chatview
node_plugin -->|"registers settings"| node_settings
node_plugin -->|"loads menus"| node_menus
node_plugin -->|"creates client"| node_ollama
node_plugin -->|"creates contextualizer"| node_context
node_menus -->|"adds file context"| node_context
node_context -->|"reads note text"| node_vaultfiles
node_context -->|"populates and queries"| node_index
node_context -.->|"requests embeddings"| node_ollama
node_context -->|"reads and writes"| node_cache
node_chatview -->|"gets relevant context"| node_context
node_chatview -.->|"sends questions"| node_ollama
node_ollama -->|"requests model output"| node_ollamaserver
node_ollama -->|"lists models"| node_ollamaserver
node_chatview -->|"renders messages"| node_conversation
node_chatview -->|"initializes input"| node_input
node_chatview -->|"initializes actions"| node_buttons
node_chatview -->|"records messages"| node_messages
node_chatview -->|"shows loading"| node_loading
node_buttons -.->|"saves conversation"| node_plugin
node_plugin -->|"opens save dialog"| node_saveas
node_saveas -->|"writes named chat"| node_plugin
node_plugin -->|"formats export"| node_format
node_plugin -->|"updates vault file"| node_vaultfiles
node_settings -->|"uses defaults"| node_defaults

click node_plugin "https://github.com/jjwheatley/mini-rag/blob/main/main.ts"
click node_menus "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/menu-manager.ts"
click node_chatview "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/chat-window.ts"
click node_conversation "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-conversation-window.ts"
click node_input "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-input.ts"
click node_buttons "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-buttons.ts"
click node_messages "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-messages.ts"
click node_loading "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-loading-animation.ts"
click node_saveas "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/save-chat-as-modal.ts"
click node_context "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/contextualizer.ts"
click node_index "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/vector-index.ts"
click node_vaultfiles "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/file-manager.ts"
click node_cache "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/contextualizer.ts"
click node_ollama "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ollama-wrapper.ts"
click node_settings "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/settings-tab.ts"
click node_defaults "https://github.com/jjwheatley/mini-rag/blob/main/src/defaults.ts"
click node_chatfiles "https://github.com/jjwheatley/mini-rag/blob/main/src/classes/file-manager.ts"
click node_format "https://github.com/jjwheatley/mini-rag/blob/main/src/utils.ts"

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_plugin,node_menus,node_user toneBlue
class node_context,node_index toneAmber
class node_chatview,node_conversation,node_input,node_buttons,node_messages,node_loading,node_saveas toneMint
class node_ollama,node_settings,node_defaults toneRose
class node_vaultfiles,node_cache,node_chatfiles,node_format,node_ollamaserver toneIndigo
```

## Components

### Plugin entry

- [Plugin lifecycle](https://github.com/jjwheatley/mini-rag/blob/main/main.ts): `main.ts`
- [Context menus](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/menu-manager.ts): `src/classes/menu-manager.ts`

### Context retrieval

- [Context assembly](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/contextualizer.ts): `src/classes/contextualizer.ts`
- [Vector index](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/vector-index.ts): `src/classes/vector-index.ts`

### Chat experience

- [Chat view](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/chat-window.ts): `src/classes/chat-window.ts`
- [Conversation display](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-conversation-window.ts): `src/classes/ui/chat-conversation-window.ts`
- [Chat input](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-input.ts): `src/classes/ui/chat-input.ts`
- [Chat actions](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-buttons.ts): `src/classes/ui/chat-buttons.ts`
- [Message history](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-messages.ts): `src/classes/ui/chat-messages.ts`
- [Loading indicator](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/chat-loading-animation.ts): `src/classes/ui/chat-loading-animation.ts`
- [Save-as modal](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ui/save-chat-as-modal.ts): `src/classes/ui/save-chat-as-modal.ts`

### Settings and models

- [Ollama client](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/ollama-wrapper.ts): `src/classes/ollama-wrapper.ts`
- [Plugin settings](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/settings-tab.ts): `src/classes/settings-tab.ts`
- [Default settings](https://github.com/jjwheatley/mini-rag/blob/main/src/defaults.ts): `src/defaults.ts`

### Vault persistence

- [Vault file access](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/file-manager.ts): `src/classes/file-manager.ts`
- [Embedding cache](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/contextualizer.ts): `src/classes/contextualizer.ts`
- [Saved chats](https://github.com/jjwheatley/mini-rag/blob/main/src/classes/file-manager.ts): `src/classes/file-manager.ts`
- [Chat export formatting](https://github.com/jjwheatley/mini-rag/blob/main/src/utils.ts): `src/utils.ts`

### Other components

- **Obsidian user**
- **Local Ollama**

## Connections

- Obsidian user → Context menus: opens chat (evidence: `README.md`)
- Obsidian user → Plugin lifecycle: opens panel (evidence: `README.md`)
- Context menus → Plugin lifecycle: loads context (evidence: `src/classes/menu-manager.ts`)
- Plugin lifecycle → Chat view: registers view (evidence: `main.ts`)
- Plugin lifecycle → Plugin settings: registers settings (evidence: `main.ts`)
- Plugin lifecycle → Context menus: loads menus (evidence: `main.ts`)
- Plugin lifecycle → Ollama client: creates client (evidence: `main.ts`)
- Plugin lifecycle → Context assembly: creates contextualizer (evidence: `main.ts`)
- Context menus → Context assembly: adds file context (evidence: `src/classes/menu-manager.ts`)
- Context assembly → Vault file access: reads note text (evidence: `src/classes/contextualizer.ts`)
- Context assembly → Vector index: populates and queries (evidence: `src/classes/contextualizer.ts`)
- Context assembly → Ollama client: requests embeddings (evidence: `src/classes/contextualizer.ts`)
- Context assembly → Embedding cache: reads and writes (evidence: `src/classes/contextualizer.ts`)
- Chat view → Context assembly: gets relevant context (evidence: `src/classes/chat-window.ts`)
- Chat view → Ollama client: sends questions
- Ollama client → Local Ollama: requests model output (evidence: `src/classes/ollama-wrapper.ts`)
- Ollama client → Local Ollama: lists models (evidence: `src/classes/ollama-wrapper.ts`)
- Chat view → Conversation display: renders messages (evidence: `src/classes/chat-window.ts`)
- Chat view → Chat input: initializes input (evidence: `src/classes/chat-window.ts`)
- Chat view → Chat actions: initializes actions (evidence: `src/classes/chat-window.ts`)
- Chat view → Message history: records messages (evidence: `src/classes/chat-window.ts`)
- Chat view → Loading indicator: shows loading (evidence: `src/classes/chat-window.ts`)
- Chat actions → Plugin lifecycle: saves conversation
- Plugin lifecycle → Save-as modal: opens save dialog (evidence: `main.ts`)
- Save-as modal → Plugin lifecycle: writes named chat (evidence: `src/classes/ui/save-chat-as-modal.ts`)
- Plugin lifecycle → Chat export formatting: formats export (evidence: `main.ts`)
- Plugin lifecycle → Vault file access: updates vault file (evidence: `main.ts`)
- Plugin settings → Default settings: uses defaults (evidence: `src/classes/settings-tab.ts`)
