# tharunpoduru/vibekit architecture

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

- Interactive diagram: https://gitdiagram.com/tharunpoduru/vibekit
- Repository: https://github.com/tharunpoduru/vibekit

## Overview

##### Project Type and Purpose
- Type: A client-side Adobe Express Add-on built in React + TypeScript.

##### File Structure
- src/ui: The React app (components, styling, entry point).
- src/sandbox: Code running in the extension’s sandboxed iframe (DOM parsing, CORS proxy calls).
- src/models: TypeScript definitions (e.g., DocumentSandboxApi.ts for messaging).
- manifest.json: Adobe Express Add-on metadata (commands, permissions).
- webpack.config.js: Bundler configuration producing the add-on package.
- package.json & tsconfig.json: Dependencies and TypeScript settings.

##### Readme Insights
- UI built with Adobe Spectrum Web Components.
- Uses OpenAI GPT-4 API for text generation.
- Requires a CORS proxy to fetch and parse third-party HTML/CSS safely.
- All logic lives client-side; no separate backend service shipping with the add-on.

##### Main Components
a. Adobe Express Host
- Loads the add-on via manifest.json.
- Provides a container and document API.
b. -On UI (React + Spectrum)
- src/ui/index.tsx → renders UI components (App.tsx).
c. Sandbox Context
- src/sandbox/code.ts
- Runs in an isolated iframe for DOM parsing.
- Communicates with the UI via DocumentSandboxApi (postMessage).
- Calls CORS Proxy to fetch external page HTML/CSS.
d. DocumentSandboxApi
- Typed interface (src/models/DocumentSandboxApi.ts).
e. CORS Proxy (External Service)
- Bypasses browser cross-origin restrictions.
- Fetches target website HTML/CSS on behalf of the sandbox.
f. OpenAI GPT-4 API (External AI Service)
- Used in prompt-based generation modes.
- The UI or sandbox sends HTTP requests (with keys) to produce text outputs.
g. Adobe Express Document
- Receives generated assets (palette, quotes, etc.).
- Inserted via the host’s scripting API.

##### Relationships and Data Flows
- User triggers action in Add-On UI.
- UI sends a “parse URL” or “generate prompt” message to Sandbox via DocumentSandboxApi.
- Sandbox:
- For prompt mode: directly calls OpenAI API → returns generated brand assets.
- UI receives data, displays previews.
- Upon “insert” commands, UI calls Adobe Express host APIs to add elements to the document.
- All HTTP calls flow through secure channels (HTTPS); secrets held in extension configuration.

##### Architectural Patterns and Principles
- Separation of concerns: UI vs. sandbox logic.
- Typed messaging contract (DocumentSandboxApi) for reliable component interaction.
- Client-only architecture: no custom backend beyond the CORS proxy and OpenAI.
- Component-driven UI: React + Spectrum.
- Build pipeline: Webpack bundles TSX and sandbox code into the add-on package.

- Title: “VibeKit Add-On System Architecture.”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Title
    subgraph "VibeKit Add-On System Architecture"
    end

    %% Host Layer
    subgraph "Adobe Express Host" 
        direction TB
        Host["Adobe Express Host"]:::host
        DocumentAPI["Document API"]:::host
    end

    %% Extension Layer
    subgraph "Extension Package" 
        direction TB

        subgraph "Add-On UI (React + Spectrum)" 
            direction TB
            UIIndex["src/ui/index.tsx<br/>Entry Point"]:::ui
            AppComp["src/ui/components/App.tsx<br/>Main App"]:::ui
            AppStyle["src/ui/components/App.css<br/>Styling"]:::ui
        end

        subgraph "Sandbox Context (iframe)" 
            direction TB
            SandboxCode["src/sandbox/code.ts<br/>Sandbox Logic"]:::sandbox
        end

        subgraph "Models (Messaging Contract)" 
            direction TB
            DocApi["src/models/DocumentSandboxApi.ts<br/>Typed API"]:::models
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        CORS["CORS Proxy"]:::external
        OpenAI["OpenAI GPT-4 API"]:::external
    end

    %% Build & Config
    subgraph "Build & Configuration"
        direction TB
        Webpack["webpack.config.js"]:::config
        TSRoot["tsconfig.json"]:::config
        TSUI["src/ui/tsconfig.json"]:::config
        TSSandbox["src/sandbox/tsconfig.json"]:::config
        PKGJson["package.json"]:::config
        PKGLock["package-lock.json"]:::config
    end

    %% User Flow
    User["User"]:::actor

    %% Connections
    User -->|"click buttons / input prompt"| UIIndex
    UIIndex -->|"render App"| AppComp
    AppComp -->|"postMessage fetchURL / generatePrompt"| DocApi
    DocApi -->|"postMessage to sandbox"| SandboxCode

    %% Sandbox flows
    SandboxCode -->|"HTTP fetchURL"| CORS
    SandboxCode -->|"run extraction logic"| SandboxCode
    SandboxCode -->|"HTTP generatePrompt"| OpenAI
    SandboxCode -->|"postMessage data"| DocApi

    %% UI receives data
    DocApi -->|"deliver assets"| AppComp
    AppComp -->|"insertColors / insertAssets"| DocumentAPI
    DocumentAPI -->|"applies to document"| Host

    %% Build & config dependencies
    UIIndex --- Webpack
    SandboxCode --- Webpack
    AppComp --- TSUI
    UIIndex --- TSUI
    SandboxCode --- TSSandbox
    DocApi --- TSRoot
    UIIndex --- PKGJson
    SandboxCode --- PKGJson

    %% Click Events
    click Host "https://github.com/tharunpoduru/vibekit/blob/dev/src/manifest.json"
    click UIIndex "https://github.com/tharunpoduru/vibekit/blob/dev/src/ui/index.tsx"
    click AppComp "https://github.com/tharunpoduru/vibekit/blob/dev/src/ui/components/App.tsx"
    click AppStyle "https://github.com/tharunpoduru/vibekit/blob/dev/src/ui/components/App.css"
    click SandboxCode "https://github.com/tharunpoduru/vibekit/blob/dev/src/sandbox/code.ts"
    click DocApi "https://github.com/tharunpoduru/vibekit/blob/dev/src/models/DocumentSandboxApi.ts"
    click Webpack "https://github.com/tharunpoduru/vibekit/blob/dev/webpack.config.js"
    click TSRoot "https://github.com/tharunpoduru/vibekit/blob/dev/tsconfig.json"
    click TSUI "https://github.com/tharunpoduru/vibekit/blob/dev/src/ui/tsconfig.json"
    click TSSandbox "https://github.com/tharunpoduru/vibekit/blob/dev/src/sandbox/tsconfig.json"
    click PKGJson "https://github.com/tharunpoduru/vibekit/blob/dev/package.json"
    click PKGLock "https://github.com/tharunpoduru/vibekit/blob/dev/package-lock.json"

    %% Styles
    classDef host fill:#FFE4B5,stroke:#DAA520,color:#000
    classDef ui fill:#B0E0E6,stroke:#4682B4,color:#000
    classDef sandbox fill:#E6E6FA,stroke:#9370DB,color:#000
    classDef models fill:#FFFACD,stroke:#DAA520,color:#000
    classDef external fill:#FFC0CB,stroke:#FF69B4,color:#000
    classDef config fill:#D3D3D3,stroke:#A9A9A9,color:#000
    classDef actor fill:#98FB98,stroke:#2E8B57,color:#000
```
