# juspay/hyperswitch-web architecture

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

- Interactive diagram: https://gitdiagram.com/juspay/hyperswitch-web
- Repository: https://github.com/juspay/hyperswitch-web

## Overview

##### Project Type & Purpose
- Project Type: This is an open-source web unified checkout SDK that enables businesses to accept payments from multiple global payment providers. It’s built using a mix of Rescript (for core SDK components located in the “src” folder) and React (as seen in the “Hyperswitch-React-Demo-App” demo). It integrates with various external payment providers (e.g., Braintree, ApplePay, GooglePay) and incorporates custom logging and error boundary components.
- Purpose: The project provides a highly customizable, unified payment experience that supports a wide range of payment methods with deep theme customization, extensive integration testing (using Cypress), and robust logging for debugging and monitoring.

##### Analyzing the File Structure
- Top-Level Separation:
– “src”: Contains the core SDK components, utility functions, payment method implementations (Components, Payments, Styles/Themes, LocaleStrings, etc.), and logging/error capturing (hyper-log-catcher, hyper-loader).
– “Hyperswitch-React-Demo-App”: A demo application that illustrates the SDK integration in a React environment. It has its own server.js, build configuration (webpack files), public assets, and a Makefile.
– “aws”: Deployment and cleanup scripts for deploying to AWS.
– “cypress-tests”: Contains end-to-end tests (written in TypeScript/JavaScript) to simulate different payment workflows.
– Root-level configuration files (Dockerfile, .env, Husky hooks, GitHub workflows) show that CI/CD, Docker-based local development, and code quality/language tooling are integral to the project.
- Architectural Hints:
– The use of “src/Payments” with many payment method sub-components implies modular design (each payment method is encapsulated).
– The organized “Components” folder in “src” and “Hooks” indicate a front-end component-based architecture using both React and Rescript.
– The Dockerfiles and AWS scripts indicate readiness for containerized deployment and cloud hosting.

##### Insights from the README
- The README details integration steps, required environment variables, and emphasizes support for multiple payment methods.
- It instructs on setting up both the demo app and a local backend server. There is explicit mention of customizing themes, logging integration (using the Beacon API), and ensuring compatibility with external services.
- It highlights architectural concerns like modularity (e.g., separation of concerns between the SDK, the server backend, and the demo front-end).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A["React Demo App"]:::client
    end

    %% Payment SDK Layer
    subgraph "Payment SDK Layer"
        B["Payment SDK Core"]:::sdk
        C["Payment Methods Modules"]:::sdk
        D["UI Components"]:::sdk
        E["Hooks"]:::sdk
        F["Hyper Log Catcher"]:::logging
        G["Hyper Loader"]:::logging
    end

    %% Backend Server Layer
    subgraph "Backend Server Layer"
        H["Backend Server"]:::server
    end

    %% External Services
    subgraph "External Services"
        I["External Payment Providers"]:::external
        J["External Logging & Monitoring"]:::external
    end

    %% DevOps & Testing
    subgraph "DevOps & Testing"
        K["Cypress Tests"]:::testing
        L["CI/CD Pipelines"]:::ci
        M["AWS Deployment Scripts"]:::deployment
        N["Root Dockerfile"]:::deployment
        O["Demo Dockerfile"]:::deployment
    end

    %% Data Flow Arrows
    A -->|"uses"| B
    B -->|"communicates"| H
    H -->|"invokes"| I

    %% Logging flows from various layers
    A ---|"logs"| J
    B ---|"logs"| J
    H ---|"logs"| J

    %% Internal SDK Module Flow
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G

    %% DevOps interactions
    L -->|"runs"| K
    L -.->|"deploysTo"| M
    M -.-> H
    N -.-> H
    O -.-> A
    L -.-> H

    %% Style Definitions
    classDef client fill:#AED581,stroke:#558B2F,stroke-width:2px;
    classDef sdk fill:#81D4FA,stroke:#0277BD,stroke-width:2px;
    classDef server fill:#FFCC80,stroke:#FF9800,stroke-width:2px;
    classDef external fill:#F48FB1,stroke:#C2185B,stroke-width:2px;
    classDef logging fill:#CE93D8,stroke:#8E24AA,stroke-width:2px;
    classDef testing fill:#FFF176,stroke:#FBC02D,stroke-width:2px;
    classDef ci fill:#80CBC4,stroke:#009688,stroke-width:2px;
    classDef deployment fill:#B0BEC5,stroke:#546E7A,stroke-width:2px;

    %% Click Events
    click A "https://github.com/juspay/hyperswitch-web/tree/main/Hyperswitch-React-Demo-App/"
    click B "https://github.com/juspay/hyperswitch-web/tree/main/src/"
    click C "https://github.com/juspay/hyperswitch-web/tree/main/src/Payments/"
    click D "https://github.com/juspay/hyperswitch-web/tree/main/src/Components/"
    click E "https://github.com/juspay/hyperswitch-web/tree/main/src/Hooks/"
    click F "https://github.com/juspay/hyperswitch-web/tree/main/src/hyper-log-catcher/"
    click G "https://github.com/juspay/hyperswitch-web/tree/main/src/hyper-loader/"
    click H "https://github.com/juspay/hyperswitch-web/blob/main/Hyperswitch-React-Demo-App/server.js"
    click K "https://github.com/juspay/hyperswitch-web/tree/main/cypress-tests/"
    click L "https://github.com/juspay/hyperswitch-web/tree/main/.github/workflows/"
    click M "https://github.com/juspay/hyperswitch-web/tree/main/aws/"
    click N "https://github.com/juspay/hyperswitch-web/tree/main/Dockerfile"
    click O "https://github.com/juspay/hyperswitch-web/tree/main/Hyperswitch-React-Demo-App/Dockerfile"
```
