# leandrolatini/show-me-chatgpt-plugin architecture

> Architecture diagram of the GitHub repository leandrolatini/show-me-chatgpt-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leandrolatini/show-me-chatgpt-plugin
- Repository: https://github.com/leandrolatini/show-me-chatgpt-plugin

## Overview

##### Project type and purpose
- It can be deployed as a container (Docker/Docker Compose), to Fly.io, or as a Cloudflare Worker (wrangler.local.toml).

##### File structure
- Top-level:
- Dockerfile, docker-compose.yml – containerization
- flyio/… – deployment scripts and config for Fly.io
- wrangler.local.toml – config for Cloudflare Workers
- src/ – application source code
- src/index.ts – server bootstrap & manifest endpoint
- src/routes/ – HTTP handlers:
- CollectEmail.ts – email-capture form handler
- Shorten.ts – URL shortening
- src/mixpanel.ts – analytics client
- src/utils.ts, src/types.ts – shared helpers & type definitions

##### Key points from the README
- The plugin registers with ChatGPT via its manifest at `/ai-plugin.json`.
- Once installed in ChatGPT, user prompts flow through the plugin:

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% ChatGPT Plugin Host
    subgraph "ChatGPT UI" 
        direction TB
        UI["Browser Icon<br/>ChatGPT UI"]:::chatgpt
    end

    %% Plugin Server
    subgraph "Plugin Server" 
        direction TB
        %% Manifest & Registrar
        Registrar["Manifest & Route Registrar<br/>(index.ts)"]:::server
        %% Static Endpoints
        Logo["Logo Endpoint<br/>(logo.ts)"]:::server
        Privacy["Privacy Page Endpoint<br/>(privacy-page.ts)"]:::server
        %% Route Handlers
        subgraph "Routes"
            direction TB
            DiagramRoute["Route: POST /Diagram<br/>(Diagram.ts)"]:::server
            EditorRoute["Route: GET /DiagramEditorWithEmailForm.html<br/>(DiagramEditorWithEmailForm.html)"]:::server
            EmailRoute["Route: POST /CollectEmail<br/>(CollectEmail.ts)"]:::server
            ShortenRoute["Route: POST /Shorten<br/>(Shorten.ts)"]:::server
        end
        %% Engine Adapters
        subgraph "Diagram-Engine Clients"
            direction TB
            AdapterIndex["Adapter Registry<br/>(index.ts)"]:::server
            MermaidClient["Mermaid Client Adapter<br/>(mermaid.ts)"]:::server
            PlantUMLClient["PlantUML Client Adapter<br/>(plantuml.ts)"]:::server
            UtilsDiagrams["Diagram Utilities<br/>(utils.ts)"]:::server
        end
        %% Shared Modules
        Mixpanel["Mixpanel Analytics<br/>(mixpanel.ts)"]:::server
        SharedUtils["Shared Utilities<br/>(utils.ts)"]:::server
        Types["Type Definitions<br/>(types.ts)"]:::server
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Kroki["Kroki Renderer Services<br/>(blockdiag, mermaid, bpmn, etc)"]:::external
        EmailService["Email Service / DB"]:::external
        URLShortener["URL Shortening DB/API"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure/Deployment"
        direction TB
        Docker["Docker / Docker Compose"]:::infra
        Fly["Fly.io"]:::infra
        CFWorker["Cloudflare Workers"]:::infra
    end

    %% Connections: ChatGPT UI ↔ Plugin Server
    UI -->|"GET /ai-plugin.json"| Registrar
    UI -->|"POST /Diagram"| DiagramRoute
    UI -->|"GET /DiagramEditorWithEmailForm.html"| EditorRoute
    UI -->|"POST /CollectEmail"| EmailRoute
    %% Plugin routing to adapters and externals
    DiagramRoute -->|"invoke"| AdapterIndex
    AdapterIndex --> MermaidClient
    AdapterIndex --> PlantUMLClient
    MermaidClient -->|"HTTP render"| Kroki
    PlantUMLClient -->|"HTTP render"| Kroki
    %% Responses back to UI
    AdapterIndex -->|"return image URL"| DiagramRoute
    DiagramRoute -->|"200 OK image"| UI
    EditorRoute -->|"200 OK HTML"| UI
    EmailRoute -->|"save email"| EmailService
    EmailRoute -->|"acknowledge"| UI
    %% Analytics
    Registrar --> Mixpanel
    DiagramRoute --> Mixpanel
    EditorRoute --> Mixpanel
    EmailRoute --> Mixpanel
    ShortenRoute --> Mixpanel
    %% URL Shortening
    ShortenRoute --> URLShortener
    ShortenRoute -->|"short URL"| UI

    %% Infra Hosting
    Registrar --> Docker
    Registrar --> Fly
    Registrar --> CFWorker

    %% Click Events
    click Registrar "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/index.ts"
    click Logo "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/logo.ts"
    click Privacy "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/privacy-page.ts"
    click Mixpanel "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/mixpanel.ts"
    click SharedUtils "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/utils.ts"
    click Types "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/types.ts"
    click DiagramRoute "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/Diagram.ts"
    click EmailRoute "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/CollectEmail.ts"
    click ShortenRoute "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/Shorten.ts"
    click EditorRoute "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/DiagramEditorWithEmailForm.html"
    click AdapterIndex "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/diagrams/index.ts"
    click MermaidClient "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/diagrams/mermaid.ts"
    click PlantUMLClient "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/diagrams/plantuml.ts"
    click UtilsDiagrams "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/src/routes/diagrams/utils.ts"
    click Docker "https://github.com/leandrolatini/show-me-chatgpt-plugin/tree/main/Dockerfile"
    click Docker "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/docker-compose.yml"
    click Fly "https://github.com/leandrolatini/show-me-chatgpt-plugin/tree/main/flyio/"
    click CFWorker "https://github.com/leandrolatini/show-me-chatgpt-plugin/blob/main/wrangler.local.toml"

    %% Styles
    classDef chatgpt fill:#cce5ff,stroke:#2a7ab8,color:#000
    classDef server fill:#d4edda,stroke:#2f6627,color:#000
    classDef external fill:#fff3cd,stroke:#997404,color:#000
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#000
```
