# incognitadev/vscode-deco-cx architecture

> Architecture diagram of the GitHub repository incognitadev/vscode-deco-cx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/incognitadev/vscode-deco-cx
- Repository: https://github.com/incognitadev/vscode-deco-cx

## Overview

#### Purpose and Runtime
This repository is a TypeScript Visual Studio Code extension for Deco.cx development. It accelerates creation of Deco “Section”, “Loader”, and “Action” source files, provides Deco-oriented snippets, and offers annotation autocomplete/preview tooling. It runs in the VS Code extension host (Node.js) and uses VS Code APIs; its UI preview surface is a VS Code webview.

Key entry points:
- `src/extension.ts`
- `src/fresh/extension.ts`

#### Extension Composition
The root extension activation likely delegates feature registration to the Fresh/Deco module. `src/fresh/extension.ts` is the feature-level coordinator: it should register commands, completion providers, snippets, and webview behavior with VS Code.

- `src/extension.ts`
- `src/fresh/extension.ts`
- `package.json`

#### File Generation Pipeline
Generation is centered on selecting a Deco artifact type and target location, deriving a route/path, then emitting a base source file. This supports both command-driven creation and folder-context creation in the Explorer.

- `src/fresh/generate.ts`
- `src/fresh/getRoutes.ts`
- `src/fresh/extension.ts`

Boundary: filesystem and workspace mutations should remain in generation/route modules, while command registration stays in the extension coordinator.

#### Route and Workspace Context Resolution
Route discovery/resolution is separated from generation. `getRoutes.ts` likely maps the selected folder or workspace structure into valid Deco paths/names, allowing generated Sections, Loaders, and Actions to follow project conventions rather than use only a raw filename.

- `src/fresh/getRoutes.ts`
- `src/fresh/generate.ts`

#### Editor Assistance: Snippets and Annotations
Snippet definitions are isolated from activation and generation. They provide reusable editor insertions such as loading fallback, error fallback, and loader patterns. Annotation completion and widget-related suggestions are expected to be registered through the Fresh extension module and may use the webview for rich previews.

- `src/fresh/snippets.ts`
- `src/fresh/extension.ts`
- `src/fresh/webview.ts`

#### Webview Preview Boundary
The webview module bridges extension-host logic to a sandboxed browser UI for annotation/widget previews. Static browser assets are kept separately and should be loaded through VS Code webview-safe URIs and message passing, rather than accessed directly by editor-assistance logic.

- `src/fresh/webview.ts`
- `media/fresh/main.js`
- `media/fresh/main.css`

#### Frontend Assets and Packaging
The webview frontend is plain static JavaScript/CSS under `media/fresh`; `vscode.css` likely aligns the UI with VS Code styling. Extension packaging, activation declarations, commands, and dependencies are defined by the VS Code extension manifest.

- `media/fresh/main.js`
- `media/fresh/vscode.css`
- `package.json`

