# krishbaidya/llamarun architecture

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

- Interactive diagram: https://gitdiagram.com/krishbaidya/llamarun
- Repository: https://github.com/krishbaidya/llamarun

## Overview

Llama Run is a Windows desktop AI assistant: users choose a model, submit a prompt, and receive generated text in the main window. The AI service manager selects cloud or local Ollama generation; cloud generation also contains MCP tool-call handling. Separate workflows cover first-run and settings, MCP server discovery and management, and Python plugin loading/event dispatch through a native CPython/WinRT bridge. The README documents MCP support and describes Python plugins as in progress. Some UI-to-subsystem wiring is not shown in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`LlamaRun/AIServiceManager.cs`](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/AIServiceManager.cs) (AI service manager), [`LlamaRun/OllamaService.cs`](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/OllamaService.cs) (Local generation), [`LlamaRun/DataStore.cs`](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/DataStore.cs) (Application state), [`LlamaRun/MCPServers/AvaliableMCPServers.xaml.cs`](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/AvaliableMCPServers.xaml.cs) (Server discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop app"]
  node_app_lifecycle["App lifecycle<br/>[App.xaml.cs]"]
  node_main_window["Main window<br/>[MainWindow.xaml.cs]"]
  node_setup["First-run setup"]
  node_settings["App settings"]
end

subgraph group_ai["AI generation"]
  node_ai_manager["AI service manager"]
  node_cloud_ai["Cloud generation<br/>[CloudLLMService.cs]"]
  node_ollama["Local generation<br/>[OllamaService.cs]"]
  node_model_catalog["Model catalog<br/>[Models.cs]"]
  node_ollama_dialog["Ollama unavailable"]
end

subgraph group_mcp["MCP servers"]
  node_mcp_available["Server discovery"]
  node_mcp_installed["Installed servers"]
  node_mcp_details["Server details"]
  node_mcp_setup["Server configuration"]
  node_mcp_preview["Install preview"]
  node_mcp_readme["Server readme"]
  node_mcp_model["MCP server model<br/>[MCPServer.cs]"]
  node_mcp_data["MCP server data<br/>[MCP_Server.cs]"]
end

subgraph group_plugins["Python plugins"]
  node_plugin_ui["Plugin settings UI"]
  node_plugin_list["Installed plugins UI"]
  node_plugin_bridge["Plugin interop API"]
  node_plugin_manager["Plugin manager<br/>[PluginManager.h]"]
  node_plugin_object["Plugin instance<br/>[Plugin.h]"]
  node_plugin_definition["Plugin definition<br/>[PluginDef.h]"]
end

subgraph group_core["Shared state"]
  node_state[("Application state<br/>[DataStore.cs]")]
  node_constants["Service endpoints<br/>[Constants.cs]"]
end

node_user(("User"))
node_llm_provider{{"Cloud LLM provider"}}
node_ollama_service{{"Ollama service"}}
node_mcp_directory{{"MCP directory"}}

node_user -->|"launches"| node_app_lifecycle
node_app_lifecycle -->|"opens first run"| node_setup
node_app_lifecycle -->|"opens main"| node_main_window
node_main_window -->|"requests generation"| node_ai_manager
node_ai_manager -->|"dispatches cloud"| node_cloud_ai
node_ai_manager -->|"dispatches local"| node_ollama
node_ai_manager -->|"checks models"| node_model_catalog
node_ai_manager -->|"stores models"| node_state
node_cloud_ai -->|"reads settings"| node_state
node_cloud_ai -.->|"sends requests"| node_llm_provider
node_ollama -->|"generates locally"| node_ollama_service
node_ollama -->|"shows unavailable"| node_ollama_dialog
node_ollama -->|"updates output"| node_ai_manager
node_settings -->|"loads and saves"| node_state
node_mcp_available -->|"uses endpoints"| node_constants
node_mcp_available -.->|"discovers servers"| node_mcp_directory
node_mcp_installed -->|"reads state"| node_state
node_mcp_details -->|"uses endpoints"| node_constants
node_mcp_available -.->|"previews install"| node_mcp_preview
node_mcp_details -.->|"configures server"| node_mcp_setup
node_mcp_details -.->|"shows readme"| node_mcp_readme
node_mcp_installed -.->|"displays servers"| node_mcp_model
node_plugin_bridge -->|"forwards calls"| node_plugin_manager
node_plugin_manager -->|"creates and dispatches"| node_plugin_object
node_plugin_manager -.->|"registers Python module"| node_plugin_definition
node_plugin_ui -.->|"manages plugins"| node_plugin_bridge
node_plugin_list -.->|"lists plugins"| node_plugin_bridge

click node_app_lifecycle "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/App.xaml.cs"
click node_main_window "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MainWindow.xaml.cs"
click node_setup "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/FirstRunWindow.xaml.cs"
click node_settings "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/SettingsWindow.xaml.cs"
click node_ai_manager "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/AIServiceManager.cs"
click node_cloud_ai "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/CloudLLMService.cs"
click node_ollama "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/OllamaService.cs"
click node_model_catalog "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/Models.cs"
click node_ollama_dialog "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/ShowOllamaUnavaliableWindow.cs"
click node_mcp_available "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/AvaliableMCPServers.xaml.cs"
click node_mcp_installed "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/InstalledMCPServers.xaml.cs"
click node_mcp_details "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/MCPServerDetailsPage.xaml.cs"
click node_mcp_setup "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/EnvironmentConfigDialog.xaml.cs"
click node_mcp_preview "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/ServerInstallPreviewDialog.xaml.cs"
click node_mcp_readme "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/SimpleReadmeViewer.xaml.cs"
click node_mcp_model "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/MCPServer.cs"
click node_mcp_data "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCP_Server.cs"
click node_plugin_ui "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/PluginPage_SettingsWindow.xaml.cs"
click node_plugin_list "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/InstalledPluginsPage.xaml.cs"
click node_plugin_bridge "https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/PluginManagerIntrop.cpp"
click node_plugin_manager "https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/PluginManager.h"
click node_plugin_object "https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/Plugin.h"
click node_plugin_definition "https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/PluginDef.h"
click node_state "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/DataStore.cs"
click node_constants "https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/Constants.cs"

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_app_lifecycle,node_main_window,node_setup,node_settings,node_user toneBlue
class node_ai_manager,node_cloud_ai,node_ollama,node_model_catalog,node_ollama_dialog toneAmber
class node_mcp_available,node_mcp_installed,node_mcp_details,node_mcp_setup,node_mcp_preview,node_mcp_readme,node_mcp_model,node_mcp_data toneMint
class node_plugin_ui,node_plugin_list,node_plugin_bridge,node_plugin_manager,node_plugin_object,node_plugin_definition toneRose
class node_state,node_constants,node_llm_provider,node_ollama_service,node_mcp_directory toneIndigo
```

## Components

### Desktop app

- [App lifecycle](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/App.xaml.cs): `LlamaRun/App.xaml.cs`
- [Main window](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MainWindow.xaml.cs): `LlamaRun/MainWindow.xaml.cs`
- [First-run setup](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/FirstRunWindow.xaml.cs): `LlamaRun/FirstRunWindow.xaml.cs`
- [App settings](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/SettingsWindow.xaml.cs): `LlamaRun/SettingsWindow.xaml.cs`

### AI generation

- [AI service manager](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/AIServiceManager.cs): `LlamaRun/AIServiceManager.cs`
- [Cloud generation](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/CloudLLMService.cs): `LlamaRun/CloudLLMService.cs`
- [Local generation](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/OllamaService.cs): `LlamaRun/OllamaService.cs`
- [Model catalog](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/Models.cs): `LlamaRun/Models.cs`
- [Ollama unavailable](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/ShowOllamaUnavaliableWindow.cs): `LlamaRun/ShowOllamaUnavaliableWindow.cs`

### MCP servers

- [Server discovery](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/AvaliableMCPServers.xaml.cs): `LlamaRun/MCPServers/AvaliableMCPServers.xaml.cs`
- [Installed servers](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/InstalledMCPServers.xaml.cs): `LlamaRun/MCPServers/InstalledMCPServers.xaml.cs`
- [Server details](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/MCPServerDetailsPage.xaml.cs): `LlamaRun/MCPServers/MCPServerDetailsPage.xaml.cs`
- [Server configuration](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/EnvironmentConfigDialog.xaml.cs): `LlamaRun/MCPServers/EnvironmentConfigDialog.xaml.cs`
- [Install preview](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/ServerInstallPreviewDialog.xaml.cs): `LlamaRun/MCPServers/ServerInstallPreviewDialog.xaml.cs`
- [Server readme](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/SimpleReadmeViewer.xaml.cs): `LlamaRun/MCPServers/SimpleReadmeViewer.xaml.cs`
- [MCP server model](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCPServers/MCPServer.cs): `LlamaRun/MCPServers/MCPServer.cs`
- [MCP server data](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/MCP_Server.cs): `LlamaRun/MCP_Server.cs`

### Python plugins

- [Plugin settings UI](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/PluginPage_SettingsWindow.xaml.cs): `LlamaRun/PluginPage_SettingsWindow.xaml.cs`
- [Installed plugins UI](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/InstalledPluginsPage.xaml.cs): `LlamaRun/InstalledPluginsPage.xaml.cs`
- [Plugin interop API](https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/PluginManagerIntrop.cpp): `CPythonIntrop/PluginManagerIntrop.cpp`
- [Plugin manager](https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/PluginManager.h): `CPythonIntrop/PluginManager.h`
- [Plugin instance](https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/Plugin.h): `CPythonIntrop/Plugin.h`
- [Plugin definition](https://github.com/krishbaidya/llamarun/blob/master/CPythonIntrop/PluginDef.h): `CPythonIntrop/PluginDef.h`

### Shared state

- [Application state](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/DataStore.cs): `LlamaRun/DataStore.cs`
- [Service endpoints](https://github.com/krishbaidya/llamarun/blob/master/LlamaRun/Constants.cs): `LlamaRun/Constants.cs`

### Other components

- **User**
- **Cloud LLM provider**
- **Ollama service**
- **MCP directory**

## Connections

- User → App lifecycle: launches (evidence: `LlamaRun/App.xaml.cs`)
- App lifecycle → First-run setup: opens first run (evidence: `LlamaRun/App.xaml.cs`)
- App lifecycle → Main window: opens main (evidence: `LlamaRun/App.xaml.cs`)
- Main window → AI service manager: requests generation (evidence: `LlamaRun/MainWindow.xaml.cs`)
- AI service manager → Cloud generation: dispatches cloud (evidence: `LlamaRun/AIServiceManager.cs`)
- AI service manager → Local generation: dispatches local (evidence: `LlamaRun/AIServiceManager.cs`)
- AI service manager → Model catalog: checks models (evidence: `LlamaRun/AIServiceManager.cs`)
- AI service manager → Application state: stores models (evidence: `LlamaRun/AIServiceManager.cs`)
- Cloud generation → Application state: reads settings (evidence: `LlamaRun/CloudLLMService.cs`)
- Cloud generation → Cloud LLM provider: sends requests
- Local generation → Ollama service: generates locally (evidence: `LlamaRun/OllamaService.cs`)
- Local generation → Ollama unavailable: shows unavailable (evidence: `LlamaRun/OllamaService.cs`)
- Local generation → AI service manager: updates output (evidence: `LlamaRun/OllamaService.cs`)
- App settings → Application state: loads and saves (evidence: `LlamaRun/DataStore.cs`)
- Server discovery → Service endpoints: uses endpoints (evidence: `LlamaRun/MCPServers/AvaliableMCPServers.xaml.cs`)
- Server discovery → MCP directory: discovers servers
- Installed servers → Application state: reads state (evidence: `LlamaRun/MCPServers/InstalledMCPServers.xaml.cs`)
- Server details → Service endpoints: uses endpoints (evidence: `LlamaRun/MCPServers/MCPServerDetailsPage.xaml.cs`)
- Server discovery → Install preview: previews install
- Server details → Server configuration: configures server
- Server details → Server readme: shows readme
- Installed servers → MCP server model: displays servers
- Plugin interop API → Plugin manager: forwards calls (evidence: `CPythonIntrop/PluginManagerIntrop.cpp`)
- Plugin manager → Plugin instance: creates and dispatches (evidence: `CPythonIntrop/PluginManager.h`)
- Plugin manager → Plugin definition: registers Python module
- Plugin settings UI → Plugin interop API: manages plugins
- Installed plugins UI → Plugin interop API: lists plugins
