# truehot/lmlocal architecture

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

- Interactive diagram: https://gitdiagram.com/truehot/lmlocal
- Repository: https://github.com/truehot/lmlocal

## Overview

LM Local is a Visual Studio AI chat assistant: users send prompts and optional workspace context through the chat UI, receive streamed model responses, and can invoke guarded tools for code and workspace actions. The graph also retains documented provider/model setup, persistent chat, instructions, inline completions, MCP and sub-agent capabilities. Source excerpts establish several internal calls, but many UI wiring and domain integrations are documented only in the README; those links are marked dashed where unverified.

Main entry points: [`LMLocal/Application/ChatSession/ChatSessionOrchestrator.cs`](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSession/ChatSessionOrchestrator.cs) (Session orchestrator), [`LMLocal/Resources/js/app.controller.js`](https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/app.controller.js) (App controller), [`LMLocal/Application/ChatSessionStream/ChatStreamService.cs`](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSessionStream/ChatStreamService.cs) (Chat streaming), [`LMLocal/Application/Abstractions/Ports/IToolRouter.cs`](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Abstractions/Ports/IToolRouter.cs) (Tool routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Chat interaction"]
  node_chatui["Chat interface<br/>[chat.controller.js]"]
  node_chatpipeline["Chat pipeline"]
  node_appcontroller["App controller<br/>[app.controller.js]"]
  node_chatinjection["Workspace context"]
end

subgraph group_conversation["Conversation runtime"]
  node_orchestrator["Session orchestrator"]
  node_streamservice["Chat streaming"]
  node_streamprocessor["Stream processing<br/>[StreamProcessor.cs]"]
  node_history["Chat history"]
  node_persistence[("Chat persistence")]
  node_streamui["Streaming UI"]
end

subgraph group_workspace["Workspace actions"]
  node_toolmanager["Tool execution"]
  node_toolrouter["Tool routing<br/>[IToolRouter.cs]"]
  node_builtintools["Visual Studio tools"]
  node_snapshots[("Change snapshots<br/>[SnapshotManager.cs]")]
end

subgraph group_configuration["Configuration and connectivity"]
  node_provider["LLM providers"]
  node_models["Model discovery"]
  node_settings[("Settings<br/>[SettingsManager.cs]")]
  node_instructions[("AI instructions")]
  node_completion["Inline completions"]
end

subgraph group_extensions["Extensions"]
  node_subagents["Sub-agents"]
  node_mcpmanager["MCP tools<br/>[McpToolManager.cs]"]
end

node_user(("Developer"))
node_mcpservers{{"MCP servers"}}
node_llm{{"Local or cloud LLM"}}
node_vside(("Visual Studio"))

node_user -.->|"sends prompt"| node_chatui
node_chatui -.->|"builds request"| node_chatpipeline
node_chatpipeline -.->|"submits chat"| node_orchestrator
node_chatinjection -.->|"adds context"| node_orchestrator
node_orchestrator -.->|"starts stream"| node_streamservice
node_streamservice -.->|"requests completion"| node_provider
node_provider -.->|"calls API"| node_llm
node_streamservice -.->|"processes chunks"| node_streamprocessor
node_streamprocessor -.->|"forwards events"| node_streamui
node_orchestrator -.->|"updates history"| node_history
node_history -->|"saves sessions"| node_persistence
node_appcontroller -.->|"configures app"| node_settings
node_appcontroller -.->|"selects presets"| node_instructions
node_appcontroller -.->|"selects model"| node_models
node_user -.->|"requests suggestions"| node_completion
node_orchestrator -.->|"executes tool calls"| node_toolmanager
node_toolmanager -->|"routes execution"| node_toolrouter
node_toolrouter -.->|"dispatches tools"| node_builtintools
node_builtintools -.->|"inspects or edits"| node_vside
node_builtintools -.->|"tracks changes"| node_snapshots
node_orchestrator -.->|"delegates tasks"| node_subagents
node_toolrouter -.->|"routes MCP tools"| node_mcpmanager
node_mcpmanager -->|"connects stdio or HTTP"| node_mcpservers

click node_chatui "https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/chat/chat.controller.js"
click node_chatpipeline "https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/chat/chat.pipeline.builder.js"
click node_appcontroller "https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/app.controller.js"
click node_chatinjection "https://github.com/truehot/lmlocal/blob/main/LMLocal/UI/ChatInjectionService.cs"
click node_orchestrator "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSession/ChatSessionOrchestrator.cs"
click node_streamservice "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSessionStream/ChatStreamService.cs"
click node_streamprocessor "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSessionStream/StreamProcessor.cs"
click node_history "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Chat/ChatHistoryManager.cs"
click node_persistence "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Persistence/ChatPersistenceService.cs"
click node_streamui "https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/streaming/streaming.pipeline.js"
click node_provider "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/LlmApi/Provider/ProviderResolver.cs"
click node_models "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ModelsList/ModelsListService.cs"
click node_settings "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Settings/SettingsManager.cs"
click node_instructions "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Instructions/InstructionsManager.cs"
click node_completion "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Autocompletions/AutocompletionsService.cs"
click node_toolmanager "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Tool/ToolExecutionManager.cs"
click node_toolrouter "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Abstractions/Ports/IToolRouter.cs"
click node_builtintools "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Tooling/BuiltInVs/BuiltInVsToolProvider.cs"
click node_snapshots "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Tooling/BuiltInVs/Snapshot/SnapshotManager.cs"
click node_subagents "https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/SubAgents/SubAgentsService.cs"
click node_mcpmanager "https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Tooling/Mcp/McpToolManager.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_chatui,node_chatpipeline,node_appcontroller,node_chatinjection toneBlue
class node_orchestrator,node_streamservice,node_streamprocessor,node_history,node_persistence,node_streamui toneAmber
class node_toolmanager,node_toolrouter,node_builtintools,node_snapshots,node_mcpservers toneMint
class node_provider,node_models,node_settings,node_instructions,node_completion toneRose
class node_subagents,node_mcpmanager,node_user,node_llm,node_vside toneIndigo
```

## Components

### Chat interaction

- [Chat interface](https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/chat/chat.controller.js): `LMLocal/Resources/js/chat/chat.controller.js`
- [Chat pipeline](https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/chat/chat.pipeline.builder.js): `LMLocal/Resources/js/chat/chat.pipeline.builder.js`
- [App controller](https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/app.controller.js): `LMLocal/Resources/js/app.controller.js`
- [Workspace context](https://github.com/truehot/lmlocal/blob/main/LMLocal/UI/ChatInjectionService.cs): `LMLocal/UI/ChatInjectionService.cs`

### Conversation runtime

- [Session orchestrator](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSession/ChatSessionOrchestrator.cs): `LMLocal/Application/ChatSession/ChatSessionOrchestrator.cs`
- [Chat streaming](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSessionStream/ChatStreamService.cs): `LMLocal/Application/ChatSessionStream/ChatStreamService.cs`
- [Stream processing](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ChatSessionStream/StreamProcessor.cs): `LMLocal/Application/ChatSessionStream/StreamProcessor.cs`
- [Chat history](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Chat/ChatHistoryManager.cs): `LMLocal/Application/Chat/ChatHistoryManager.cs`
- [Chat persistence](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Persistence/ChatPersistenceService.cs): `LMLocal/Infrastructure/Persistence/ChatPersistenceService.cs`
- [Streaming UI](https://github.com/truehot/lmlocal/blob/main/LMLocal/Resources/js/streaming/streaming.pipeline.js): `LMLocal/Resources/js/streaming/streaming.pipeline.js`

### Workspace actions

- [Tool execution](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Tool/ToolExecutionManager.cs): `LMLocal/Application/Tool/ToolExecutionManager.cs`
- [Tool routing](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Abstractions/Ports/IToolRouter.cs): `LMLocal/Application/Abstractions/Ports/IToolRouter.cs`
- [Visual Studio tools](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Tooling/BuiltInVs/BuiltInVsToolProvider.cs): `LMLocal/Infrastructure/Tooling/BuiltInVs/BuiltInVsToolProvider.cs`
- [Change snapshots](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Tooling/BuiltInVs/Snapshot/SnapshotManager.cs): `LMLocal/Infrastructure/Tooling/BuiltInVs/Snapshot/SnapshotManager.cs`

### Configuration and connectivity

- [LLM providers](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/LlmApi/Provider/ProviderResolver.cs): `LMLocal/Infrastructure/LlmApi/Provider/ProviderResolver.cs`
- [Model discovery](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/ModelsList/ModelsListService.cs): `LMLocal/Application/ModelsList/ModelsListService.cs`
- [Settings](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Settings/SettingsManager.cs): `LMLocal/Infrastructure/Settings/SettingsManager.cs`
- [AI instructions](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Instructions/InstructionsManager.cs): `LMLocal/Infrastructure/Instructions/InstructionsManager.cs`
- [Inline completions](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/Autocompletions/AutocompletionsService.cs): `LMLocal/Application/Autocompletions/AutocompletionsService.cs`

### Extensions

- [Sub-agents](https://github.com/truehot/lmlocal/blob/main/LMLocal/Application/SubAgents/SubAgentsService.cs): `LMLocal/Application/SubAgents/SubAgentsService.cs`
- [MCP tools](https://github.com/truehot/lmlocal/blob/main/LMLocal/Infrastructure/Tooling/Mcp/McpToolManager.cs): `LMLocal/Infrastructure/Tooling/Mcp/McpToolManager.cs`

### Other components

- **Developer**
- **MCP servers**
- **Local or cloud LLM**
- **Visual Studio**

## Connections

- Developer → Chat interface: sends prompt
- Chat interface → Chat pipeline: builds request (evidence: `LMLocal/Resources/js/chat/chat.pipeline.builder.js`)
- Chat pipeline → Session orchestrator: submits chat
- Workspace context → Session orchestrator: adds context
- Session orchestrator → Chat streaming: starts stream
- Chat streaming → LLM providers: requests completion
- LLM providers → Local or cloud LLM: calls API
- Chat streaming → Stream processing: processes chunks
- Stream processing → Streaming UI: forwards events
- Session orchestrator → Chat history: updates history
- Chat history → Chat persistence: saves sessions (evidence: `LMLocal/Application/Chat/ChatHistoryManager.cs`)
- App controller → Settings: configures app
- App controller → AI instructions: selects presets
- App controller → Model discovery: selects model
- Developer → Inline completions: requests suggestions
- Session orchestrator → Tool execution: executes tool calls
- Tool execution → Tool routing: routes execution (evidence: `LMLocal/Application/Tool/ToolExecutionManager.cs`)
- Tool routing → Visual Studio tools: dispatches tools
- Visual Studio tools → Visual Studio: inspects or edits
- Visual Studio tools → Change snapshots: tracks changes
- Session orchestrator → Sub-agents: delegates tasks
- Tool routing → MCP tools: routes MCP tools
- MCP tools → MCP servers: connects stdio or HTTP (evidence: `LMLocal/Infrastructure/Tooling/Mcp/McpToolManager.cs`)
