# applovin/applovin-max-react-native architecture

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

- Interactive diagram: https://gitdiagram.com/applovin/applovin-max-react-native
- Repository: https://github.com/applovin/applovin-max-react-native

## Overview

##### Main Components

a. Client Layer (React Native Application)
- React Native JavaScript bridge
- Main entry points (src/index.ts)
- Different ad type components:
- Banner Ads
- Interstitial Ads
- Rewarded Ads
- Native Ads
- MRec Ads
- App Open Ads

b. Bridge Layer
- Native Modules Bridge
- Event Emitter System
- Type Definitions Interface

c. Platform-Specific Native Implementations
- iOS Implementation (Objective-C/Swift)
- Android Implementation (Java)

d. AppLovin MAX SDK
- Ad Network Mediation
- Ad Serving System
- Analytics & Reporting

##### Key Relationships to Highlight

- Bidirectional communication between:
- React Native components and native modules
- Native implementations and AppLovin SDK
- Event system flow from SDK to React Native

##### Specific Elements

a. Components:
- Ad View Components (src/AdView.tsx)
- Native Ad Components (src/nativeAd/*)
- Privacy Controls (src/Privacy.ts)
- Configuration Management (src/types/Configuration.ts)

b. Event System:
- Ad Events (src/types/AdEvent.ts)
- Error Handling (src/types/CMPError.ts)
- Callback System

##### Implementation Details

- Use rectangles for main components
- Interface definitions between layers

##### Specific Features to Emphasize

- Multiple ad format support
- Cross-platform compatibility
- Event handling system
- Type safety implementation
- Privacy controls

Remember to include a small overview section explaining the main components and their responsibilities, as this will help other developers understand the system's architecture quickly.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef reactNative fill:#3498db,color:white
    classDef bridge fill:#2ecc71,color:white
    classDef native fill:#e67e22,color:white
    classDef sdk fill:#9b59b6,color:white
    classDef external fill:#95a5a6,color:white

    %% Client Layer
    subgraph RNApp["React Native Application"]
        Entry["Entry Point"]:::reactNative
        AdComponents["Ad Components"]:::reactNative
        UIComponents["UI Components"]:::reactNative
    end

    %% Ad Components Detail
    subgraph AdTypes["Ad Type Components"]
        Banner["Banner Ads"]:::reactNative
        Interstitial["Interstitial Ads"]:::reactNative
        Rewarded["Rewarded Ads"]:::reactNative
        Native["Native Ads"]:::reactNative
        MRec["MRec Ads"]:::reactNative
        AppOpen["App Open Ads"]:::reactNative
    end

    %% Bridge Layer
    subgraph Bridge["Bridge Layer"]
        CoreBridge["Core Bridge"]:::bridge
        EventEmitter["Event Emitter"]:::bridge
        TypeDefs["Type Definitions"]:::bridge
    end

    %% Native Implementation
    subgraph NativeLayer["Native Implementation"]
        iOSImpl["iOS Implementation"]:::native
        AndroidImpl["Android Implementation"]:::native
    end

    %% AppLovin SDK
    subgraph AppLovinSDK["AppLovin MAX SDK"]
        AdNetwork["Ad Network Mediation"]:::sdk
        AdServing["Ad Serving System"]:::sdk
        Analytics["Analytics & Reporting"]:::sdk
    end

    %% Supporting Components
    subgraph Support["Supporting Components"]
        Privacy["Privacy Controls"]:::bridge
        Config["Configuration"]:::bridge
        AdEvents["Ad Events"]:::bridge
        ErrorHandling["Error Handling"]:::bridge
    end

    %% Relationships
    Entry --> AdComponents
    AdComponents --> AdTypes
    AdTypes --> CoreBridge
    CoreBridge --> EventEmitter
    CoreBridge --> TypeDefs
    CoreBridge --> NativeLayer
    NativeLayer --> AppLovinSDK
    EventEmitter --> AdComponents
    Support --> CoreBridge

    %% Click Events
    click Entry "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/index.ts"
    click Banner "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/BannerAd.ts"
    click Interstitial "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/InterstitialAd.ts"
    click Rewarded "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/RewardedAd.ts"
    click Native "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/nativeAd/NativeAdView.tsx"
    click MRec "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/MRecAd.ts"
    click AppOpen "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/AppOpenAd.ts"
    click EventEmitter "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/EventEmitter.ts"
    click TypeDefs "https://github.com/AppLovin/AppLovin-MAX-React-Native/tree/master/src/types/"
    click CoreBridge "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/AppLovinMAX.ts"
    click iOSImpl "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/ios/AppLovinMAX.m"
    click AndroidImpl "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/android/src/main/java/com/applovin/reactnative/AppLovinMAXModule.java"
    click Privacy "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/Privacy.ts"
    click Config "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/types/Configuration.ts"
    click AdEvents "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/types/AdEvent.ts"
    click ErrorHandling "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/types/CMPError.ts"
    click UIComponents "https://github.com/AppLovin/AppLovin-MAX-React-Native/blob/master/src/nativeAd/NativeAdViewComponents.tsx"

    %% Legend
    subgraph Legend
        RN["React Native"]:::reactNative
        BR["Bridge"]:::bridge
        NAT["Native"]:::native
        SDK["SDK"]:::sdk
        EXT["External"]:::external
    end
```
