# settle-club/settle-android-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/settle-club/settle-android-sdk
- Repository: https://github.com/settle-club/settle-android-sdk

## Overview

- The "settle-payment" module, which contains the core SDK functionality, including payment data handling, UI components for payment dialogs, permission management, and utility functions.
- The "app" module, which appears to be a sample or demo Android application showing how to use the SDK (e.g., with MainActivity implementing SettlePaymentCallback and demonstrating usage).

##### Main Components
- SDK Library ("settle-payment" module):
– Payment UI: Contains components like the payment dialog (fragment_payment_dialog.xml) and logic in SettlePayment.kt.
– Payment Data & Utilities: Classes for data handling (PaymentSuccessResponse, PaymentOptions, etc.) and helper utilities such as URLUtils.
– Permissions: A dedicated submodule handling permission logic (PermissionHandlerFragment, PermissionType).
- Demo/Consumer App ("app" module):
– Sample Activity (MainActivity) showing how to integrate the SDK.
– Android resources for layouts, strings, and themes that demonstrate the SDK usage.
- Infrastructure Components:
– Build and configuration systems (Gradle configuration files, proguard rules).
– Testing components (unit tests and instrumented tests under src/test and src/androidTest folders).
– Android Manifest and resource files supporting UI and application behavior.

##### Relationships and Interactions
– The client app (represented by the "app" module) calling the SettlePayment API (e.g., SettlePayment.open()).
– Callback mechanisms whereby the client implements SettlePaymentCallback to handle onSuccess and onError events.
- Internally, the SDK handles the steps for payment:
– Creating an order (interaction with external payment APIs via the provided redirectUrl).
– Launching the payment UI.
– Processing and returning the transaction response.
- External integration points:
– The Create Order API (which isn’t implemented in code, but referenced in the README) and Payment Webhook verification for backend servers.

##### Architectural Patterns & Design Principles
- Modular design: Separate modules for the core SDK and the demo application.
- Callback/Observer pattern: Use of SettlePaymentCallback to handle success and error events.
- Layer separation: Clear delineation between UI (payment dialog), business logic (order creation and transaction handling), and utility/permissions handling.

##### Relevant Technologies, Frameworks, and Tools
- Android (native Android app development using Kotlin).
- Gradle (for build configuration, seen in build.gradle.kts files and settings.gradle.kts).
- Testing frameworks (JUnit for unit tests and Android Instrumentation testing).
- Proguard configuration for code obfuscation indicated via proguard-rules.pro files.
- Android resources (layouts, drawables, XML resources) controlling UI design.

##### Detail Orientation
- Adding notes to explain that, in the demo, SettlePaymentCallback is extended by activities/fragments to handle payment event callbacks.
- Both the Android-specific components (like AndroidManifest, resources) and module-specific build/configuration elements.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Demo App Module
    subgraph "Demo App Module"
        MA("MainActivity"):::demo
    end
    
    %% Settle Payment SDK
    subgraph "Settle Payment SDK"
        %% Payment UI Submodule
        subgraph "Payment UI"
            SP("SettlePayment"):::ui
            PD("Payment Dialog"):::ui
        end
        
        %% Payment Data & Utilities Submodule
        subgraph "Payment Data & Utilities"
            PS("PaymentSuccessResponse"):::utilities
            PO("SettlePaymentOptions"):::utilities
            U("URLUtils"):::utilities
        end
        
        %% Permissions Management Submodule
        subgraph "Permissions Management"
            PH("PermissionHandlerFragment"):::permissions
            PT("PermissionType"):::permissions
        end
    end

    %% External Payment Order API
    EX("External Payment Order API"):::external

    %% Interactions
    MA -->|"callsSettlePayment.open()"| SP
    SP -->|"LaunchPaymentUI"| PD
    PD -->|"Callback:onSuccess/onError"| MA

    %% SDK internal interactions - Data & Utilities
    PD -->|"ProcessResponse"| PS
    PD -->|"ReadOptions"| PO
    PD -->|"UtilizeURL"| U

    %% SDK internal interactions - Permissions
    SP -->|"CheckPermissions"| PH
    PH -->|"Uses"| PT

    %% External API integrations
    PD -->|"CreateOrder"| EX
    EX -->|"VerifyWebhook"| PD

    %% Click events for SDK Library - Payment UI
    click SP "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/java/com/settle/sdk/payment/ui/SettlePayment.kt"
    click PD "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/res/layout/fragment_payment_dialog.xml"

    %% Click events for SDK Library - Payment Data & Utilities
    click PS "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/java/com/settle/sdk/payment/data/PaymentSuccessResponse.kt"
    click PO "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/java/com/settle/sdk/payment/ui/SettlePaymentOptions.kt"
    click U "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/java/com/settle/sdk/payment/utils/URLUtils.kt"

    %% Click events for SDK Library - Permissions Management
    click PH "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/java/com/settle/sdk/payment/permissions/PermissionHandlerFragment.kt"
    click PT "https://github.com/settle-club/settle-android-sdk/blob/main/settle-payment/src/main/java/com/settle/sdk/payment/permissions/PermissionType.kt"

    %% Click events for Demo/Consumer App
    click MA "https://github.com/settle-club/settle-android-sdk/blob/main/app/src/main/java/com/settle/android/sdk/MainActivity.kt"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef utilities fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef permissions fill:#F5B7B1,stroke:#EC7063,stroke-width:2px;
    classDef demo fill:#FCF3CF,stroke:#F7DC6F,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#AF7AC5,stroke-width:2px;
```
