# thebuggybug/vscode_ext architecture

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

- Interactive diagram: https://gitdiagram.com/thebuggybug/vscode_ext
- Repository: https://github.com/thebuggybug/vscode_ext

## Overview

##### Project type and purpose
- This is a Visual Studio Code extension (“Deepseek”) written in TypeScript.
- Purpose: Provide an in-editor chatbot UI that communicates with the Ollama local AI model (`deepseek-coder-v2`).

##### File structure
- Top-level files:
- package.json, tsconfig.json, eslint.config.mjs, README.md, CHANGELOG.md, License.md
- vsce and VS Code configuration files (.gitignore, .vscodeignore, vsc-extension-quickstart.md)
- src/ directory (TypeScript source):
- extension.ts – Extension activation, command registration, lifecycle management
- panel.ts – Webview panel manager, message handling between extension and UI
- drafts.js – (possibly helper or experimental code)
- test/extension.test.ts – Unit tests for extension activation and message handling
- src/webview/ – Static assets for the embedded chatbot UI
- index.html, script.js, style.css

##### README for additional insights
- The user invokes the “Start Deepseek” command via the Command Palette.
- The extension spins up a Webview-based chatbot UI in a VS Code panel.
- Communications flow over VS Code’s `postMessage` API from webview → extension host.
- The extension invokes the Ollama CLI (`child_process.spawn` or similar) to pass user messages to the local `deepseek-coder-v2` model, receives responses, and relays them back to the webview.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    User["User"]:::actor

    %% VS Code Application
    subgraph "VS Code Core" 
        VSCodeApp["VS Code Application"]:::core
    end

    %% Extension Host Process
    subgraph "Extension Host Process"
        ExtActivate["Extension Activation & Command Registry"]:::extension
        ExtPanel["Webview Panel Manager & Message Broker"]:::extension
        Drafts["External CLI Invoker & Business Logic Helpers"]:::extension
        Tests["Unit Tests (Extension Host & Messaging)"]:::extension
        subgraph "Extension Configuration & Metadata"
            Pkg["package.json"]:::config
            TSConfig["tsconfig.json"]:::config
            ESLintCfg["eslint.config.mjs"]:::config
            Quickstart["vsc-extension-quickstart.md"]:::config
        end
        subgraph "Ignore & Packaging Rules"
            Gitignore[".gitignore"]:::config
            VSCodeIgnore[".vscodeignore"]:::config
            VSCodeTestCfg[".vscode-test.mjs"]:::config
            Changelog["CHANGELOG.md"]:::config
            License["License.md"]:::config
            Readme["README.md"]:::config
        end
        Resources["resources"]:::config
    end

    %% Webview UI
    subgraph "Webview UI"
        WebIndex["index.html"]:::ui
        WebScript["script.js"]:::ui
        WebStyle["style.css"]:::ui
    end

    %% External Service
    Ollama["Ollama CLI + deepseek-coder-v2 Model"]:::external

    %% Communication Proxy for Webview
    UIProxy["Webview UI"]:::ui

    %% Connections
    User -->|"invokes Start Deepseek"| VSCodeApp
    VSCodeApp -->|"command registration"| ExtActivate
    ExtActivate -->|"calls createPanel()"| ExtPanel
    ExtPanel -->|"renders UI"| UIProxy
    UIProxy -->|"postMessage (user prompt)"| ExtPanel
    ExtPanel -->|"spawn process"| Ollama
    Ollama -->|"stdout response"| ExtPanel
    ExtPanel -->|"postMessage (model response)"| UIProxy
    Pkg -->|"build & activation metadata"| ExtActivate
    TSConfig --> ExtActivate
    ESLintCfg --> ExtActivate
    Quickstart --> ExtActivate
    Resources -->|"assets for UI"| UIProxy
    Tests -->|"test extension logic"| ExtActivate

    %% Click Events
    click ExtActivate "https://github.com/thebuggybug/vscode_ext/blob/v1/src/extension.ts"
    click ExtPanel "https://github.com/thebuggybug/vscode_ext/blob/v1/src/panel.ts"
    click Drafts "https://github.com/thebuggybug/vscode_ext/blob/v1/src/drafts.js"
    click WebIndex "https://github.com/thebuggybug/vscode_ext/blob/v1/src/webview/index.html"
    click WebScript "https://github.com/thebuggybug/vscode_ext/blob/v1/src/webview/script.js"
    click WebStyle "https://github.com/thebuggybug/vscode_ext/blob/v1/src/webview/style.css"
    click Tests "https://github.com/thebuggybug/vscode_ext/blob/v1/src/test/extension.test.ts"
    click Pkg "https://github.com/thebuggybug/vscode_ext/blob/v1/package.json"
    click TSConfig "https://github.com/thebuggybug/vscode_ext/blob/v1/tsconfig.json"
    click ESLintCfg "https://github.com/thebuggybug/vscode_ext/blob/v1/eslint.config.mjs"
    click Quickstart "https://github.com/thebuggybug/vscode_ext/blob/v1/vsc-extension-quickstart.md"
    click Gitignore "https://github.com/thebuggybug/vscode_ext/blob/v1/.gitignore"
    click VSCodeIgnore "https://github.com/thebuggybug/vscode_ext/blob/v1/.vscodeignore"
    click VSCodeTestCfg "https://github.com/thebuggybug/vscode_ext/blob/v1/.vscode-test.mjs"
    click Changelog "https://github.com/thebuggybug/vscode_ext/blob/v1/CHANGELOG.md"
    click License "https://github.com/thebuggybug/vscode_ext/blob/v1/License.md"
    click Readme "https://github.com/thebuggybug/vscode_ext/blob/v1/README.md"
    click Resources "https://github.com/thebuggybug/vscode_ext/tree/v1/resources"

    %% Styles
    classDef core fill:#bbdefb,stroke:#1e88e5,color:#0d47a1;
    classDef extension fill:#c8e6c9,stroke:#43a047,color:#1b5e20;
    classDef ui fill:#fff9c4,stroke:#fbc02d,color:#f57f17;
    classDef external fill:#ffccbc,stroke:#fb8c00,color:#e65100;
    classDef config fill:#e0e0e0,stroke:#757575,color:#212121;
    classDef actor fill:#f0f4c3,stroke:#afb42b,color:#827717;
```
