# airwallex/airwallex-payment-demo architecture

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

- Interactive diagram: https://gitdiagram.com/airwallex/airwallex-payment-demo
- Repository: https://github.com/airwallex/airwallex-payment-demo

## Overview

##### Project type and purpose
- This is not a single production service but a monorepo of “demo integrations” for the Airwallex Payment Element.
- Its purpose is to show merchants how to integrate the Airwallex JS SDK / REST API through various web frameworks (static HTML/CDN, React-TS SPA) and API examples (Node).

##### File structure
- Top-level:
- README.md, commitlint.config.js, version.sh, GitHub config (.github, .gitignore)
- docs/ – markdown docs for each payment method
- integrations/ – current, supported integration samples:
– cdn/ (static HTML + sandbox config + package.json)
– node/ (TypeScript Node backend, Express-style controllers in src/controller, config, app.ts)
– react-ts/ (Create-React-App TypeScript SPA under src/, components folder, util.ts, public/)
- integrations@deprecated/ – older framework samples (Angular, Vue, React w/o TS, ReactNative)
- payment-method-logos/ and special-cases/ – static assets
- Key patterns:
- A monorepo with multiple independent sub-projects
- Each integration has its own package.json, config (tsconfig, .eslintrc) and runs independently
- The Node sample is the only true “backend” that actually calls Airwallex REST API

##### Insights from the README
- Focus is on demonstrating the “Airwallex payment element” via several front-end frameworks
- Describes “Creating a Payment Intent” – merchant must insert secret via API (Node sample)
- Mentions sandboxes for live testing of CDN and React-TS samples

##### Details to capture
- The monorepo structure hosting multiple independent integration projects
- The role of the Node sample as the server-side component for secrets
- The client-side use of the Airwallex JS SDK
- The end-to-end checkout flow: user → front-end → back-end (optional) → Airwallex
- CI/CD or versioning (GitHub Actions, version.sh) as an optional build pipeline component

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Root and shared docs/assets
    subgraph "GitHub Monorepo"
        direction TB
        README["README.md"]:::repo
        Commitlint["commitlint.config.js"]:::repo
        Version["version.sh"]:::repo
        GitHubCfg[".github/"]:::ci
        Docs["docs/"]:::docs
        Assets["payment-method-logos/ & special-cases/"]:::asset

        subgraph "Integrations"
            direction TB

            subgraph "Static HTML/CDN App"
                direction TB
                CDNIndex["index.html"]:::frontend
                CDNPackage["package.json"]:::frontend
                CDNSandbox["sandbox.config.json"]:::frontend
                CDNStyle["style.css"]:::frontend
            end

            subgraph "React-TS SPA"
                direction TB
                ReactSrc["src/"]:::frontend
                ReactPublic["public/"]:::frontend
                ReactPkg["package.json"]:::frontend
                ReactTSConfig["tsconfig.json"]:::frontend
            end

            subgraph "Node Backend (Express API)"
                direction TB
                NodeApp["app.ts"]:::backend
                NodeIntent["controller/intent.ts"]:::backend
                NodeConfig["config.ts"]:::backend
                NodePkg["package.json"]:::backend
                NodeEnv[".env_copy"]:::backend
            end
        end
    end

    %% External entities
    Browser["Merchant Browser"]:::external
    AirwallexSDK["Airwallex JS SDK"]:::external
    AirwallexAPI["Airwallex REST API"]:::external

    %% CI/CD Flow
    GitHubCfg -->|triggers| Version

    %% User interactions and flows
    Browser -->|loads via CDN| CDNIndex
    Browser -->|loads SPA| ReactPublic

    CDNIndex -->|"<script> loads"| AirwallexSDK
    ReactPublic -->|"npm import"| AirwallexSDK

    %% Payment Intent creation paths
    ReactPublic -->|"/create-payment-intent"| NodeApp
    CDNIndex -->|"/create-payment-intent"| NodeApp

    NodeApp -->|HTTPS call| AirwallexAPI
    AirwallexAPI -->|client_secret| NodeApp
    NodeApp -->|return client_secret| ReactPublic
    NodeApp -->|return client_secret| CDNIndex

    AirwallexSDK -->|renders payment element & confirms| AirwallexAPI

    %% Click Events
    click README "https://github.com/airwallex/airwallex-payment-demo/blob/master/README.md"
    click Commitlint "https://github.com/airwallex/airwallex-payment-demo/blob/master/commitlint.config.js"
    click Version "https://github.com/airwallex/airwallex-payment-demo/blob/master/version.sh"
    click GitHubCfg "https://github.com/airwallex/airwallex-payment-demo/tree/master/.github/"
    click Docs "https://github.com/airwallex/airwallex-payment-demo/tree/master/docs/"
    click CDNIndex "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/cdn/index.html"
    click CDNPackage "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/cdn/package.json"
    click CDNSandbox "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/cdn/sandbox.config.json"
    click CDNStyle "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/cdn/style.css"
    click ReactSrc "https://github.com/airwallex/airwallex-payment-demo/tree/master/integrations/react-ts/src/"
    click ReactPublic "https://github.com/airwallex/airwallex-payment-demo/tree/master/integrations/react-ts/public/"
    click ReactPkg "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/react-ts/package.json"
    click ReactTSConfig "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/react-ts/tsconfig.json"
    click NodeApp "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/node/src/app.ts"
    click NodeIntent "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/node/src/controller/intent.ts"
    click NodeConfig "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/node/src/config.ts"
    click NodePkg "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/node/package.json"
    click NodeEnv "https://github.com/airwallex/airwallex-payment-demo/blob/master/integrations/node/.env_copy"

    %% Styles
    classDef repo fill:#f9f,stroke:#333,stroke-width:1px
    classDef ci fill:#fea,stroke:#333,stroke-width:1px
    classDef docs fill:#ccf,stroke:#333,stroke-width:1px
    classDef asset fill:#cfc,stroke:#333,stroke-width:1px
    classDef frontend fill:#bbf,stroke:#333,stroke-width:1px
    classDef backend fill:#fbb,stroke:#333,stroke-width:1px
    classDef external fill:#eee,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
