# x3mads/androiddemoapp architecture

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

- Interactive diagram: https://gitdiagram.com/x3mads/androiddemoapp
- Repository: https://github.com/x3mads/androiddemoapp

## Overview

##### Main Components
- Android Application Framework: Represent the overall Android app where the integration takes place.
- User Interface Layer:
- DemoActivity – the primary activity showing the ad implementations.
- activity_demo.xml – the layout that defines the look and feel.
- Business Logic Layer:
- DemoViewModel – handles logic for the UI, supporting the MVVM (Model-View-ViewModel) pattern.
- Advertisement Helpers:
- BannerHelper, InterstitialHelper, RewardedHelper – these classes encapsulate different ad types provided by the X3M library.
- External Dependencies:
- X3M Library – illustrate an external connection that handles retrieving and managing ad content.
- Build and Test Infrastructure:

##### Relationships and Interactions
- The UI component (DemoActivity) interacts with the DemoViewModel, which in turn uses the ad helper classes to request and control ads.
- The DemoViewModel manages state and triggers methods on the BannerHelper, InterstitialHelper, and RewardedHelper to load and display ads.
- From the ad helper classes, illustrate an external dependency or API call to the X3M Library’s backend service (or server API). This represents the bridge between your application’s code and the external ad service.
- That the Android framework itself (e.g., lifecycle management, XML layouts, manifest configurations) underpins the entire app.

##### Architectural Patterns & Design Principles
- The project follows a modular approach with clear separation between UI, business logic (ViewModel), and utility classes (ad helpers).
- Although simple, the MVVM pattern can be highlighted to show the decoupling of UI from business logic.
- The overall design emphasizes integration points (i.e., the X3M library) and demonstrates how the app communicates with external advertisement services.

##### Relevant Technologies and Frameworks
- Android SDK (including Activities, ViewModels, and resource management)
- Kotlin (as indicated by the use of .kt files and Gradle Kotlin build scripts)
- The X3M Ads SDK (directly mentioned in the README and integrated via helper classes)
- Gradle for building and dependency management

- Inside this environment, split out the following:
- A “UI Layer” containing DemoActivity and its associated layout.
- A “Logic Layer” with DemoViewModel.
- An “Ad Services Layer” with the BannerHelper, InterstitialHelper, and RewardedHelper.
- “Ad Services Layer” to an external system representing the X3M Ads API endpoint.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Application Environment"
        AAF["Android Application Framework"]:::framework
        subgraph "UI Layer"
            DA["DemoActivity (UI Layer)"]:::ui
            ADemoXML["activity_demo.xml (UI Layout)"]:::ui
        end
        subgraph "Business Logic Layer"
            DVM["DemoViewModel (Business Logic)"]:::logic
        end
        subgraph "Ad Services Layer"
            BH["BannerHelper (Ad Integration)"]:::ad
            IH["InterstitialHelper (Ad Integration)"]:::ad
            RH["RewardedHelper (Ad Integration)"]:::ad
        end
        ES["X3M Library (External Service)"]:::external
        BTI["Build & Test Infrastructure"]:::infra
    end

    %% Connections between layers
    DA -->|"sendsEvents"| DVM
    DA -->|"usesLayout"| ADemoXML
    DVM -->|"loadsBanner"| BH
    DVM -->|"loadsInterstitial"| IH
    DVM -->|"loadsRewarded"| RH
    BH -->|"callsAPI"| ES
    IH -->|"callsAPI"| ES
    RH -->|"callsAPI"| ES
    AAF -->|"builds"| DA
    AAF -->|"builds"| DVM
    AAF -->|"builds"| BH
    AAF -->|"builds"| IH
    AAF -->|"builds"| RH
    AAF -->|"includes"| BTI

    %% Click Events
    click AAF "https://github.com/x3mads/androiddemoapp/blob/main/build.gradle.kts"
    click DA "https://github.com/x3mads/androiddemoapp/blob/main/app/src/main/java/com/x3mads/demo/DemoActivity.kt"
    click ADemoXML "https://github.com/x3mads/androiddemoapp/blob/main/app/src/main/res/layout/activity_demo.xml"
    click DVM "https://github.com/x3mads/androiddemoapp/blob/main/app/src/main/java/com/x3mads/demo/DemoViewModel.kt"
    click BH "https://github.com/x3mads/androiddemoapp/blob/main/app/src/main/java/com/x3mads/demo/ads/BannerHelper.kt"
    click IH "https://github.com/x3mads/androiddemoapp/blob/main/app/src/main/java/com/x3mads/demo/ads/InterstitialHelper.kt"
    click RH "https://github.com/x3mads/androiddemoapp/blob/main/app/src/main/java/com/x3mads/demo/ads/RewardedHelper.kt"
    click BTI "https://github.com/x3mads/androiddemoapp/blob/main/app/build.gradle.kts"

    %% Styles
    classDef framework fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef logic fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef ad fill:#ffe5cc,stroke:#333,stroke-width:2px;
    classDef external fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef infra fill:#e0e0e0,stroke:#333,stroke-width:2px;
```
