# keyurvaghani/openbuddy architecture

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

- Interactive diagram: https://gitdiagram.com/keyurvaghani/openbuddy
- Repository: https://github.com/keyurvaghani/openbuddy

## Overview

OpenBuddy is a VS Code extension for Claude Code that patches Claude’s chat webview, then turns supported fenced blocks in replies into interactive rich views. The workflow starts with a user asking Claude for a visual; Claude emits a fence, and the injected webview script polls for complete blocks and dispatches them to renderers. Separately, extension activation installs Claude instructions and watches for Claude updates to reapply the patch. Edges are based on the README and shown source/index references; unsampled implementation details are omitted.

Main entry points: [`src/webview/index.ts`](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/index.ts) (Renderer registry), [`src/webview/fenceBlocks.ts`](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/fenceBlocks.ts) (Fence plumbing), [`src/extension.ts`](https://github.com/keyurvaghani/openbuddy/blob/main/src/extension.ts) (Extension entry), [`src/webview/appBlocks.ts`](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/appBlocks.ts) (Runnable HTML app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Extension lifecycle"]
  node_extension["Extension entry<br/>[extension.ts]"]
end

subgraph group_host["Host patching"]
  node_patcher["Bundle patcher<br/>[patcher.ts]"]
  node_selfheal["Update watcher<br/>[selfHeal.ts]"]
end

subgraph group_webview["Reply rendering"]
  node_main["Injected entry<br/>[main.ts]"]
  node_registry["Renderer registry<br/>[index.ts]"]
  node_ticker["Render ticker<br/>[ticker.ts]"]
  node_fences["Fence plumbing<br/>[fenceBlocks.ts]"]
  node_mermaid["Mermaid renderer<br/>[mermaidBlocks.ts]"]
  node_chart["Chart renderer<br/>[chartBlocks.ts]"]
  node_math["Math renderer<br/>[mathBlocks.ts]"]
  node_html["HTML preview<br/>[htmlBlocks.ts]"]
  node_app["Runnable HTML app<br/>[appBlocks.ts]"]
end

subgraph group_instructions["Claude instructions"]
  node_skill["Skill management<br/>[skill.ts]"]
  node_uninstall["Uninstall cleanup<br/>[uninstall.ts]"]
end

node_user(("VS Code user"))
node_claude["Claude Code"]
node_chat["Claude chat webview"]

node_user -->|"requests visual"| node_claude
node_claude -->|"writes fenced reply"| node_chat
node_extension -->|"creates and patches"| node_patcher
node_extension -->|"starts watcher"| node_selfheal
node_patcher -->|"injects script"| node_chat
node_selfheal -->|"reapplies patch"| node_patcher
node_extension -->|"installs instructions"| node_skill
node_uninstall -->|"removes skill"| node_skill
node_chat -->|"runs injected script"| node_main
node_main -->|"starts render steps"| node_registry
node_registry -->|"exports ticker"| node_ticker
node_registry -->|"registers renderer"| node_mermaid
node_registry -->|"registers renderer"| node_chart
node_registry -->|"registers renderer"| node_math
node_registry -->|"registers renderer"| node_html
node_registry -->|"registers renderer"| node_app
node_chart -->|"renders through"| node_fences
node_html -->|"renders through"| node_fences
node_app -->|"renders through"| node_fences
node_app -->|"sanitizes and mounts"| node_html
node_mermaid -->|"uses shared plumbing"| node_fences
node_math -->|"uses shared plumbing"| node_fences

click node_extension "https://github.com/keyurvaghani/openbuddy/blob/main/src/extension.ts"
click node_patcher "https://github.com/keyurvaghani/openbuddy/blob/main/src/host/patcher.ts"
click node_selfheal "https://github.com/keyurvaghani/openbuddy/blob/main/src/host/selfHeal.ts"
click node_skill "https://github.com/keyurvaghani/openbuddy/blob/main/src/skill.ts"
click node_uninstall "https://github.com/keyurvaghani/openbuddy/blob/main/src/uninstall.ts"
click node_main "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/main.ts"
click node_registry "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/index.ts"
click node_ticker "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/ticker.ts"
click node_fences "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/fenceBlocks.ts"
click node_mermaid "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/mermaidBlocks.ts"
click node_chart "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/chartBlocks.ts"
click node_math "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/mathBlocks.ts"
click node_html "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/htmlBlocks.ts"
click node_app "https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/appBlocks.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_extension,node_user,node_chat toneBlue
class node_patcher,node_selfheal toneAmber
class node_main,node_registry,node_ticker,node_fences,node_mermaid,node_chart,node_math,node_html,node_app toneMint
class node_skill,node_uninstall toneRose
class node_claude toneIndigo
```

## Components

### Extension lifecycle

- [Extension entry](https://github.com/keyurvaghani/openbuddy/blob/main/src/extension.ts): `src/extension.ts`

### Host patching

- [Bundle patcher](https://github.com/keyurvaghani/openbuddy/blob/main/src/host/patcher.ts): `src/host/patcher.ts`
- [Update watcher](https://github.com/keyurvaghani/openbuddy/blob/main/src/host/selfHeal.ts): `src/host/selfHeal.ts`

### Reply rendering

- [Injected entry](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/main.ts): `src/webview/main.ts`
- [Renderer registry](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/index.ts): `src/webview/index.ts`
- [Render ticker](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/ticker.ts): `src/webview/ticker.ts`
- [Fence plumbing](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/fenceBlocks.ts): `src/webview/fenceBlocks.ts`
- [Mermaid renderer](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/mermaidBlocks.ts): `src/webview/mermaidBlocks.ts`
- [Chart renderer](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/chartBlocks.ts): `src/webview/chartBlocks.ts`
- [Math renderer](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/mathBlocks.ts): `src/webview/mathBlocks.ts`
- [HTML preview](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/htmlBlocks.ts): `src/webview/htmlBlocks.ts`
- [Runnable HTML app](https://github.com/keyurvaghani/openbuddy/blob/main/src/webview/appBlocks.ts): `src/webview/appBlocks.ts`

### Claude instructions

- [Skill management](https://github.com/keyurvaghani/openbuddy/blob/main/src/skill.ts): `src/skill.ts`
- [Uninstall cleanup](https://github.com/keyurvaghani/openbuddy/blob/main/src/uninstall.ts): `src/uninstall.ts`

### Other components

- **VS Code user**
- **Claude Code**
- **Claude chat webview**

## Connections

- VS Code user → Claude Code: requests visual (evidence: `README.md`)
- Claude Code → Claude chat webview: writes fenced reply (evidence: `README.md`)
- Extension entry → Bundle patcher: creates and patches (evidence: `src/extension.ts`)
- Extension entry → Update watcher: starts watcher (evidence: `src/extension.ts`)
- Bundle patcher → Claude chat webview: injects script (evidence: `README.md`)
- Update watcher → Bundle patcher: reapplies patch (evidence: `src/host/selfHeal.ts`)
- Extension entry → Skill management: installs instructions (evidence: `src/extension.ts`)
- Uninstall cleanup → Skill management: removes skill (evidence: `src/uninstall.ts`)
- Claude chat webview → Injected entry: runs injected script (evidence: `README.md`)
- Injected entry → Renderer registry: starts render steps (evidence: `src/webview/main.ts`)
- Renderer registry → Render ticker: exports ticker (evidence: `src/webview/index.ts`)
- Renderer registry → Mermaid renderer: registers renderer (evidence: `src/webview/index.ts`)
- Renderer registry → Chart renderer: registers renderer (evidence: `src/webview/index.ts`)
- Renderer registry → Math renderer: registers renderer (evidence: `src/webview/index.ts`)
- Renderer registry → HTML preview: registers renderer (evidence: `src/webview/index.ts`)
- Renderer registry → Runnable HTML app: registers renderer (evidence: `src/webview/index.ts`)
- Chart renderer → Fence plumbing: renders through (evidence: `src/webview/chartBlocks.ts`)
- HTML preview → Fence plumbing: renders through (evidence: `src/webview/htmlBlocks.ts`)
- Runnable HTML app → Fence plumbing: renders through (evidence: `src/webview/appBlocks.ts`)
- Runnable HTML app → HTML preview: sanitizes and mounts (evidence: `src/webview/appBlocks.ts`)
- Mermaid renderer → Fence plumbing: uses shared plumbing (evidence: `src/webview/mermaidBlocks.ts`)
- Math renderer → Fence plumbing: uses shared plumbing (evidence: `src/webview/mathBlocks.ts`)
