# mendix/web-extension-template architecture

> Architecture diagram of the GitHub repository mendix/web-extension-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mendix/web-extension-template
- Repository: https://github.com/mendix/web-extension-template

## Overview

##### Main Components
- Extension Manifest & Public Assets:
– Represented by the “public” folder, containing the manifest.json. This defines the extension’s metadata and configuration required by Mendix Studio Pro.
- Extension Core:
– Found in “src/main/index.ts”. This file likely contains the core logic that integrates with Mendix Studio Pro, handling messaging and lifecycle events.
- UI Layer:
– Located in “src/ui/index.tsx”. This component is intended to handle the user interface for the extension (potentially using React, given the .tsx extension).
- Build & Configuration:
– The presence of package.json, tsconfig.json, and vite.config.ts indicates that Vite is used for bundling the code, with TypeScript as the language. Configuration files and build scripts form another conceptual component.
- Project Metadata & Miscellaneous:
– Files like .gitignore, LICENSE, and .editorconfig serve as peripheral components for project maintenance and code quality.

##### Relationships and Interactions
- The manifest, when processed, triggers the loading of the extension’s core code (src/main/index.ts) into the Mendix environment.
- The core code in src/main is responsible for initializing and managing the extension’s lifecycle. It may also call or inject the UI components from src/ui/index.tsx.
- The UI component, likely rendered in a browser-like environment or an embedded panel within Studio Pro, provides the user-facing aspect of the extension.
- The build configuration (vite.config.ts, package.json, tsconfig.json) ties all source code together for the build process (via npm run build) that outputs the final assets into the “dist/myextension” structure used by Mendix.

##### Architectural Patterns
- Modular Structure: Each top-level part (public assets, main logic, UI layer, and build configuration) forms an independent module that interacts through well-defined interfaces.
- Integration with External Systems: Emphasize the boundary where Mendix Studio Pro interacts with the extension, particularly via the manifest and runtime injection of the extension code.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External System
    Mendix["Mendix Studio Pro"]:::external

    %% Assets
    Assets["Manifest & Public Assets"]:::asset

    %% Source Code Subgraph
    subgraph "Source Code"
        Core["Extension Core Logic"]:::runtime
        UI["UI Components"]:::runtime
    end

    %% Build Process Subgraph
    subgraph "Build Process"
        subgraph "Build & Configuration"
            Pkg["package.json"]:::config
            Tsconfig["tsconfig.json"]:::config
            Vite["vite.config.ts"]:::config
            BuildConfig["Build Configuration"]:::build
            Pkg --> BuildConfig
            Tsconfig --> BuildConfig
            Vite --> BuildConfig
        end
        BuildConfig --> Dist["Build Output (dist/myextension)"]:::output
    end

    %% Project Metadata Subgraph
    subgraph "Project Metadata & Miscellaneous"
        Editor[".editorconfig"]:::meta
        Git[".gitignore"]:::meta
        License["LICENSE"]:::meta
    end

    %% Relationships
    Mendix -->|"loads"| Assets
    Assets -->|"triggers"| Core
    Core -->|"renders"| UI
    Core -->|"compiledBy"| BuildConfig
    UI -->|"compiledBy"| BuildConfig

    %% Styles
    classDef external fill:#ffebcd,stroke:#a52a2a,stroke-width:2px;
    classDef asset fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef runtime fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef build fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef output fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef config fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef meta fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click Assets "https://github.com/mendix/web-extension-template/blob/main/public/manifest.json"
    click Core "https://github.com/mendix/web-extension-template/blob/main/src/main/index.ts"
    click UI "https://github.com/mendix/web-extension-template/blob/main/src/ui/index.tsx"
    click Pkg "https://github.com/mendix/web-extension-template/blob/main/package.json"
    click Tsconfig "https://github.com/mendix/web-extension-template/blob/main/tsconfig.json"
    click Vite "https://github.com/mendix/web-extension-template/blob/main/vite.config.ts"
    click Editor "https://github.com/mendix/web-extension-template/blob/main/.editorconfig"
    click Git "https://github.com/mendix/web-extension-template/blob/main/.gitignore"
    click License "https://github.com/mendix/web-extension-template/tree/main/LICENSE"
```
