# moengage/moengage-ios-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/moengage/moengage-ios-sdk
- Repository: https://github.com/moengage/moengage-ios-sdk

## Overview

##### Main Components
- SDK Core: At the heart is the MoEngage-iOS-SDK module (and likely MoEngageCore.podspec) which manages the common functionalities required for various features.
- Feature Modules: You have several submodules indicated by separate podspec files and SPM directories. These include:
– Analytics: MoEngageAnalytics.podspec
– Cards: MoEngageCards.podspec and Sources/MoEngageCardsSPM
– Geofence: MoEngageGeofence.podspec and Sources/MoEngageGeofenceSPM
– InApps: MoEngageInApps.podspec and Sources/MoEngageInAppSPM
– Inbox: MoEngageInbox.podspec and Sources/MoEngageInboxSPM
– Messaging: MoEngageMessaging.podspec
– Real-Time Trigger: MoEngageRealTimeTrigger.podspec and Sources/MoEngageRealTimeTriggerSPM
– Rich Notification: MoEngageRichNotification.podspec and Sources/MoEngageRichNotificationSPM
– Security: MoEngageSecurity.podspec
– Trigger Evaluator: MoEngageTriggerEvaluator.podspec and Sources/MoEngageTriggerEvaluatorSPM
– Objective-C Utilities: MoEngageObjCUtils.podspec
- Supporting Utilities: The Utilities directory contains scripts (pod_publish.rb, post_build.rb, spec.rb) that handle build, testing, or deployment tasks.
- Documentation: The docs folder contains auto-generated documentation (using Jazzy judging by the filenames) along with packaged docsets.
- External Configuration: There’s also a GitHub workflows directory (.github/workflows) that shows CI/CD integration.

##### Relationships and Interactions
- The clients (iOS apps integrating the SDK) interact with the SDK’s public API provided by MoEngage-iOS-SDK.
- The core module likely exposes shared services such as event logging, API communication, and configuration management.
- The feature modules (Cards, Geofence, etc.) plug into the core, each handling distinct functionalities. They might internally communicate with the core module and, possibly, among themselves if there are shared dependencies.
- Build and packaging utilities ensure that both the CocoaPods and SPM distributions are built, tested, and published consistently.

##### Architectural Patterns
- Modularity: Emphasize that each functional area (cards, inbox, inapp, etc.) is separated, making it easier to maintain, update, or even swap out components.
- Multi-distribution: The project is designed for both CocoaPods and Swift Package Manager, so include notes about dual distribution channels.
- CI/CD and Automated Documentation: The inclusion of GitHub workflows and comprehensive docs suggest an automated dev and deployment process.
- Clear separation between API (public interfaces for integration) and internal implementations.

##### Relevant Technologies and Frameworks
- CocoaPods and SPM distribution methods.
- Likely native iOS frameworks (UIKit, Foundation) as dependencies.
- Automated documentation generators (Jazzy).
- Build automation scripts in Ruby (see the Utilities folder).

## Diagram (Mermaid)

```mermaid
flowchart TD
    client["iOS App (Client)"]:::client
    sdk_api["MoEngage-iOS-SDK (Public API)"]:::sdk
    backend["MoEngage Backend Services"]:::feature

    client -->|"uses"| sdk_api
    sdk_api -->|"coordinates"| sdk_core
    sdk_api -->|"data_sync"| backend
    backend -->|"push_notify"| sdk_api

    subgraph "SDK Modules"
        sdk_core["SDK Core"]:::feature
        analytics["Analytics"]:::feature
        cards["Cards"]:::feature
        geofence["Geofence"]:::feature
        inapps["In-App"]:::feature
        inbox["Inbox"]:::feature
        messaging["Messaging"]:::feature
        real_time["Real-Time Trigger"]:::feature
        rich_notification["Rich Notification"]:::feature
        security["Security"]:::feature
        trigger_eval["Trigger Evaluator"]:::feature
        objc_utils["Objective-C Utilities"]:::feature
    end

    sdk_core -->|"handles"| analytics
    sdk_core -->|"handles"| cards
    sdk_core -->|"handles"| geofence
    sdk_core -->|"handles"| inapps
    sdk_core -->|"handles"| inbox
    sdk_core -->|"handles"| messaging
    sdk_core -->|"handles"| real_time
    sdk_core -->|"handles"| rich_notification
    sdk_core -->|"handles"| security
    sdk_core -->|"handles"| trigger_eval
    sdk_core -->|"provides"| objc_utils

    subgraph "Supporting Tools"
        utilities["Utilities Scripts"]:::tool
        documentation["Documentation (Jazzy)"]:::doc
        cicd["CI/CD (GitHub Workflows)"]:::cicd
    end

    utilities -->|"build_test"| sdk_api
    cicd -->|"triggers_build"| utilities
    sdk_api -->|"publishes_docs"| documentation

    click sdk_core "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngage-iOS-SDK.podspec"
    click sdk_core "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageCore.podspec"
    click analytics "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageAnalytics.podspec"
    click cards "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageCards.podspec"
    click cards "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageCardsSPM"
    click geofence "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageGeofence.podspec"
    click geofence "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageGeofenceSPM"
    click inapps "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageInApps.podspec"
    click inapps "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageInAppSPM"
    click inbox "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageInbox.podspec"
    click inbox "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageInboxSPM"
    click messaging "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageMessaging.podspec"
    click real_time "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageRealTimeTrigger.podspec"
    click real_time "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageRealTimeTriggerSPM"
    click rich_notification "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageRichNotification.podspec"
    click rich_notification "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageRichNotificationSPM"
    click security "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageSecurity.podspec"
    click trigger_eval "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageTriggerEvaluator.podspec"
    click trigger_eval "https://github.com/moengage/moengage-ios-sdk/tree/master/Sources/MoEngageTriggerEvaluatorSPM"
    click objc_utils "https://github.com/moengage/moengage-ios-sdk/blob/master/MoEngageObjCUtils.podspec"
    click utilities "https://github.com/moengage/moengage-ios-sdk/tree/master/Utilities"
    click documentation "https://github.com/moengage/moengage-ios-sdk/tree/master/docs"
    click cicd "https://github.com/moengage/moengage-ios-sdk/tree/master/.github/workflows"

    classDef client fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef sdk fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef feature fill:#99FF99,stroke:#333,stroke-width:2px;
    classDef tool fill:#FF9999,stroke:#333,stroke-width:2px;
    classDef doc fill:#FFCC99,stroke:#333,stroke-width:2px;
    classDef cicd fill:#CC99FF,stroke:#333,stroke-width:2px;
```
