# bruno-gs-dev/visual-ai-editor architecture

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

- Interactive diagram: https://gitdiagram.com/bruno-gs-dev/visual-ai-editor
- Repository: https://github.com/bruno-gs-dev/visual-ai-editor

## Overview

Visual AI Editor lets a developer select existing page elements, request natural-language edits, review and apply the result, then save source changes or hand framework changes to an agent. The browser client gathers selection and CSS context; the server routes edit requests to a configured AI provider and checks design tokens before returning output. Other documented capabilities include visual selection tools, undo/redo, design-system viewing and validation, framework integrations, and provider configuration. Some server internals and framework wiring were not sampled, so uncertain links are omitted or marked unverified.

Main entry points: [`server/index.ts`](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/index.ts) (HTTP API), [`server/providers/index.ts`](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/index.ts) (Provider registry), [`src/actions.ts`](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/actions.ts) (Edit and review), [`src/core.ts`](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/core.ts) (Editor runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser editor"]
  node_editor["Editor runtime<br/>[core.ts]"]
  node_selection["Element selection<br/>[selection.ts]"]
  node_tools["Selection tools<br/>[tools.ts]"]
  node_edit_actions["Edit and review<br/>[actions.ts]"]
  node_translations["UI localization<br/>[i18n.ts]"]
end

subgraph group_server["Edit service"]
  node_server["HTTP API<br/>[index.ts]"]
  node_patching["Surgical patching<br/>[patch.ts]"]
  node_agent_handoff["Agent handoff<br/>[index.ts]"]
end

subgraph group_providers["AI providers"]
  node_provider_registry["Provider registry<br/>[index.ts]"]
  node_openai["OpenAI adapter<br/>[openai.ts]"]
  node_anthropic["Anthropic adapter<br/>[anthropic.ts]"]
  node_opencode["OpenCode adapter<br/>[opencode.ts]"]
  node_local_agent["Local agent<br/>[local-agent.ts]"]
end

subgraph group_design["Design system"]
  node_design_tokens["Palette validation<br/>[design-tokens.ts]"]
  node_design_check["Design checks<br/>[design-check.ts]"]
end

subgraph group_frameworks["Framework integrations"]
  node_react_hook["React hook<br/>[useAIEditor.ts]"]
  node_angular_builder["Angular builder<br/>[builder.ts]"]
  node_angular_transformer["Source tagging<br/>[transformer.ts]"]
end

node_developer(("Developer"))
node_cli["Start CLI<br/>[cli.ts]"]
node_ai_service(("Configured AI"))
node_project_files["Project source"]

node_developer -->|"starts editor"| node_cli
node_cli -->|"starts server"| node_server
node_developer -->|"selects elements"| node_selection
node_selection -.->|"uses tools"| node_tools
node_editor -.->|"supports selection"| node_selection
node_developer -->|"requests edit"| node_edit_actions
node_edit_actions -->|"posts edit"| node_server
node_server -->|"resolves provider"| node_provider_registry
node_provider_registry -->|"dispatches"| node_openai
node_provider_registry -->|"dispatches"| node_anthropic
node_provider_registry -->|"dispatches"| node_opencode
node_provider_registry -->|"dispatches"| node_local_agent
node_openai -.->|"sends prompt"| node_ai_service
node_anthropic -.->|"sends prompt"| node_ai_service
node_opencode -.->|"sends prompt"| node_ai_service
node_local_agent -.->|"runs agent"| node_ai_service
node_server -->|"checks palette"| node_design_tokens
node_design_check -.->|"checks design"| node_project_files
node_server -.->|"applies patches"| node_patching
node_edit_actions -->|"saves changes"| node_project_files
node_edit_actions -->|"requests handoff"| node_server
node_server -->|"writes manifest"| node_agent_handoff
node_react_hook -.->|"mounts editor"| node_editor
node_angular_builder -->|"transforms templates"| node_angular_transformer
node_translations -.->|"provides strings"| node_editor

click node_cli "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/bin/cli.ts"
click node_editor "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/core.ts"
click node_selection "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/selection.ts"
click node_tools "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/tools.ts"
click node_edit_actions "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/actions.ts"
click node_translations "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/i18n.ts"
click node_server "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/index.ts"
click node_provider_registry "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/index.ts"
click node_openai "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/openai.ts"
click node_anthropic "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/anthropic.ts"
click node_opencode "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/opencode.ts"
click node_local_agent "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/local-agent.ts"
click node_design_tokens "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/lib/design-tokens.ts"
click node_design_check "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/lib/design-check.ts"
click node_patching "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/lib/patch.ts"
click node_react_hook "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/react/useAIEditor.ts"
click node_angular_builder "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/angular-plugin/src/builder.ts"
click node_angular_transformer "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/angular-plugin/src/transformer.ts"
click node_agent_handoff "https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/index.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_editor,node_selection,node_tools,node_edit_actions,node_translations toneBlue
class node_server,node_patching,node_agent_handoff toneAmber
class node_provider_registry,node_openai,node_anthropic,node_opencode,node_local_agent toneMint
class node_design_tokens,node_design_check toneRose
class node_react_hook,node_angular_builder,node_angular_transformer,node_developer,node_ai_service,node_project_files toneIndigo
class node_cli toneTeal
```

## Components

### Browser editor

- [Editor runtime](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/core.ts): `src/core.ts`
- [Element selection](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/selection.ts): `src/selection.ts`
- [Selection tools](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/tools.ts): `src/tools.ts`
- [Edit and review](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/actions.ts): `src/actions.ts`
- [UI localization](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/src/i18n.ts): `src/i18n.ts`

### Edit service

- [HTTP API](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/index.ts): `server/index.ts`
- [Surgical patching](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/lib/patch.ts): `lib/patch.ts`
- [Agent handoff](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/index.ts): `server/index.ts`

### AI providers

- [Provider registry](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/index.ts): `server/providers/index.ts`
- [OpenAI adapter](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/openai.ts): `server/providers/openai.ts`
- [Anthropic adapter](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/anthropic.ts): `server/providers/anthropic.ts`
- [OpenCode adapter](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/opencode.ts): `server/providers/opencode.ts`
- [Local agent](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/server/providers/local-agent.ts): `server/providers/local-agent.ts`

### Design system

- [Palette validation](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/lib/design-tokens.ts): `lib/design-tokens.ts`
- [Design checks](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/lib/design-check.ts): `lib/design-check.ts`

### Framework integrations

- [React hook](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/react/useAIEditor.ts): `react/useAIEditor.ts`
- [Angular builder](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/angular-plugin/src/builder.ts): `angular-plugin/src/builder.ts`
- [Source tagging](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/angular-plugin/src/transformer.ts): `angular-plugin/src/transformer.ts`

### Other components

- **Developer**
- [Start CLI](https://github.com/bruno-gs-dev/visual-ai-editor/blob/main/bin/cli.ts): `bin/cli.ts`
- **Configured AI**
- **Project source**

## Connections

- Developer → Start CLI: starts editor (evidence: `README.md`)
- Start CLI → HTTP API: starts server (evidence: `bin/cli.ts`)
- Developer → Element selection: selects elements (evidence: `README.md`)
- Element selection → Selection tools: uses tools
- Editor runtime → Element selection: supports selection (evidence: `src/selection.ts`)
- Developer → Edit and review: requests edit (evidence: `README.md`)
- Edit and review → HTTP API: posts edit (evidence: `src/actions.ts`)
- HTTP API → Provider registry: resolves provider (evidence: `server/index.ts`)
- Provider registry → OpenAI adapter: dispatches (evidence: `server/providers/index.ts`)
- Provider registry → Anthropic adapter: dispatches (evidence: `server/providers/index.ts`)
- Provider registry → OpenCode adapter: dispatches (evidence: `server/providers/index.ts`)
- Provider registry → Local agent: dispatches (evidence: `server/providers/index.ts`)
- OpenAI adapter → Configured AI: sends prompt
- Anthropic adapter → Configured AI: sends prompt
- OpenCode adapter → Configured AI: sends prompt
- Local agent → Configured AI: runs agent
- HTTP API → Palette validation: checks palette (evidence: `server/index.ts`)
- Design checks → Project source: checks design
- HTTP API → Surgical patching: applies patches (evidence: `server/index.ts`)
- Edit and review → Project source: saves changes (evidence: `src/actions.ts`)
- Edit and review → HTTP API: requests handoff (evidence: `src/actions.ts`)
- HTTP API → Agent handoff: writes manifest (evidence: `server/index.ts`)
- React hook → Editor runtime: mounts editor
- Angular builder → Source tagging: transforms templates (evidence: `angular-plugin/src/builder.ts`)
- UI localization → Editor runtime: provides strings (evidence: `src/i18n.ts`)
