# get-advantage/advantage architecture

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

- Interactive diagram: https://gitdiagram.com/get-advantage/advantage
- Repository: https://github.com/get-advantage/advantage

## Overview

##### Main Components

a) Core Components:
- Advantage Wrapper (Central Component)
- Format Engine
- Messaging System
- UI Layer
- Publisher Integration
- Creative Integration

b) Format Types:
- TopScroll
- MidScroll
- WelcomePage

##### Component Relationships

**Top Layer: Integration Points**

**Middle Layer: Core Framework**

**Bottom Layer: Format Implementation**

##### Specific Implementation Details

a) Publisher Side:
- Integration point with website
- Configuration options
- Message handling system

b) Creative Side:
- Format rendering system
- UI components
- Message handling

c) Core Framework:
- Wrapper implementation
- Format management
- Security layer
- Messaging bus

##### Key Architectural Patterns to Highlight

- Message-based communication system (evident from messaging directory)
- Plugin-based format system (shown in formats directory)
- Separation of concerns between UI and logic
- Type-safe implementation (TypeScript usage)

##### Technical Stack Elements

- TypeScript as primary language
- Vite for building
- Cypress for testing
- CSS modules for styling

**┌─────────────────────────────────────────┐**
- Publisher Website             │
- ┬───────────────────────┘

**┌─────────────────▼───────────────────────┐**
- Advantage Wrapper Layer          │
- ┬───────────────────────┤
- Message Bus    │     Security Layer    │
- ┼───────────────────────┘

**┌─────────────────▼───────────────────────┐**
- Format Engine                 │
- ┬───────────┬─────────────────┤
- TopScroll │ MidScroll │   WelcomePage   │
- ┴───────────┴─────────────────┘

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef integration fill:#4CAF50,stroke:#2E7D32,color:white
    classDef format fill:#FFC107,stroke:#FFA000,color:black
    classDef messaging fill:#FF5722,stroke:#E64A19,color:white
    classDef ui fill:#9C27B0,stroke:#7B1FA2,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Integration Points]:::integration
        L3[Format Components]:::format
        L4[Messaging Components]:::messaging
        L5[UI Components]:::ui
    end

    %% Publisher Integration Layer
    subgraph "Publisher Integration"
        PI[Publisher Website]:::integration
        PC[Configuration]:::integration
    end
    click PC "https://github.com/get-advantage/advantage/blob/main/playground/local-dev/config.ts"

    %% Core Framework Layer
    subgraph "Core Framework"
        AW[Advantage Wrapper]:::core
        FE[Format Engine]:::core
        MB[Message Bus]:::core
        SL[Security Layer]:::core
    end
    click AW "https://github.com/get-advantage/advantage/blob/main/src/advantage/wrapper.ts"
    click FE "https://github.com/get-advantage/advantage/blob/main/src/advantage/formats/format-helper.ts"

    %% Messaging System
    subgraph "Messaging System"
        PS[Publisher Side]:::messaging
        CS[Creative Side]:::messaging
    end
    click PS "https://github.com/get-advantage/advantage/blob/main/src/advantage/messaging/publisher-side.ts"
    click CS "https://github.com/get-advantage/advantage/blob/main/src/advantage/messaging/creative-side.ts"

    %% UI Layer
    subgraph "UI Components"
        UIL[UI Layer]:::ui
    end
    click UIL "https://github.com/get-advantage/advantage/blob/main/src/advantage/ui-layer.ts"

    %% Format Implementation Layer
    subgraph "Format Types"
        TS[TopScroll]:::format
        MS[MidScroll]:::format
        WP[WelcomePage]:::format
    end
    click TS "https://github.com/get-advantage/advantage/blob/main/src/advantage/formats/topscroll.ts"
    click MS "https://github.com/get-advantage/advantage/blob/main/src/advantage/formats/midscroll.ts"
    click WP "https://github.com/get-advantage/advantage/blob/main/src/advantage/formats/welcomepage.ts"

    %% Relationships
    PI --> PC
    PC --> AW
    AW --> MB
    MB --> SL
    MB --> PS
    MB --> CS
    AW --> FE
    FE --> UIL
    FE --> TS
    FE --> MS
    FE --> WP
    PS -.-> MB
    CS -.-> MB
    UIL -.-> TS
    UIL -.-> MS
    UIL -.-> WP
```
