# matifdeveloper/admob_easy architecture

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

- Interactive diagram: https://gitdiagram.com/matifdeveloper/admob_easy
- Repository: https://github.com/matifdeveloper/admob_easy

## Overview

##### Project type and purpose
- This is a Flutter plugin/package named “Admob Easy.”

##### File structure
- Top-level: pubspec.yaml, README, CHANGELOG, LICENSE, .gitignore, analysis_options.yaml
- lib/
- admob_easy.dart – main entrypoint and singleton (AdmobEasy.instance)
- ads/
– controllers/connectivity_controller.dart – tracks network status
– helper/admob_helper.dart & admob_ump_helper.dart – wrap AdMob SDK initialization and UMP consent flows
– services/… – classes to initialize and load each ad type (banner_ad.dart, rewarded_ad.dart, open_app_ad.dart, init_ad.dart, admob_easy_native.dart)
– sources.dart – constants for ad-unit IDs
– utils/admob_easy_logger.dart – logging
- No “frontend” or “backend” directories because it’s a client-side library.

##### README for additional insights
- It shows how to configure AndroidManifest and Info.plist, how to call initialize(), create/load/show methods, and use the AdmobEasyNative widget.
- UMP consent and connectivity monitoring are key features.

a. Main components
- Flutter Application (your host app)
- AdmobEasy plugin (Dart layer)
– AdmobEasy singleton façade
– ConnectivityController
– AdmobHelper & UMPHelper
– Ad services (BannerService, RewardedService, OpenAppService, InterstitialService)
– Native ad widget (AdmobEasyNative)
– Logger
- Platform Channels
- Native AdMob SDKs on Android & iOS (including UMP)
b. Relationships and interactions
1. App calls AdmobEasy.instance.initialize(…)
2. AdmobEasy façade invokes AdmobHelper to configure SDK with ad unit IDs
3. UMPHelper handles consent dialogues via platform channel to native UMP SDK
4. ConnectivityController polls network state and exposes ValueListenable to app/services
5. When app calls create/load/show methods, corresponding service class
- checks connectivity
- requests ad via platform channel to native AdMob SDK
- forwards events (onLoaded, onClicked, onPaidEvent) back to Dart
6. AdmobEasyNative widget requests a native ad, receives a PlatformView from the SDK
c. Architectural patterns and design principles
- Singleton pattern for AdmobEasy.instance
- Façade pattern – unified API over multiple ad types and consent flow
- Controller for connectivity (separation of concerns)
- Service classes for each ad type (single responsibility)
- Platform channel abstraction isolates Dart from native SDK details
d. Key technologies and frameworks
- Dart & Flutter widgets (AdmobEasyNative extends StatefulWidget)
- Platform channels for iOS and Android integration
- Google Mobile Ads SDK (Android & iOS)
- Google User Messaging Platform (UMP) native SDK
- connectivity_plus or similar (wrapped inside connectivity_controller)

