# awslabs/diagram-maker architecture

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

- Interactive diagram: https://gitdiagram.com/awslabs/diagram-maker
- Repository: https://github.com/awslabs/diagram-maker

## Overview

##### Main Components
- Service Layer: Under “src/service” you have ConfigService, DiagramMakerApi, event management (UIEventManager, UIEventNormalizer) and other utilities that act as bridges between UI actions and state updates.
- Integration & Testing: There are dedicated folders for integration tests (“integ”), end-to-end tests (“cypress”), and storybook demos (“.storybook” and “storybook”). These indicate emphasis on both interactive demos and automated testing.
- Tooling and Build: Configuration files (like webpack.common.js, webpack.prod.js, package.json, tsconfig.json, ESLint, browserConfig files) show how the project is built, linted, and bundled.

##### Relationships and Interactions
- User interactions on UI components (canvas, node, edge, etc.) trigger actions that are dispatched to the global state store.
- The Service Layer (including API and configuration modules) supports enhanced functionalities (like external configuration and events) and communicates with the state management layer.
- Plugins and layout modules (found in both “src/state/plugin” and “src/state/layout”) show extension points where additional behaviors can be injected, indicating a modular design where new features or behavior can be plugged in with minimal friction.
- Testing infrastructure (Cypress tests, integration demos, Storybook demos) ensures that both functionality and UI interactions remain intact as the project scales.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The architecture neatly separates the presentation (UI components), business (state management and service layers), and integration (testing/demo) concerns.
- Modular/Component-based Design: Each UI component and state module is organized in its own folder, highlighting reusability and isolation.
- Declarative Configuration: The README emphasizes a declarative interface, which is reflected in the way state, services, and plugins are designed.
- Extensibility: With plugins and layout variations (e.g., “LeftRightRectangular”, “TopBottomRectangular” in the integ folder), the design facilitates additional functionalities without major refactoring.

- Under this, distinguish between the UI/Presentation Layer (React components) and the underlying core engine.
b. A block for the UI Components:
- Components such as Canvas, Node, Connector, Edge, Context Menu, Panel, etc.
c. A block for the State Management Layer:
- Different state modules (edge, node, editor, layout, etc.) and show that they are coordinated by a central store.
d. A Service/Utility Block:
- Services like ConfigService, DiagramMakerApi, and other utility modules (UI Event Manager, Observer, etc.).
- This block to both the UI Layer and the State Management Layer to show support for event management and configuration.
e. An Integration & Testing Block:
- “cypress” for end-to-end tests, “integ” for integration demos, and “storybook” for live demos/documentation.
f. The Build & Configuration Block:
- Build process including Webpack configuration, ESLint, and TypeScript configurations. This can be depicted on the periphery, representing that it feeds into how the overall system is built and maintained.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Diagram Maker Library Block
    subgraph "Diagram Maker Library"
        direction TB
        UI["UI/Presentation Layer: Canvas, Node, Connector, Edge, ContextMenu, Panel, etc."]:::ui
        SM["State Management Layer: node, edge, editor, layout, global, panel, plugin, workspace"]:::state
        SL["Service Layer: ConfigService, DiagramMakerApi, UIEventManager, UIEventNormalizer, etc."]:::service
        UI -->|"dispatches"| SM
        SM -->|"updates"| UI
        SL -->|"supports"| SM
        SL -->|"supports"| UI
    end

    %% Integration & Testing Block
    subgraph "Integration & Testing"
        direction TB
        IT1["Cypress (End-to-End Testing)"]:::testing
        IT2["Integration Demos (integ)"]:::testing
        IT3["Storybook Demos (.storybook)"]:::testing
        IT4["Storybook Documentation (storybook)"]:::testing
    end

    %% Build & Tooling Configuration Block
    subgraph "Build & Tooling"
        direction TB
        BT1["package.json"]:::build
        BT2["webpack.common.js"]:::build
        BT3["webpack.prod.js"]:::build
        BT4["tsconfig.json"]:::build
        BT5[".eslintrc"]:::build
    end

    %% Relationships between Library and Integration/Build Blocks
    SL -->|"integrates_with"| IT1
    SL -->|"integrates_with"| IT2
    SL -->|"integrates_with"| IT3
    SL -->|"integrates_with"| IT4

    BT1 ---|"configures"| UI
    BT1 ---|"configures"| SM
    BT1 ---|"configures"| SL

    %% Click Events for Component Mapping
    click UI "https://github.com/awslabs/diagram-maker/tree/master/src/components"
    click SM "https://github.com/awslabs/diagram-maker/tree/master/src/state"
    click SL "https://github.com/awslabs/diagram-maker/tree/master/src/service"
    click IT1 "https://github.com/awslabs/diagram-maker/tree/master/cypress"
    click IT2 "https://github.com/awslabs/diagram-maker/tree/master/integ"
    click IT3 "https://github.com/awslabs/diagram-maker/blob/master/.storybook"
    click IT4 "https://github.com/awslabs/diagram-maker/tree/master/storybook"
    click BT1 "https://github.com/awslabs/diagram-maker/blob/master/package.json"
    click BT2 "https://github.com/awslabs/diagram-maker/blob/master/webpack.common.js"
    click BT3 "https://github.com/awslabs/diagram-maker/blob/master/webpack.prod.js"
    click BT4 "https://github.com/awslabs/diagram-maker/blob/master/tsconfig.json"
    click BT5 "https://github.com/awslabs/diagram-maker/blob/master/.eslintrc"

    %% Styles
    classDef ui fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef state fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef service fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef testing fill:#F9C0C0,stroke:#333,stroke-width:2px;
    classDef build fill:#E1BEE7,stroke:#333,stroke-width:2px;
```
