# trycourier/courier-designer architecture

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

- Interactive diagram: https://gitdiagram.com/trycourier/courier-designer
- Repository: https://github.com/trycourier/courier-designer

## Overview

##### Main Components and Layers
- **Monorepo Orchestrator**
- pnpm workspaces (pnpm-workspace.yaml)
- Turbo (turbo.json)
- Workspace scripts (pnpm dev, build, test, lint)
- **Core Layer**
- packages/react-designer
– React components, hooks, types
– Build scripts (esbuild, build.js), PostCSS, Tailwind
– Unit tests (vitest.config.ts)
– E2E tests (playwright.config.ts)
- **Framework Adapter**
- packages/vue-designer
– Wraps React core for Vue
– Vue single-file component (Editor.vue)
– Build script (build.js)
- **Demo/Development Apps**
- apps/editor-dev (Vite + React)
– Local dev harness loading react-designer (and optionally vue-designer)
- apps/nextjs-demo (Next.js + Tailwind)
– Brand-editor & Template-editor pages
– API hooks into react-designer providers
- **CI/CD Pipelines**
- .github/workflows/check-pull-request.yml
- .github/workflows/publish-canary.yml
- .github/workflows/publish-release.yml
- **External Services**
- npm registry (package publish)
- GitHub (source repo, PRs)

##### Relationships & Dependencies
- **pnpm/Turbo** orchestrates all packages and apps, running builds/tests across the monorepo.
- **react-designer** is the core library:
→ depended on by vue-designer and both demo apps.
- **vue-designer** wraps and re-exports react-designer for Vue consumers.
- **apps/editor-dev** imports react-designer directly (for local iteration).
- **apps/nextjs-demo** imports react-designer providers and components to showcase usage.
- CI workflows trigger on push/PR, run lint/tests via the orchestrator, then publish packages to npm.

##### Architectural Patterns & Design Principles
- **Layered Architecture**: Core → Adapter → Application
- **Monorepo Workspace**: Single source for tooling, versioning, cross-package linkage.
- **Separation of Concerns**:
- UI logic in react-designer
- Framework binding in vue-designer
- Demo & experimentation in apps
- **CI/CD Automation**: Validate and publish across layers from one place.

##### Essential Elements
- Clear **component labels** (package names, app names, workflow names)

## Diagram (Mermaid)