##### Elements
- Clear labels for each component (e.g., AdmobEasy façade, UMP Helper, BannerService)
– App → AdmobEasy → Helper/Service → Platform Channel → Native SDK
– Native SDK → Platform Channel → Dart callbacks → App
– Another for platform channels
– A third for native SDKs
- Annotations for key interactions (e.g., consent flow, connectivity check)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Flutter Application
    App["Flutter Application"]:::app

    %% Dart/Flutter Plugin Layer
    subgraph "Admob Easy Plugin (Dart Layer)"
        direction TB
        Facade["AdmobEasy Facade (Singleton)"]:::dart
        ConnectivityController["ConnectivityController"]:::dart
        AdmobHelper["AdmobHelper (SDK Init)"]:::dart
        UMPHelper["UMPHelper (Consent Flow)"]:::dart
        BannerService["BannerService"]:::dart
        RewardedService["RewardedService"]:::dart
        InterstitialService["InitAdService"]:::dart
        OpenAppService["OpenAppService"]:::dart
        NativeAdWidget["AdmobEasyNative Widget"]:::dart
        AdUnitConstants["AdUnit ID Constants"]:::dart
        Logger["AdmobEasyLogger"]:::dart
    end

    %% Platform Channel Boundary
    subgraph "Platform Channels"
        direction TB
        Channel["PlatformChannel"]:::channel
    end

    %% Native SDK Layer
    subgraph "Native SDKs"
        direction TB
        AndroidSDK["Android Mobile Ads SDK\n& UMP"]:::native
        iOSSDK["iOS Google Mobile Ads SDK\n& UMP"]:::native
    end

    %% Interactions
    App -->|"calls initialize() / create/load/show"| Facade
    Facade -->|uses| AdmobHelper
    Facade -->|uses| UMPHelper
    Facade -->|uses| ConnectivityController
    Facade -->|delegates to| BannerService
    Facade -->|delegates to| RewardedService
    Facade -->|delegates to| InterstitialService
    Facade -->|delegates to| OpenAppService
    Facade -->|exposes widget| NativeAdWidget
    Facade -->|logs via| Logger

    %% Services interactions
    BannerService -->|checks connectivity| ConnectivityController
    RewardedService -->|checks connectivity| ConnectivityController
    InterstitialService -->|checks connectivity| ConnectivityController
    OpenAppService -->|checks connectivity| ConnectivityController

    %% Constants
    BannerService -->|reads adUnits| AdUnitConstants
    RewardedService -->|reads adUnits| AdUnitConstants
    InterstitialService -->|reads adUnits| AdUnitConstants
    OpenAppService -->|reads adUnits| AdUnitConstants

    %% Consent and Init flows to native via channels
    AdmobHelper -->|init SDK| Channel
    UMPHelper -->|request consent| Channel

    %% Ad requests/responses
    BannerService -->|load/show ad| Channel
    RewardedService -->|load/show ad| Channel
    InterstitialService -->|load/show ad| Channel
    OpenAppService -->|load/show ad| Channel
    NativeAdWidget -->|create PlatformView| Channel

    Channel -->|invoke Android SDK methods| AndroidSDK
    Channel -->|invoke iOS SDK methods| iOSSDK

    AndroidSDK -->|callbacks/events| Channel
    iOSSDK -->|callbacks/events| Channel

    Channel -->|deliver callbacks| BannerService
    Channel -->|deliver callbacks| RewardedService
    Channel -->|deliver callbacks| InterstitialService
    Channel -->|deliver callbacks| OpenAppService
    Channel -->|deliver callbacks| NativeAdWidget

    Channel -->|deliver consent result| UMPHelper

    %% Callbacks to App
    BannerService -->|event callbacks| App
    RewardedService -->|event callbacks| App
    InterstitialService -->|event callbacks| App
    OpenAppService -->|event callbacks| App
    NativeAdWidget -->|render view| App

    %% Click Events
    click Facade "https://github.com/matifdeveloper/admob_easy/blob/master/lib/admob_easy.dart"
    click ConnectivityController "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/controllers/connectivity_controller.dart"
    click AdmobHelper "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/helper/admob_helper.dart"
    click UMPHelper "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/helper/admob_ump_helper.dart"
    click BannerService "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/services/banner_ad.dart"
    click RewardedService "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/services/rewarded_ad.dart"
    click InterstitialService "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/services/init_ad.dart"
    click OpenAppService "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/services/open_app_ad.dart"
    click NativeAdWidget "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/services/admob_easy_native.dart"
    click AdUnitConstants "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/sources.dart"
    click Logger "https://github.com/matifdeveloper/admob_easy/blob/master/lib/ads/utils/admob_easy_logger.dart"

    %% Styles
    classDef app fill:#f9f,stroke:#333,stroke-width:1px
    classDef dart fill:#bbf,stroke:#333,stroke-width:1px
    classDef channel fill:#ffb,stroke:#333,stroke-width:1px
    classDef native fill:#bfb,stroke:#333,stroke-width:1px
```
