# lalbi2s/agent-controller architecture

> Architecture diagram of the GitHub repository lalbi2s/agent-controller, 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/lalbi2s/agent-controller
- Repository: https://github.com/lalbi2s/agent-controller

## Overview

Agent Controller is a localhost web app for defining and running configurable LLM-agent pipelines over uploaded files. The main workflow uploads input, executes agents in order, validates and reviews generated output, and sends errors back through bounded correction loops before returning a downloadable result. The UI also supports pipeline and prompt editing, provider/model configuration, and API-key management. The README documents the central flow; some detailed backend wiring is unsampled, so the graph limits those relationships to documented links.

Main entry points: [`Orchestrator.cs`](https://github.com/lalbi2s/agent-controller/blob/main/Orchestrator.cs) (Pipeline orchestrator), [`frontend/src/App.tsx`](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/App.tsx) (Run interface), [`frontend/src/hooks/useApi.ts`](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/hooks/useApi.ts) (API hooks), [`Services/LLMClientFactory.cs`](https://github.com/lalbi2s/agent-controller/blob/main/Services/LLMClientFactory.cs) (LLM client factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["Run interface<br/>[App.tsx]"]
  node_api_hooks["API hooks<br/>[useApi.ts]"]
  node_pipeline_editor["Pipeline editor<br/>[PipelineEditor.tsx]"]
  node_pipeline_creator["Pipeline creator"]
  node_keys_page["API keys page<br/>[ApiKeysPage.tsx]"]
end

subgraph group_api["HTTP API"]
  node_run_api["Run endpoint<br/>[RunController.cs]"]
  node_pipelines_api["Pipeline endpoints"]
  node_keys_api["Key endpoints<br/>[KeysController.cs]"]
  node_models_api["Model endpoints"]
end

subgraph group_pipeline["Pipeline runtime"]
  node_orchestrator["Pipeline orchestrator<br/>[Orchestrator.cs]"]
  node_agent_factory["Agent factory<br/>[AgentFactory.cs]"]
  node_agent["Pipeline agent<br/>[Agent.cs]"]
  node_chunking["Input chunking"]
  node_checker["Dashboard checker"]
  node_breakpoints["Breakpoint service"]
  node_events["Run events<br/>[PipelineEvent.cs]"]
end

subgraph group_llm["LLM providers"]
  node_client_factory["LLM client factory"]
  node_anthropic_client["Anthropic client<br/>[AnthropicClient.cs]"]
  node_openai_client["OpenAI-compatible client<br/>[OpenAIClient.cs]"]
end

subgraph group_config["Pipeline and credentials"]
  node_prompt_loader["Pipeline and prompt files<br/>[PromptLoader.cs]"]
  node_key_store[("Encrypted key store<br/>[ApiKeyStore.cs]")]
  node_key_resolver["Key resolver<br/>[ApiKeyResolver.cs]"]
end

node_user(("Local user"))
node_provider_services{{"LLM provider services"}}
node_dashboard_result["Pipeline output"]

node_user -->|"uploads and configures"| node_app
node_app -->|"loads pipeline data"| node_api_hooks
node_app -->|"submits run"| node_run_api
node_app -->|"manages pipelines"| node_pipelines_api
node_app -->|"manages keys"| node_keys_api
node_api_hooks -->|"fetches pipelines"| node_pipelines_api
node_api_hooks -->|"fetches models"| node_models_api
node_pipeline_editor -->|"uses API data"| node_api_hooks
node_pipeline_creator -->|"uses API data"| node_api_hooks
node_keys_page -->|"saves and tests keys"| node_keys_api
node_run_api -->|"starts pipeline"| node_orchestrator
node_pipelines_api -->|"edits pipeline files"| node_prompt_loader
node_orchestrator -->|"prepares agents"| node_agent_factory
node_orchestrator -->|"loads prompts"| node_prompt_loader
node_orchestrator -->|"splits large input"| node_chunking
node_orchestrator -->|"runs checks"| node_checker
node_orchestrator -->|"pauses at breakpoint"| node_breakpoints
node_orchestrator -->|"emits run events"| node_events
node_orchestrator -->|"returns output"| node_dashboard_result
node_agent_factory -->|"creates agents"| node_agent
node_agent -->|"selects provider client"| node_client_factory
node_client_factory -->|"selects available client"| node_anthropic_client
node_client_factory -->|"selects available client"| node_openai_client
node_anthropic_client -->|"resolves API key"| node_key_resolver
node_openai_client -->|"resolves API key"| node_key_resolver
node_key_resolver -->|"reads stored keys"| node_key_store
node_keys_api -->|"stores encrypted keys"| node_key_store
node_anthropic_client -->|"sends completions"| node_provider_services
node_openai_client -->|"sends completions"| node_provider_services

click node_app "https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/App.tsx"
click node_api_hooks "https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/hooks/useApi.ts"
click node_pipeline_editor "https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/components/PipelineEditor.tsx"
click node_pipeline_creator "https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/components/PipelineCreator.tsx"
click node_keys_page "https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/components/ApiKeysPage.tsx"
click node_run_api "https://github.com/lalbi2s/agent-controller/blob/main/Controllers/RunController.cs"
click node_pipelines_api "https://github.com/lalbi2s/agent-controller/blob/main/Controllers/PipelinesController.cs"
click node_keys_api "https://github.com/lalbi2s/agent-controller/blob/main/Controllers/KeysController.cs"
click node_models_api "https://github.com/lalbi2s/agent-controller/blob/main/Controllers/ModelsController.cs"
click node_orchestrator "https://github.com/lalbi2s/agent-controller/blob/main/Orchestrator.cs"
click node_agent_factory "https://github.com/lalbi2s/agent-controller/blob/main/Agents/AgentFactory.cs"
click node_agent "https://github.com/lalbi2s/agent-controller/blob/main/Agents/Agent.cs"
click node_chunking "https://github.com/lalbi2s/agent-controller/blob/main/Services/FileChunkingService.cs"
click node_checker "https://github.com/lalbi2s/agent-controller/blob/main/Services/GrafanaDashboardChecker.cs"
click node_breakpoints "https://github.com/lalbi2s/agent-controller/blob/main/Services/BreakpointService.cs"
click node_events "https://github.com/lalbi2s/agent-controller/blob/main/Models/PipelineEvent.cs"
click node_prompt_loader "https://github.com/lalbi2s/agent-controller/blob/main/Services/PromptLoader.cs"
click node_key_store "https://github.com/lalbi2s/agent-controller/blob/main/Services/ApiKeyStore.cs"
click node_key_resolver "https://github.com/lalbi2s/agent-controller/blob/main/Services/ApiKeyResolver.cs"
click node_client_factory "https://github.com/lalbi2s/agent-controller/blob/main/Services/LLMClientFactory.cs"
click node_anthropic_client "https://github.com/lalbi2s/agent-controller/blob/main/Services/AnthropicClient.cs"
click node_openai_client "https://github.com/lalbi2s/agent-controller/blob/main/Services/OpenAIClient.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,node_api_hooks,node_pipeline_editor,node_pipeline_creator,node_keys_page,node_user toneBlue
class node_run_api,node_pipelines_api,node_keys_api,node_models_api toneAmber
class node_orchestrator,node_agent_factory,node_agent,node_chunking,node_checker,node_breakpoints,node_events toneMint
class node_client_factory,node_anthropic_client,node_openai_client toneRose
class node_prompt_loader,node_key_store,node_key_resolver,node_provider_services,node_dashboard_result toneIndigo
```

## Components

### Web interface

- [Run interface](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API hooks](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/hooks/useApi.ts): `frontend/src/hooks/useApi.ts`
- [Pipeline editor](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/components/PipelineEditor.tsx): `frontend/src/components/PipelineEditor.tsx`
- [Pipeline creator](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/components/PipelineCreator.tsx): `frontend/src/components/PipelineCreator.tsx`
- [API keys page](https://github.com/lalbi2s/agent-controller/blob/main/frontend/src/components/ApiKeysPage.tsx): `frontend/src/components/ApiKeysPage.tsx`

### HTTP API

- [Run endpoint](https://github.com/lalbi2s/agent-controller/blob/main/Controllers/RunController.cs): `Controllers/RunController.cs`
- [Pipeline endpoints](https://github.com/lalbi2s/agent-controller/blob/main/Controllers/PipelinesController.cs): `Controllers/PipelinesController.cs`
- [Key endpoints](https://github.com/lalbi2s/agent-controller/blob/main/Controllers/KeysController.cs): `Controllers/KeysController.cs`
- [Model endpoints](https://github.com/lalbi2s/agent-controller/blob/main/Controllers/ModelsController.cs): `Controllers/ModelsController.cs`

### Pipeline runtime

- [Pipeline orchestrator](https://github.com/lalbi2s/agent-controller/blob/main/Orchestrator.cs): `Orchestrator.cs`
- [Agent factory](https://github.com/lalbi2s/agent-controller/blob/main/Agents/AgentFactory.cs): `Agents/AgentFactory.cs`
- [Pipeline agent](https://github.com/lalbi2s/agent-controller/blob/main/Agents/Agent.cs): `Agents/Agent.cs`
- [Input chunking](https://github.com/lalbi2s/agent-controller/blob/main/Services/FileChunkingService.cs): `Services/FileChunkingService.cs`
- [Dashboard checker](https://github.com/lalbi2s/agent-controller/blob/main/Services/GrafanaDashboardChecker.cs): `Services/GrafanaDashboardChecker.cs`
- [Breakpoint service](https://github.com/lalbi2s/agent-controller/blob/main/Services/BreakpointService.cs): `Services/BreakpointService.cs`
- [Run events](https://github.com/lalbi2s/agent-controller/blob/main/Models/PipelineEvent.cs): `Models/PipelineEvent.cs`

### LLM providers

- [LLM client factory](https://github.com/lalbi2s/agent-controller/blob/main/Services/LLMClientFactory.cs): `Services/LLMClientFactory.cs`
- [Anthropic client](https://github.com/lalbi2s/agent-controller/blob/main/Services/AnthropicClient.cs): `Services/AnthropicClient.cs`
- [OpenAI-compatible client](https://github.com/lalbi2s/agent-controller/blob/main/Services/OpenAIClient.cs): `Services/OpenAIClient.cs`

### Pipeline and credentials

- [Pipeline and prompt files](https://github.com/lalbi2s/agent-controller/blob/main/Services/PromptLoader.cs): `Services/PromptLoader.cs`
- [Encrypted key store](https://github.com/lalbi2s/agent-controller/blob/main/Services/ApiKeyStore.cs): `Services/ApiKeyStore.cs`
- [Key resolver](https://github.com/lalbi2s/agent-controller/blob/main/Services/ApiKeyResolver.cs): `Services/ApiKeyResolver.cs`

### Other components

- **Local user**
- **LLM provider services**
- **Pipeline output**

## Connections

- Local user → Run interface: uploads and configures
- Run interface → API hooks: loads pipeline data (evidence: `frontend/src/App.tsx`)
- Run interface → Run endpoint: submits run
- Run interface → Pipeline endpoints: manages pipelines
- Run interface → Key endpoints: manages keys
- API hooks → Pipeline endpoints: fetches pipelines (evidence: `frontend/src/hooks/useApi.ts`)
- API hooks → Model endpoints: fetches models (evidence: `frontend/src/hooks/useApi.ts`)
- Pipeline editor → API hooks: uses API data (evidence: `frontend/src/components/PipelineEditor.tsx`)
- Pipeline creator → API hooks: uses API data (evidence: `frontend/src/components/PipelineCreator.tsx`)
- API keys page → Key endpoints: saves and tests keys
- Run endpoint → Pipeline orchestrator: starts pipeline (evidence: `Controllers/RunController.cs`)
- Pipeline endpoints → Pipeline and prompt files: edits pipeline files (evidence: `Controllers/PipelinesController.cs`)
- Pipeline orchestrator → Agent factory: prepares agents (evidence: `Orchestrator.cs`)
- Pipeline orchestrator → Pipeline and prompt files: loads prompts (evidence: `Orchestrator.cs`)
- Pipeline orchestrator → Input chunking: splits large input (evidence: `Orchestrator.cs`)
- Pipeline orchestrator → Dashboard checker: runs checks
- Pipeline orchestrator → Breakpoint service: pauses at breakpoint (evidence: `Orchestrator.cs`)
- Pipeline orchestrator → Run events: emits run events (evidence: `Orchestrator.cs`)
- Pipeline orchestrator → Pipeline output: returns output
- Agent factory → Pipeline agent: creates agents (evidence: `Agents/AgentFactory.cs`)
- Pipeline agent → LLM client factory: selects provider client (evidence: `Agents/Agent.cs`)
- LLM client factory → Anthropic client: selects available client (evidence: `Services/LLMClientFactory.cs`)
- LLM client factory → OpenAI-compatible client: selects available client (evidence: `Services/LLMClientFactory.cs`)
- Anthropic client → Key resolver: resolves API key (evidence: `Services/AnthropicClient.cs`)
- OpenAI-compatible client → Key resolver: resolves API key (evidence: `Services/OpenAIClient.cs`)
- Key resolver → Encrypted key store: reads stored keys (evidence: `Services/ApiKeyResolver.cs`)
- Key endpoints → Encrypted key store: stores encrypted keys (evidence: `Controllers/KeysController.cs`)
- Anthropic client → LLM provider services: sends completions
- OpenAI-compatible client → LLM provider services: sends completions