```mermaid
graph TB
  %% Orchestrator & CI/CD Layer
  subgraph "Orchestrator & CI/CD" 
    direction TB
    PNPMWS["pnpm-workspace.yaml"]:::orchestrator
    TURBO["turbo.json"]:::orchestrator
    ROOTPKG["package.json (root)"]:::orchestrator
    CHECK[".github/workflows/check-pull-request.yml"]:::cicd
    CANARY[".github/workflows/publish-canary.yml"]:::cicd
    RELEASE[".github/workflows/publish-release.yml"]:::cicd
  end

  %% Core Layer
  subgraph "Core Layer" 
    direction TB
    subgraph "packages/react-designer"
      direction TB
      RD_MAIN["packages/react-designer"]:::core
      RD_BUILD["build.js"]:::core
      RD_SRC["src/"]:::core
      RD_CONFIG["config/"]:::core
      RD_SCRIPTS["scripts/"]:::core
      RD_VITEST["vitest.config.ts"]:::core
      RD_PLAY["playwright.config.ts"]:::core
    end
  end

  %% Framework Adapter Layer
  subgraph "Framework Adapter" 
    direction TB
    subgraph "packages/vue-designer"
      direction TB
      VD_MAIN["packages/vue-designer"]:::adapter
      VD_BUILD["build.js"]:::adapter
      VD_EDITOR["src/Editor.vue"]:::adapter
      VD_INDEX["src/index.ts"]:::adapter
    end
  end

  %% Demo/Development Apps Layer
  subgraph "Demo/Development Apps" 
    direction TB
    subgraph "apps/editor-dev"
      direction TB
      ED_MAIN["apps/editor-dev"]:::app
      ED_VITE["vite.config.ts"]:::app
      ED_SRC["src/"]:::app
      ED_PKG["package.json"]:::app
    end
    subgraph "apps/nextjs-demo"
      direction TB
      NJ_MAIN["apps/nextjs-demo"]:::app
      NJ_NEXTCFG["next.config.js"]:::app
      NJ_TWCFG["tailwind.config.js"]:::app
      NJ_SRC["src/app/"]:::app
      NJ_PKG["package.json"]:::app
    end
  end

  %% External Services
  subgraph "External Services"
    direction TB
    GITHUB["GitHub (repo & PRs)"]:::external
    NPM["npm registry"]:::external
  end

  %% Relationships
  PNPMWS -->|"orchestrates"| RD_MAIN
  TURBO -->|"orchestrates"| RD_MAIN
  ROOTPKG -->|"scripts"| RD_MAIN

  PNPMWS -->|"orchestrates"| VD_MAIN
  TURBO -->|"orchestrates"| VD_MAIN
  ROOTPKG -->|"scripts"| VD_MAIN

  PNPMWS -->|"orchestrates"| ED_MAIN
  TURBO -->|"orchestrates"| ED_MAIN
  ROOTPKG -->|"scripts"| ED_MAIN

  PNPMWS -->|"orchestrates"| NJ_MAIN
  TURBO -->|"orchestrates"| NJ_MAIN
  ROOTPKG -->|"scripts"| NJ_MAIN

  RD_MAIN -->|"wraps"| VD_MAIN
  RD_MAIN -->|"imports"| ED_MAIN
  RD_MAIN -->|"imports"| NJ_MAIN

  CHECK -->|"runs tests on"| RD_MAIN
  CHECK -->|"runs tests on"| VD_MAIN
  CHECK -->|"runs tests on"| ED_MAIN
  CHECK -->|"runs tests on"| NJ_MAIN

  CANARY -->|"publishes"| RD_MAIN
  CANARY -->|"publishes"| VD_MAIN

  RELEASE -->|"publishes"| RD_MAIN
  RELEASE -->|"publishes"| VD_MAIN

  RELEASE -->|"publishes"| ED_MAIN
  RELEASE -->|"publishes"| NJ_MAIN

  CHECK -->|"triggered by"| GITHUB
  CANARY -->|"triggered by"| GITHUB
  RELEASE -->|"triggered by"| GITHUB

  CANARY -->|"publishes to"| NPM
  RELEASE -->|"publishes to"| NPM

  %% Click Events
  click PNPMWS "https://github.com/trycourier/courier-designer/blob/main/pnpm-workspace.yaml"
  click TURBO "https://github.com/trycourier/courier-designer/blob/main/turbo.json"
  click ROOTPKG "https://github.com/trycourier/courier-designer/blob/main/package.json"
  click CHECK "https://github.com/trycourier/courier-designer/blob/main/.github/workflows/check-pull-request.yml"
  click CANARY "https://github.com/trycourier/courier-designer/blob/main/.github/workflows/publish-canary.yml"
  click RELEASE "https://github.com/trycourier/courier-designer/blob/main/.github/workflows/publish-release.yml"
  click RD_MAIN "https://github.com/trycourier/courier-designer/tree/main/packages/react-designer/"
  click RD_BUILD "https://github.com/trycourier/courier-designer/blob/main/packages/react-designer/build.js"
  click RD_SRC "https://github.com/trycourier/courier-designer/tree/main/packages/react-designer/src/"
  click RD_CONFIG "https://github.com/trycourier/courier-designer/tree/main/packages/react-designer/config/"
  click RD_SCRIPTS "https://github.com/trycourier/courier-designer/tree/main/packages/react-designer/scripts/"
  click RD_VITEST "https://github.com/trycourier/courier-designer/blob/main/packages/react-designer/vitest.config.ts"
  click RD_PLAY "https://github.com/trycourier/courier-designer/blob/main/packages/react-designer/playwright.config.ts"
  click VD_MAIN "https://github.com/trycourier/courier-designer/tree/main/packages/vue-designer/"
  click VD_BUILD "https://github.com/trycourier/courier-designer/blob/main/packages/vue-designer/build.js"
  click VD_EDITOR "https://github.com/trycourier/courier-designer/blob/main/packages/vue-designer/src/Editor.vue"
  click VD_INDEX "https://github.com/trycourier/courier-designer/blob/main/packages/vue-designer/src/index.ts"
  click ED_MAIN "https://github.com/trycourier/courier-designer/tree/main/apps/editor-dev/"
  click ED_VITE "https://github.com/trycourier/courier-designer/blob/main/apps/editor-dev/vite.config.ts"
  click ED_SRC "https://github.com/trycourier/courier-designer/tree/main/apps/editor-dev/src/"
  click ED_PKG "https://github.com/trycourier/courier-designer/blob/main/apps/editor-dev/package.json"
  click NJ_MAIN "https://github.com/trycourier/courier-designer/tree/main/apps/nextjs-demo/"
  click NJ_NEXTCFG "https://github.com/trycourier/courier-designer/blob/main/apps/nextjs-demo/next.config.js"
  click NJ_TWCFG "https://github.com/trycourier/courier-designer/blob/main/apps/nextjs-demo/tailwind.config.js"
  click NJ_SRC "https://github.com/trycourier/courier-designer/tree/main/apps/nextjs-demo/src/app/"
  click NJ_PKG "https://github.com/trycourier/courier-designer/blob/main/apps/nextjs-demo/package.json"

  %% Styles
  classDef orchestrator fill:#cccccc,stroke:#333,stroke-width:1px
  classDef cicd fill:#dddddd,stroke:#333,stroke-width:1px
  classDef core fill:#d0e1f9,stroke:#333,stroke-width:1px
  classDef adapter fill:#c8e6c9,stroke:#333,stroke-width:1px
  classDef app fill:#ffe0b2,stroke:#333,stroke-width:1px
  classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px
```
