# karote00/cdd-example architecture

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

- Interactive diagram: https://gitdiagram.com/karote00/cdd-example
- Repository: https://github.com/karote00/cdd-example

## Overview

##### Project Type & Purpose
- This is a front-end-centric monorepo (managed by Yarn Workspaces and Turborepo) containing a React/Vite “apps/ui” application and ~15 domain-specific packages (core, input-system, interaction-core, render, scene-tree, selection, system-context, ui-context, props-manager, reactive-events, design-system, etc.).
- It appears to implement a modular, event-driven “design tool” framework: the UI side loads domain packages that talk over an event bus to handle input, state, rendering, undo/redo, selection, and so on.

##### File-Structure Analysis
- Top-level: monorepo config files (.gitignore, turbo.json, GitHub workflows, package.json).
- “apps/ui”: the React entry point (Vite, PostCSS/Tailwind, index.html, src/ directory with controllers, contexts, providers, states, components).
- “packages/…”: each package implements one responsibility:
– core: central API layer & subscriptions
– input-system: low-level event mapping & subscription
– interaction-core: business rules & handlers
– factory: data creation & registry
– props-manager: property panel logic
– render: canvas/SVG rendering layers
– scene-tree: component tree UI
– selection: selection management
– system-context, ui-context: shared state hooks & stores
– reactive-events: the shared pub/sub/event bus
– design-system: reusable UI components
– utils & event-emitter: generic helpers
- Build & deployment: Vite for the app, Storybook in design-system, Turbo scripts for “dev-all” and CI, Vercel config.

##### Key Insights from README
- The name “Communication-Driven-Development” implies an event-driven architecture where domain modules communicate via channels (reactive-events).

##### Main Components & Interactions
a. Frontend App (“apps/ui”):
– Hosts the React UI, imports domain packages.
– Contains Controllers → dispatch user actions into the event bus.
– Contains Providers & Contexts → subscribe to shared state streams.
– Renders UI via design-system components.
b. Domain Modules (packages/…):
– reactive-events: the central Event Bus (publish/subscribe streams per domain)
– input-system → normalizes raw DOM events → publishes input events
– interaction-core → applies business rules (drag, pan/zoom, select, undo/redo) → publishes interaction events
– factory → creates and registers new elements/scene objects
– props-manager → listens for selection changes → updates property panel state
– selection → manages current selection state
– render → listens for scene-tree & viewport updates → draws canvas/SVG layers
– system-context & ui-context → maintain global application and UI state
– core → provides high-level API endpoints wrapping other modules
c. Data Flow:
User → React Controller → input-system → event bus → interaction-core → event bus → factory/selection/scene-tree/props-manager → event bus → render → React view → Canvas/SVG
d. Architectural Patterns & Principles
– Monorepo with logical packages (separation of concerns)
– Event-Driven Architecture (EDA) / Pub-Sub via reactive-events
– Layered: Input → Business Logic → Data/State Management → Render → UI
– DI‐style: each package exports minimal apis & subscribes only to its domain channel
– Hooks/Context in React for state subscription

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User"]:::external

    %% UI Layer
    subgraph "UI Layer"
        UIController["React Controllers\napps/ui"]:::ui
        ReactView["React View\napps/ui"]:::ui
        DesignSystem["Design System UI Components\npackages/design-system"]:::ui
    end

    %% Event Bus
    EventBus["Event Bus\npackages/reactive-events"]:::bus

    %% Domain Logic
    subgraph "Domain Logic"
        InputSystem["Input System\npackages/input-system"]:::domain
        InteractionCore["Interaction Core\npackages/interaction-core"]:::domain
        CoreAPI["Core API Layer\npackages/core"]:::domain
        Factory["Factory / Data Layer\npackages/factory"]:::domain
    end

    %% State Managers
    subgraph "State Managers"
        Selection["Selection Manager\npackages/selection"]:::state
        SceneTree["Scene-Tree Manager\npackages/scene-tree"]:::state
        PropsManager["Props Manager\npackages/props-manager"]:::state
        SysContext["System Context\npackages/system-context"]:::state
        UIContext["UI Context\npackages/ui-context"]:::state
    end

    %% Render Layer
    RenderEngine["Render Engine\npackages/render"]:::render

    %% Flows
    User -->|"user action"| UIController
    UIController -->|"dispatch event"| InputSystem
    InputSystem -->|"normalizedEvent"| EventBus
    EventBus -->|"inputEvent"| InteractionCore
    InteractionCore -->|"interactionEvent"| EventBus
    EventBus -->|"createEvent"| Factory
    EventBus -->|"selectEvent"| Selection
    EventBus -->|"sceneUpdate"| SceneTree
    EventBus -->|"propsUpdate"| PropsManager
    EventBus -->|"contextUpdate"| SysContext
    EventBus -->|"uiContextUpdate"| UIContext
    Factory -->|"dataReady"| EventBus
    Selection -->|"selectionChanged"| EventBus
    SceneTree -->|"treeChanged"| EventBus
    PropsManager -->|"propsChanged"| EventBus
    SysContext -->|"sysState"| EventBus
    UIContext -->|"uiState"| EventBus
    EventBus -->|"renderRequest"| RenderEngine
    RenderEngine -->|"renderOutput"| ReactView
    ReactView -->|"updateUI"| DesignSystem

    %% Click Events
    click UIController "https://github.com/karote00/cdd-example/tree/main/apps/ui"
    click ReactView "https://github.com/karote00/cdd-example/tree/main/apps/ui"
    click DesignSystem "https://github.com/karote00/cdd-example/tree/main/packages/design-system"
    click EventBus "https://github.com/karote00/cdd-example/tree/main/packages/reactive-events"
    click InputSystem "https://github.com/karote00/cdd-example/tree/main/packages/input-system"
    click InteractionCore "https://github.com/karote00/cdd-example/tree/main/packages/interaction-core"
    click CoreAPI "https://github.com/karote00/cdd-example/tree/main/packages/core"
    click Factory "https://github.com/karote00/cdd-example/tree/main/packages/factory"
    click Selection "https://github.com/karote00/cdd-example/tree/main/packages/selection"
    click SceneTree "https://github.com/karote00/cdd-example/tree/main/packages/scene-tree"
    click PropsManager "https://github.com/karote00/cdd-example/tree/main/packages/props-manager"
    click SysContext "https://github.com/karote00/cdd-example/tree/main/packages/system-context"
    click UIContext "https://github.com/karote00/cdd-example/tree/main/packages/ui-context"
    click RenderEngine "https://github.com/karote00/cdd-example/tree/main/packages/render"

    %% Styles
    classDef external fill:#FFFFFF,stroke:#000000,color:#000000;
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef bus fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00;
    classDef domain fill:#E2F0D9,stroke:#32CD32,color:#228B22;
    classDef state fill:#E8D0FF,stroke:#800080,color:#800080;
    classDef render fill:#D0FFF0,stroke:#20B2AA,color:#20B2AA;
```