Main entry points: [`src/fresh/webview.ts`](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/webview.ts) (Webview Bridge), [`src/fresh/extension.ts`](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts) (Fresh/Deco Coordinator), [`src/extension.ts`](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/extension.ts) (Root Activation), [`src/fresh/getRoutes.ts`](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/getRoutes.ts) (Route Resolution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Extension Host"]
  node_root_activation["Root Activation<br/>extension entry<br/>[extension.ts]"]
  node_fresh_coordinator["Fresh/Deco Coordinator<br/>feature coordinator<br/>[extension.ts]"]
  node_vscode_api{{"VS Code APIs<br/>platform API"}}
end

subgraph group_generation["Generation Pipeline"]
  node_artifact_commands["Artifact Creation Commands<br/>command handlers<br/>[extension.ts]"]
  node_route_resolution["Route Resolution<br/>workspace resolver<br/>[getRoutes.ts]"]
  node_source_generation["Source Generation<br/>file generator<br/>[generate.ts]"]
  node_workspace_filesystem[("Workspace Filesystem<br/>workspace boundary")]
end

subgraph group_editor["Editor Assistance"]
  node_snippet_definitions["Deco Snippets<br/>snippet definitions<br/>[snippets.ts]"]
  node_annotation_assistance["Annotation Assistance<br/>completion and widgets<br/>[extension.ts]"]
end

subgraph group_webview["Webview UI"]
  node_webview_bridge["Webview Bridge<br/>webview host<br/>[webview.ts]"]
  node_webview_script["Preview Script<br/>browser JavaScript<br/>[main.js]"]
  node_webview_styles["Preview Styles<br/>browser CSS<br/>[main.css]"]
  node_vscode_styles["VS Code Theme Styles<br/>browser CSS<br/>[vscode.css]"]
end

node_manifest["Extension Manifest<br/>VS Code manifest<br/>[package.json]"]

node_manifest -->|"activates"| node_root_activation
node_root_activation -->|"delegates to"| node_fresh_coordinator
node_fresh_coordinator -->|"registers with"| node_vscode_api
node_fresh_coordinator -->|"registers"| node_artifact_commands
node_artifact_commands -->|"resolves target"| node_route_resolution
node_route_resolution -->|"supplies route and path"| node_source_generation
node_source_generation -->|"writes source files"| node_workspace_filesystem
node_fresh_coordinator -->|"registers"| node_snippet_definitions
node_fresh_coordinator -->|"registers"| node_annotation_assistance
node_annotation_assistance -->|"requests preview"| node_webview_bridge
node_webview_bridge -->|"creates webview via"| node_vscode_api
node_webview_bridge -->|"loads safe URI"| node_webview_script
node_webview_bridge -->|"loads safe URI"| node_webview_styles
node_webview_bridge -->|"loads safe URI"| node_vscode_styles
node_webview_script -.->|"message passing"| node_webview_bridge

click node_manifest "https://github.com/incognitadev/vscode-deco-cx/blob/main/package.json"
click node_root_activation "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/extension.ts"
click node_fresh_coordinator "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts"
click node_artifact_commands "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts"
click node_route_resolution "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/getRoutes.ts"
click node_source_generation "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/generate.ts"
click node_snippet_definitions "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/snippets.ts"
click node_annotation_assistance "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts"
click node_webview_bridge "https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/webview.ts"
click node_webview_script "https://github.com/incognitadev/vscode-deco-cx/blob/main/media/fresh/main.js"
click node_webview_styles "https://github.com/incognitadev/vscode-deco-cx/blob/main/media/fresh/main.css"
click node_vscode_styles "https://github.com/incognitadev/vscode-deco-cx/blob/main/media/fresh/vscode.css"

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_root_activation,node_fresh_coordinator,node_vscode_api toneBlue
class node_artifact_commands,node_route_resolution,node_source_generation,node_workspace_filesystem toneAmber
class node_snippet_definitions,node_annotation_assistance toneMint
class node_webview_bridge,node_webview_script,node_webview_styles,node_vscode_styles toneRose
class node_manifest toneNeutral
```

## Components

### Extension Host

TypeScript running in the VS Code extension host.

- [Root Activation](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/extension.ts): extension entry · Activates the extension and delegates Deco features. · `src/extension.ts`
- [Fresh/Deco Coordinator](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts): feature coordinator · Registers feature commands and VS Code providers. · `src/fresh/extension.ts`
- **VS Code APIs**: platform API · Commands, Explorer context, editor providers, and webviews.

### Generation Pipeline

Creates Deco artifact files from workspace context.

- [Artifact Creation Commands](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts): command handlers · Starts Section, Loader, and Action creation from commands or folders. · `src/fresh/extension.ts`
- [Route Resolution](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/getRoutes.ts): workspace resolver · Derives valid Deco paths from selected folders and workspace structure. · `src/fresh/getRoutes.ts`
- [Source Generation](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/generate.ts): file generator · Emits base Section, Loader, and Action source files. · `src/fresh/generate.ts`
- **Workspace Filesystem**: workspace boundary · Target folders and generated source files.

### Editor Assistance

Snippets, annotation completion, and previews.

- [Deco Snippets](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/snippets.ts): snippet definitions · Reusable loading, error, and loader insertions. · `src/fresh/snippets.ts`
- [Annotation Assistance](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/extension.ts): completion and widgets · Provides annotation autocomplete and preview interactions. · `src/fresh/extension.ts`

### Webview UI

Sandboxed browser assets for rich previews.

- [Webview Bridge](https://github.com/incognitadev/vscode-deco-cx/blob/main/src/fresh/webview.ts): webview host · Creates the preview surface and exchanges messages with its UI. · `src/fresh/webview.ts`
- [Preview Script](https://github.com/incognitadev/vscode-deco-cx/blob/main/media/fresh/main.js): browser JavaScript · Renders annotation or widget previews. · `media/fresh/main.js`
- [Preview Styles](https://github.com/incognitadev/vscode-deco-cx/blob/main/media/fresh/main.css): browser CSS · Styles the webview preview UI. · `media/fresh/main.css`
- [VS Code Theme Styles](https://github.com/incognitadev/vscode-deco-cx/blob/main/media/fresh/vscode.css): browser CSS · Aligns the preview with VS Code styling. · `media/fresh/vscode.css`

### Other components

- [Extension Manifest](https://github.com/incognitadev/vscode-deco-cx/blob/main/package.json): VS Code manifest · Declares activation, commands, and dependencies. · `package.json`

## Connections

- Extension Manifest → Root Activation: activates
- Root Activation → Fresh/Deco Coordinator: delegates to
- Fresh/Deco Coordinator → VS Code APIs: registers with
- Fresh/Deco Coordinator → Artifact Creation Commands: registers
- Artifact Creation Commands → Route Resolution: resolves target
- Route Resolution → Source Generation: supplies route and path
- Source Generation → Workspace Filesystem: writes source files
- Fresh/Deco Coordinator → Deco Snippets: registers
- Fresh/Deco Coordinator → Annotation Assistance: registers
- Annotation Assistance → Webview Bridge: requests preview
- Webview Bridge → VS Code APIs: creates webview via
- Webview Bridge → Preview Script: loads safe URI
- Webview Bridge → Preview Styles: loads safe URI
- Webview Bridge → VS Code Theme Styles: loads safe URI
- Preview Script → Webview Bridge: message passing
