# eighthundreds/vscode-drawio architecture

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

- Interactive diagram: https://gitdiagram.com/eighthundreds/vscode-drawio
- Repository: https://github.com/eighthundreds/vscode-drawio

## Overview

##### Project Type and Purpose
- The goal is to let users open, edit, and save “.drawio” (and related) files inside VS Code via a Webview-backed UI.

##### File Structure Analysis
- Top‐level files: package.json/lock, tsconfig.json, CHANGELOG.md, LICENSE, README.md
- /src: TypeScript extension code
- extension.ts – activates the extension and registers the custom editor provider
- DrawIOEditorProvider.ts – implements the VS Code CustomEditorProvider interface
- logger.ts – central logging utility
- /test – unit/integration tests run against the extension
- /drawioApp: the entire static front-end application
- app.html, index.html, electron.js, etc. – entry points for the web UI
- MathJax integration, Dropbox/GitHub/OneDrive/Trello clients, all packaged in
- Visual Studio Code configuration files (.vscode, .eslintrc.json)

##### README Insights
- Confirms “custom editor” extension.
- Points to an alternative, implying this is a wrapper rather than a reimplementation.

a. Main Components
1. VS Code Host (Extension Host process)
2. DrawIOEditorProvider (TypeScript)
3. Webview Panel (Chromium‐based UI inside VS Code)
4. Static Asset Store (/drawioApp folder)
5. Local File System / VS Code Workspace FS API
6. External Services (Dropbox, OneDrive, GitHub, etc.—optional front-end connectors)
b. Relationships and Interactions
- VS Code Host ↔ DrawIOEditorProvider: activation, registration of custom editors
- DrawIOEditorProvider ↔ Webview:
– Provider loads app.html into a Webview
– Message passing (postMessage) for “open file,” “save file,” undo/redo notifications
- Webview ↔ External Services: front-end clients (e.g., DropboxClient.js) make HTTP calls
c. Architectural Patterns
- Custom Editor pattern in VS Code: separation of host logic (TypeScript) vs. UI (Webview)
d. Key Technologies
- VS Code Extension API (CustomEditorProvider)
- TypeScript for extension code
- VS Code FS API for file I/O
- Node tooling (npm, webpack or none, tsconfig)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Host Tier"
        VSCodeExtensionHost["VS Code Extension Host"]:::host
        DrawIOEditorProvider["DrawIOEditorProvider"]:::host
        LoggingUtility["Logging Utility"]:::host
        WorkspaceFSAPI["Workspace FS API"]:::host
        Tests["Unit/Integration Tests"]:::host
    end

    subgraph "UI Tier"
        WebviewPanel["Webview Panel"]:::ui
        subgraph "Static Asset Store" 
            EntryHTML["app.html"]:::ui
            CacheManifest["cache.manifest"]:::ui
            ElectronSupport["electron.js"]:::ui
            MVCCore["App.js / EditorUi.js"]:::ui
            Models["DrawioFile.js / DriveFile.js"]:::ui
            Connectors["External Connectors"]:::ui
            MathJax["MathJax.js"]:::ui
            MxGraph["mxgraph Library"]:::ui
            Plugins["Plugin Architecture"]:::ui
            Stencils["Stencils Library"]:::ui
            Shapes["Shapes Library"]:::ui
            Templates["Templates Library"]:::ui
            Styles["Stylesheets"]:::ui
            MiscFrontEnd["Misc Front-end Entries"]:::ui
        end
    end

    subgraph "External Services"
        ExternalServices["Dropbox / OneDrive / GitHub / GitLab / Trello"]:::ext
    end

    %% Connections
    VSCodeExtensionHost -->|"registers"| DrawIOEditorProvider
    DrawIOEditorProvider -->|"reads/writes"| WorkspaceFSAPI
    DrawIOEditorProvider -->|"loads UI"| WebviewPanel
    DrawIOEditorProvider -->|"logs via"| LoggingUtility
    DrawIOEditorProvider -->|"tests run on"| Tests
    WebviewPanel -->|"loads assets"| EntryHTML
    WebviewPanel -->|"loads assets"| CacheManifest
    WebviewPanel -->|"loads assets"| ElectronSupport
    WebviewPanel -->|"loads assets"| MVCCore
    WebviewPanel -->|"loads assets"| Models
    WebviewPanel -->|"loads assets"| Connectors
    WebviewPanel -->|"loads assets"| MathJax
    WebviewPanel -->|"loads assets"| MxGraph
    WebviewPanel -->|"loads assets"| Plugins
    WebviewPanel -->|"loads assets"| Stencils
    WebviewPanel -->|"loads assets"| Shapes
    WebviewPanel -->|"loads assets"| Templates
    WebviewPanel -->|"loads assets"| Styles
    WebviewPanel -->|"loads assets"| MiscFrontEnd
    WebviewPanel -->|"postMessage ↔"| DrawIOEditorProvider
    WebviewPanel -->|"HTTP calls"| ExternalServices

    %% Click Events
    click VSCodeExtensionHost "https://github.com/eighthundreds/vscode-drawio/blob/master/src/extension.ts"
    click DrawIOEditorProvider "https://github.com/eighthundreds/vscode-drawio/blob/master/src/DrawIOEditorProvider.ts"
    click LoggingUtility "https://github.com/eighthundreds/vscode-drawio/blob/master/src/logger.ts"
    click Tests "https://github.com/eighthundreds/vscode-drawio/tree/master/src/test"
    click EntryHTML "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/app.html"
    click CacheManifest "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/cache.manifest"
    click ElectronSupport "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/electron.js"
    click MVCCore "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/js/diagramly/App.js"
    click Models "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/js/diagramly/DrawioFile.js"
    click Connectors "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/js/diagramly/DropboxClient.js"
    click MathJax "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/math/MathJax.js"
    click MxGraph "https://github.com/eighthundreds/vscode-drawio/tree/master/drawioApp/js/mxgraph"
    click Plugins "https://github.com/eighthundreds/vscode-drawio/tree/master/drawioApp/plugins/"
    click Stencils "https://github.com/eighthundreds/vscode-drawio/tree/master/drawioApp/stencils/"
    click Shapes "https://github.com/eighthundreds/vscode-drawio/tree/master/drawioApp/shapes/"
    click Templates "https://github.com/eighthundreds/vscode-drawio/tree/master/drawioApp/templates/"
    click Styles "https://github.com/eighthundreds/vscode-drawio/tree/master/drawioApp/styles/"
    click MiscFrontEnd "https://github.com/eighthundreds/vscode-drawio/blob/master/drawioApp/index.html"
    click VSCodeExtensionHost "https://github.com/eighthundreds/vscode-drawio/blob/master/package.json"

    classDef host fill:#bbdefb,stroke:#1e88e5,color:#0d47a1;
    classDef ui fill:#c8e6c9,stroke:#43a047,color:#1b5e20;
    classDef ext fill:#ffe0b2,stroke:#fb8c00,color:#e65100;
```
