# dyn-art/monorepo architecture

> Architecture diagram of the GitHub repository dyn-art/monorepo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dyn-art/monorepo
- Repository: https://github.com/dyn-art/monorepo

## Overview

##### Main System Components

a. Frontend Applications:
- Web Application (apps/web)
- Figma Plugin (apps/figma-plugin)

b. Backend Services:
- Core API Service (apps/ee_core-node)
- Graphic Service (apps/ee_graphic)

c. Core Libraries:
- SVG Builder (crates/arb_svg_builder)
- DTIF Processing (packages/arb-dtif)
- UI Components (packages/ui)

##### Key Architectural Elements

a. Client Layer:
- Web Interface
- Figma Plugin Interface
- API Clients

b. Service Layer:
- Image Generation Service
- SVG Processing Service
- Authentication Service

c. Core Processing Layer:
- SVG Builder Engine
- DTIF Transformer
- Asset Processing

d. Data Layer:
- Database (indicated by drizzle migrations)
- Asset Storage

**[Client Layer]**
- ↓
**[API Gateway]**
- ↓
**[Service Layer]**
- ↓
**[Core Processing]**
- ↓
**[Data Layer]**

##### Important Flows to Highlight

a. Image Generation Flow:
- Client Request → API Gateway
- Service Layer Processing
- SVG/Image Generation
- Response Delivery

b. Asset Management Flow:
- Asset Upload
- Processing Pipeline
- Storage and Caching
- Delivery

##### Component Relationships

Clear connections between:
- Figma Plugin ↔ API Gateway
- Web App ↔ API Gateway
- API Gateway ↔ Services
- Services ↔ Core Processing
- Core Processing ↔ Data Layer

##### Technical Details

- Rust-based image processing pipeline
- SVG generation and optimization
- DTIF (Dynamic Template Intermediate Format) processing
- Database interactions
- Caching mechanisms
- API endpoints

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#0000ff'
  }
}}%%

flowchart TB
    %% Styles
    classDef client fill:#4a90e2,stroke:#2b2b2b,color:white
    classDef service fill:#50c878,stroke:#2b2b2b,color:white
    classDef core fill:#9b59b6,stroke:#2b2b2b,color:white
    classDef data fill:#f1c40f,stroke:#2b2b2b,color:black
    classDef security fill:#e74c3c,stroke:#2b2b2b,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        WebApp["Web Application"]:::client
        FigmaPlugin["Figma Plugin"]:::client
        UIComponents["UI Components"]:::client
        Editor["Frontend Editor"]:::client
    end

    %% API Gateway Layer
    subgraph APILayer["API Gateway Layer"]
        APIGateway["API Gateway"]:::service
        AuthService["Authentication Service"]:::security
        APITypes["API Types"]:::service
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        CoreAPI["Core API Service"]:::service
        GraphicService["Graphic Service"]:::service
        ImageProcessor["Image Processing Pipeline"]:::service
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        SVGBuilder["SVG Builder"]:::core
        DTIFProcessor["DTIF Processor"]:::core
        CoreEngine["Core Processing Engine"]:::core
        AssetManager["Asset Manager"]:::core
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        DB[(Database)]:::data
        AssetStorage[("Asset Storage")]:::data
    end

    %% Connections
    WebApp --> APIGateway
    FigmaPlugin --> APIGateway
    APIGateway --> AuthService
    APIGateway --> CoreAPI
    APIGateway --> GraphicService
    CoreAPI --> SVGBuilder
    CoreAPI --> DTIFProcessor
    GraphicService --> ImageProcessor
    ImageProcessor --> CoreEngine
    CoreEngine --> AssetManager
    AssetManager --> AssetStorage
    CoreAPI --> DB
    UIComponents --> WebApp
    Editor --> WebApp
    APITypes --> APIGateway

    %% Click Events
    click WebApp "https://github.com/dyn-art/monorepo/tree/develop/apps/web"
    click FigmaPlugin "https://github.com/dyn-art/monorepo/tree/develop/apps/figma-plugin"
    click CoreAPI "https://github.com/dyn-art/monorepo/tree/develop/apps/ee_core-node"
    click GraphicService "https://github.com/dyn-art/monorepo/tree/develop/apps/ee_graphic"
    click SVGBuilder "https://github.com/dyn-art/monorepo/tree/develop/crates/arb_svg_builder"
    click DTIFProcessor "https://github.com/dyn-art/monorepo/tree/develop/packages/arb-dtif"
    click UIComponents "https://github.com/dyn-art/monorepo/tree/develop/packages/ui"
    click DB "https://github.com/dyn-art/monorepo/tree/develop/apps/ee_core-node/drizzle/migrations"
    click CoreEngine "https://github.com/dyn-art/monorepo/tree/develop/crates/arb_core"
    click AssetManager "https://github.com/dyn-art/monorepo/tree/develop/crates/arb_asset"
    click Editor "https://github.com/dyn-art/monorepo/tree/develop/packages/arb-svg-editor"
    click APITypes "https://github.com/dyn-art/monorepo/tree/develop/packages/types"
    click AuthService "https://github.com/dyn-art/monorepo/tree/develop/apps/web/src/app/auth"
    click ImageProcessor "https://github.com/dyn-art/monorepo/tree/develop/apps/ee_graphic/src/routes/v1/artboard"

    %% Legend
    subgraph Legend
        ClientComp["Client Component"]:::client
        ServiceComp["Service Component"]:::service
        CoreComp["Core Component"]:::core
        DataComp["Data Store"]:::data
        SecurityComp["Security Component"]:::security
    end
```
