# adityaambre/payment-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/adityaambre/payment-sdk
- Repository: https://github.com/adityaambre/payment-sdk

## Overview

##### Project type and purpose
- This is a Java Payment SDK library (jar) intended to be embedded in client applications to provide a unified payment interface supporting multiple payment modes (debit/credit card, net banking).
- The README confirms it’s not a standalone app but a reusable SDK: you include PaymentSDK.jar, configure your IDE, then call its API (PaymentSDK.getInstance().init(), initialise(), pay(), onResult()).

##### File structure
- Top-level artifacts:
- jar/PaymentSDK.jar    – compiled library
- src/sdk               – Java packages for the SDK
- src/sdk/client        – client-facing API: base classes, model classes (PaymentMode, CardRequirement, NetBankingRequirement), example (SdkConfiguration)
- src/sdk/core          – core engine: base types, constants, delegate, service logic, utilities, validators
- Architectural hints:
- A singleton entry point (PaymentSDK.getInstance())
- A delegate pattern (PaymentDelegate) that orchestrates flow
- A service class (PaymentService) that executes business logic
- Validators and utilities to enforce rules and transform data
- Model/requirement objects to decouple mode-specific parameters

##### Key points from the README
- Integration steps outline the high-level “call flow”:
1. import SDK packages
2. set up PaymentMode + PaymentRequirement
3. init SDK → get PaymentDelegate
4. delegate.initialise(...).pay(amount).onResult(callback)
- Example client code (SdkConfiguration) shows typical usage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    ClientApp["Client Application"]:::external

    subgraph "PaymentSDK Library"
        direction TB

        subgraph "Client API"
            direction TB
            PS["PaymentSDK\n(Singleton)"]:::clientApi
            PR["PaymentRequirement"]:::clientApi
            TR["TransactionResult\n(interface)"]:::interface
            SC["SdkConfiguration"]:::clientApi
        end

        subgraph "Models"
            direction TB
            CR["CardRequirement"]:::model
            NR["NetBankingRequirement"]:::model
            PM["PaymentMode"]:::model
        end

        subgraph "Core Engine"
            direction TB
            PD["PaymentDelegate"]:::internal
            PSrv["PaymentService"]:::internal
            VAL["Validator"]:::internal
            UT["Utility"]:::internal
            CST["Constant"]:::internal
            PB["Payment\n(base type)"]:::internal
        end
    end

    EG["External Payment Gateway"]:::external

    ClientApp -->|".getInstance().init()"| PS
    PS -->|"returns delegate"| PD
    ClientApp -->|"delegate.initialise(mode, req)"| PD
    PD -->|"validate()"| VAL
    VAL --> PD
    PD -->|"invoke service"| PSrv
    PSrv -->|"format()"| UT
    PSrv -->|"call API"| EG
    EG -->|"response"| PSrv
    PSrv -->|"map to TransactionResult"| TR
    TR -->|"callback"| ClientApp

    click PS "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/PaymentSDK.java"
    click PR "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/client/base/PaymentRequirement.java"
    click TR "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/client/base/TransactionResult.java"
    click SC "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/client/example/SdkConfiguration.java"
    click CR "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/client/model/CardRequirement.java"
    click NR "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/client/model/NetBankingRequirement.java"
    click PM "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/client/model/PaymentMode.java"
    click PD "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/core/delegate/PaymentDelegate.java"
    click PSrv "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/core/service/PaymentService.java"
    click VAL "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/core/validator/Validator.java"
    click UT "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/core/utility/Utility.java"
    click CST "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/core/constant/Constant.java"
    click PB "https://github.com/adityaambre/payment-sdk/blob/main/src/sdk/core/base/Payment.java"

    class PS,PR,SC clientApi
    class PD,PSrv,VAL,UT,CST,PB internal
    class CR,NR,PM model
    class ClientApp,EG external
    class TR interface

    classDef clientApi fill:#BBDEFB,stroke:#1976D2,stroke-width:1px
    classDef internal fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
    classDef model fill:#FFE0B2,stroke:#F57C00,stroke-width:1px
    classDef external fill:#CFD8DC,stroke:#455A64,stroke-width:1px
    classDef interface stroke-dasharray:5 5,fill:#FFF3E0,stroke:#FB8C00,stroke-width:1px
```
