# braze-inc/braze-swift-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/braze-inc/braze-swift-sdk
- Repository: https://github.com/braze-inc/braze-swift-sdk

## Overview

##### Main Components Overview
The system should be divided into these primary components:

**Core SDK Components:**
- BrazeKit (Analytics & Push Notifications)
- BrazeUI (User Interface Components)
- BrazeLocation (Location Services)
- BrazeNotificationService (Rich Push Notifications)
- BrazePushStory (Push Stories)

##### Detailed Architecture Breakdown

a) Core Layer (BrazeKit):
- Analytics Engine
- Push Notification Handler
- Data Collection Services
- SDK Configuration
- Authentication Services

b) UI Layer (BrazeUI):
- In-App Messaging System
- Content Cards Interface
- Banner Management
- Custom UI Components
- Localization Support (extensive, as seen in Resources/Localization)

c) Service Extensions:
- Notification Service Extension
- Push Story Extension
- Location Services

##### Integration Points

- Mobile App Integration Points
- Backend Services Communication
- Push Notification Infrastructure
- Analytics Data Flow

##### Specific Implementation Details

- Blue rectangles: Core SDK modules
- Green rectangles: UI components
- Yellow diamonds: Service extensions
- Red circles: Integration points
- Gray rectangles: Resource bundles

##### Data Flow Representation

- Analytics data flow to Braze servers
- Push notification path
- Location data processing
- Content delivery mechanisms

##### Component Relationships

**Mobile App**
- ↓
**BrazeKit (Core)**
- ↙     ↓     ↘
**BrazeUI  BrazeLocation  BrazeNotificationService**
- ↓         ↓              ↓
**User Interface  Location     Push**
**Components     Services    Notifications**

##### Cross-Platform Support

Platform-specific implementations for:
- iOS
- tvOS
- visionOS
- Mac Catalyst

##### Key Features to Highlight

- Analytics & User Tracking
- Push Notification Systems
- In-App Messaging
- Content Cards
- Location Services
- Rich Push Notifications
- Push Stories

##### Integration Methods

Support for:
- Swift Package Manager
- CocoaPods
- Manual Integration

##### Resource Management

Include:
- Localization Bundles
- Asset Management
- Configuration Files

- Core SDK Components
- UI Layer
- Service Extensions
- Platform-Specific Implementations

- Component types
- Data flow directions
- Platform support indicators
- Integration method indicators

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        CoreSDK[Core SDK Components]:::core
        UIComp[UI Components]:::ui
        ServiceExt[Service Extensions]:::service
        IntPoint[Integration Points]:::integration
        ResourceB[Resource Bundles]:::resource
    end

    subgraph "Mobile Application"
        MobileApp[Mobile App Integration]:::integration
    end

    subgraph "Core Layer"
        CoreSDK_Main["BrazeKit (Core SDK)"]:::core
        Analytics["Analytics Engine"]:::core
        PushHandler["Push Notification Handler"]:::core
        DataCollection["Data Collection Services"]:::core
        SDKConfig["SDK Configuration"]:::core
        Auth["Authentication Services"]:::core
    end

    subgraph "UI Layer"
        BrazeUI["BrazeUI"]:::ui
        InApp["In-App Messaging System"]:::ui
        ContentCards["Content Cards Interface"]:::ui
        Banner["Banner Management"]:::ui
        CustomUI["Custom UI Components"]:::ui
        Localization["Localization Support"]:::resource
    end

    subgraph "Service Extensions"
        NotificationService["Notification Service Extension"]:::service
        PushStory["Push Story Extension"]:::service
        Location["Location Services"]:::service
    end

    subgraph "Platform Support"
        iOS["iOS"]:::platform
        tvOS["tvOS"]:::platform
        visionOS["visionOS"]:::platform
        MacCatalyst["Mac Catalyst"]:::platform
    end

    MobileApp --> CoreSDK_Main
    CoreSDK_Main --> Analytics
    CoreSDK_Main --> PushHandler
    CoreSDK_Main --> DataCollection
    CoreSDK_Main --> SDKConfig
    CoreSDK_Main --> Auth

    CoreSDK_Main --> BrazeUI
    BrazeUI --> InApp
    BrazeUI --> ContentCards
    BrazeUI --> Banner
    BrazeUI --> CustomUI
    BrazeUI --> Localization

    CoreSDK_Main --> NotificationService
    CoreSDK_Main --> PushStory
    CoreSDK_Main --> Location

    CoreSDK_Main --> iOS
    CoreSDK_Main --> tvOS
    CoreSDK_Main --> visionOS
    CoreSDK_Main --> MacCatalyst

    %% Click events for component mapping
    click CoreSDK_Main "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeKitCompat"
    click InApp "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeUI/InAppMessageUI"
    click ContentCards "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeUI/ContentCardUI"
    click Banner "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeUI/BannerUI"
    click CustomUI "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeUI/Dependencies"
    click Localization "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeUI/Resources/Localization"
    click Location "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazeLocationResources"
    click PushHandler "https://github.com/braze-inc/braze-swift-sdk/blob/main/Sources/BrazeKitCompat/AppboyKit/ABKPushUtils.m"
    click PushStory "https://github.com/braze-inc/braze-swift-sdk/tree/main/Sources/BrazePushStoryResources"
    click Auth "https://github.com/braze-inc/braze-swift-sdk/blob/main/Sources/BrazeKitCompat/AppboyKit/ABKSdkAuthenticationError.m"

    classDef core fill:#2374ab
    classDef ui fill:#47a025
    classDef service fill:#ffb627
    classDef integration fill:#d62828
    classDef resource fill:#808080
    classDef platform fill:#6c757d
```
