# frontify/brand-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/frontify/brand-sdk
- Repository: https://github.com/frontify/brand-sdk

## Overview

##### Main Components

a. Core Packages Layer:
- App Bridge Package
- CLI Package
- TypeScript Types/Helpers Package
- Guideline Blocks Settings Package
- Platform App Package
- Sidebar Settings Package

b. Integration Layer:
- Frontify Platform
- Local Development Environment
- External Applications

c. Communication Layer:
- API Communication
- Event System
- Message Bus

##### Architectural Patterns to Highlight

a. Bridge Pattern Implementation:
- How App Bridge acts as an abstraction layer between external apps and Frontify's platform
- Message bus system for cross-document communication

b. Plugin Architecture:
- Demonstrate the extensible nature of the RichTextEditor and its plugins
- How different blocks and settings can be composed

**┌─────────────────────────────────────────────────────────────────┐**
- External Applications                        │
- ┬─────────────────────────────────┘

**┌───────────────────────────────▼─────────────────────────────────┐**
- Brand SDK Core                           │
- ┌─────────────┐  ┌──────────────┐  ┌────────────────────────┐  │
- App Bridge  │◄─┤ TypeScript   │  │ Guideline Blocks       │  │
- Package     │  │ Types/Helpers│  │ Settings               │  │
- ┬──────┘  └──────────────┘  └────────────────────────┘  │
- ┌──────────────┐  ┌────────────────────────┐  │
- Platform App │  │ Sidebar Settings       │  │
- ┘  └────────────────────────┘  │
- ┼───────────────────────────────────────────────────────┘

**┌─────────▼───────────────────────────────────────────────────────┐**
- Communication Layer                          │
- ┌─────────────┐  ┌──────────────┐  ┌────────────────────────┐  │
- Message Bus │  │ Event System │  │ API Integration        │  │
- ┘  └──────────────┘  └────────────────────────┘  │
- ┘

**┌─────────▼───────────────────────────────────────────────────────┐**
- Frontify Platform                           │
- ┘

##### Important Details

a. Package Relationships:
- How App Bridge depends on TypeScript types
- How Guideline Blocks Settings uses App Bridge
- Demonstrate CLI's relationship with local development

b. Data Flow:
- Bidirectional communication between App Bridge and Frontify Platform
- Event propagation through the Message Bus
- API calls and responses

##### Additional Elements

a. Development Tools:
- CLI tooling connection to local development
- Build and deployment pipelines

b. Security Layer:
- Authentication and authorization flows
- Secure API communication

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef external fill:#FFA07A,stroke:#FF6347
    classDef core fill:#87CEEB,stroke:#4682B4
    classDef communication fill:#98FB98,stroke:#3CB371
    classDef platform fill:#DDA0DD,stroke:#9370DB
    classDef development fill:#F0E68C,stroke:#DAA520

    %% External Applications Layer
    subgraph ExternalApps["External Applications"]
        EA[External Apps]:::external
    end

    %% Core SDK Layer
    subgraph CoreSDK["Brand SDK Core"]
        AppBridge["App Bridge Package"]:::core
        TypeScript["TypeScript Types/Helpers"]:::core
        GuidelineBlocks["Guideline Blocks Settings"]:::core
        PlatformApp["Platform App"]:::core
        SidebarSettings["Sidebar Settings"]:::core
        CLI["CLI Package"]:::core
        Plugins["Plugin Architecture"]:::core
    end

    %% Communication Layer
    subgraph CommLayer["Communication Layer"]
        MessageBus["Message Bus System"]:::communication
        EventSystem["Event System"]:::communication
        ApiComm["API Communication"]:::communication
        CommandReg["Command Registry"]:::communication
        ApiMethodReg["API Method Registry"]:::communication
    end

    %% Development Layer
    subgraph DevEnv["Development Environment"]
        LocalDev["Local Development"]:::development
    end

    %% Platform Layer
    subgraph Platform["Frontify Platform"]
        FrontifyPlatform["Frontify Platform Core"]:::platform
    end

    %% Relationships
    EA --> AppBridge
    AppBridge --> MessageBus
    AppBridge --> EventSystem
    AppBridge --> ApiComm
    MessageBus --> FrontifyPlatform
    EventSystem --> FrontifyPlatform
    ApiComm --> FrontifyPlatform
    CLI --> LocalDev
    LocalDev --> FrontifyPlatform
    GuidelineBlocks --> AppBridge
    PlatformApp --> AppBridge
    SidebarSettings --> AppBridge
    Plugins --> GuidelineBlocks
    CommandReg --> AppBridge
    ApiMethodReg --> ApiComm

    %% Click Events
    click AppBridge "https://github.com/Frontify/brand-sdk/tree/main/packages/app-bridge"
    click CLI "https://github.com/Frontify/brand-sdk/tree/main/packages/cli"
    click GuidelineBlocks "https://github.com/Frontify/brand-sdk/tree/main/packages/guideline-blocks-settings"
    click PlatformApp "https://github.com/Frontify/brand-sdk/tree/main/packages/platform-app"
    click SidebarSettings "https://github.com/Frontify/brand-sdk/tree/main/packages/sidebar-settings"
    click MessageBus "https://github.com/Frontify/brand-sdk/blob/main/packages/app-bridge/src/utilities/MessageBus.ts"
    click EventSystem "https://github.com/Frontify/brand-sdk/blob/main/packages/app-bridge/src/registries/events/EventRegistry.ts"
    click ApiComm "https://github.com/Frontify/brand-sdk/tree/main/packages/app-bridge/src/registries/api"
    click LocalDev "https://github.com/Frontify/brand-sdk/tree/main/packages/cli/src/servers"
    click Plugins "https://github.com/Frontify/brand-sdk/tree/main/packages/guideline-blocks-settings/src/components/RichTextEditor/plugins"
    click CommandReg "https://github.com/Frontify/brand-sdk/blob/main/packages/app-bridge/src/registries/commands/CommandRegistry.ts"
    click ApiMethodReg "https://github.com/Frontify/brand-sdk/blob/main/packages/app-bridge/src/registries/api/ApiMethodRegistry.ts"

    %% Legend
    subgraph Legend
        L1["External Component"]:::external
        L2["Core Component"]:::core
        L3["Communication Component"]:::communication
        L4["Platform Component"]:::platform
        L5["Development Component"]:::development
    end
```
