# apriliawanadidarso-netizen/zcode-panel architecture

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

- Interactive diagram: https://gitdiagram.com/apriliawanadidarso-netizen/zcode-panel
- Repository: https://github.com/apriliawanadidarso-netizen/zcode-panel

## Overview

ZCode is a VS Code sidebar chat extension for the GLM Coding Plan. A user sends a message in the webview; the extension-host panel obtains settings and an API key, adds conversation and optional file context, then calls the streaming client. Streamed output and errors return to the panel for display. Commands also open or clear the panel, attach the active file, and export chat as Markdown. The excerpts show the host-side request flow; webview messaging and file attachment are included based on documented capabilities, not fully sampled implementation.

Main entry points: [`src/panel.ts`](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/panel.ts) (Chat panel provider), [`src/glm.ts`](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/glm.ts) (SSE streaming client), [`src/extension.ts`](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/extension.ts) (Extension activation), [`src/types.ts`](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/types.ts) (Message and chat types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Extension host"]
  node_extension["Extension activation<br/>[extension.ts]"]
end

subgraph group_chat["Chat experience"]
  node_panel["Chat panel provider<br/>[panel.ts]"]
  node_webview["Chat webview<br/>[panel.ts]"]
  node_protocol["Message and chat types<br/>[types.ts]"]
end

subgraph group_services["Configuration and API"]
  node_config["Settings and API key<br/>[config.ts]"]
  node_glm["SSE streaming client<br/>[glm.ts]"]
end

node_user(("VS Code user"))
node_zai{{"Z.ai GLM endpoint"}}
node_vscode{{"VS Code editor services"}}
node_markdown["Markdown export file"]

node_user -->|"sends messages"| node_webview
node_webview -->|"posts events"| node_panel
node_extension -->|"registers provider"| node_panel
node_extension -->|"routes commands"| node_panel
node_panel -->|"gets key and settings"| node_config
node_panel -->|"requests completion"| node_glm
node_glm -->|"streams SSE"| node_zai
node_glm -->|"forwards deltas"| node_panel
node_panel -->|"posts updates"| node_webview
node_panel -->|"reads active file"| node_vscode
node_panel -->|"writes export"| node_markdown
node_panel -->|"uses message types"| node_protocol

click node_extension "https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/extension.ts"
click node_panel "https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/panel.ts"
click node_webview "https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/panel.ts"
click node_protocol "https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/types.ts"
click node_config "https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/config.ts"
click node_glm "https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/glm.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 toneBlue
class node_panel,node_webview,node_protocol toneAmber
class node_config,node_glm toneMint
class node_zai,node_vscode,node_markdown toneIndigo
```

## Components

### Extension host

- [Extension activation](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/extension.ts): `src/extension.ts`

### Chat experience

- [Chat panel provider](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/panel.ts): `src/panel.ts`
- [Chat webview](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/panel.ts): `src/panel.ts`
- [Message and chat types](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/types.ts): `src/types.ts`

### Configuration and API

- [Settings and API key](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/config.ts): `src/config.ts`
- [SSE streaming client](https://github.com/apriliawanadidarso-netizen/zcode-panel/blob/main/src/glm.ts): `src/glm.ts`

### Other components

- **VS Code user**
- **Z.ai GLM endpoint**
- **VS Code editor services**
- **Markdown export file**

## Connections

- VS Code user → Chat webview: sends messages (evidence: `README.md`)
- Chat webview → Chat panel provider: posts events (evidence: `README.md`)
- Extension activation → Chat panel provider: registers provider (evidence: `src/extension.ts`)
- Extension activation → Chat panel provider: routes commands (evidence: `src/extension.ts`)
- Chat panel provider → Settings and API key: gets key and settings (evidence: `src/panel.ts`)
- Chat panel provider → SSE streaming client: requests completion (evidence: `src/panel.ts`)
- SSE streaming client → Z.ai GLM endpoint: streams SSE (evidence: `src/glm.ts`)
- SSE streaming client → Chat panel provider: forwards deltas (evidence: `src/panel.ts`)
- Chat panel provider → Chat webview: posts updates (evidence: `src/panel.ts`)
- Chat panel provider → VS Code editor services: reads active file (evidence: `README.md`)
- Chat panel provider → Markdown export file: writes export (evidence: `src/panel.ts`)
- Chat panel provider → Message and chat types: uses message types (evidence: `src/panel.ts`)
