# juspay/hyperswitch-cdk architecture

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

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

## Overview

##### Core Components
- Infrastructural Deployment Layer: Represented by the AWS CDK scripts (cdk.json, awsconfig.ts, bin/hs-cdk.ts) and configuration files under the “lib/aws” directory. Note the specialized stacks for card vault, auto scaling groups, networking, RDS, jump servers, etc.
- Service Modules: Highlight the App Server (described in the README as a key Rust-based backend), Scheduler Services, Admin Control Center, and Demo App with SDK integration. Even if their code isn’t completely visible in this repository, the README clearly defines their roles.
- Support / Auxiliary Components: Include specialized components such as Card Vault (with its dedicated stacks and scripts), Image Builder (with its own deployment scripts and configuration in the “single-click”, “install-locker.sh”, “deploy_imagebuilder.sh”, etc.), and Jump Servers (for secure access).
- External Dependencies & Infrastructure Scripts: Scripts in the “bash” folder, installation and upgrade scripts, and integration utilities (e.g., in “dependencies/code_builder”) show how setup and build are automated.

##### Out Communication & Relationships
- Directional flows showing that installation scripts (from the “bash” and “bin” directories) trigger the deployment processes.
- That some components, like the Card Vault, require a multi-step jump server connection (making it a layered/security-focused component with an internal and an external jump connection).

##### Architectural Patterns & Design Choices
- Module Isolation: Each major function (e.g., card vault, image builder) is isolated into its own module/stack as seen in separate directories and scripts.
- Cross-Cloud Flexibility: Although AWS is the primary target, note references to Azure and GCP stacks in the “lib/azure” and “lib/gcp” directories.
- Extensibility & Security: A layered security design is implied (e.g., jump servers accessing card vault securely), so clearly denote secure channels and control boundaries.

- App Server (with a note on its Rust implementation).
- Scheduler Services.
- Admin Control Center.
- Card Vault services with internal and external jump server layers.
- Image Builder for proxies (Squid and Envoy) as detailed in the components folder.
- Build Automation (code builder) and dependency management.
- Detailed sub-components within the AWS layer (e.g., Auto Scaling Groups, EKS, RDS, Lambda functions, networking modules) as represented in the “lib/aws” subdirectories.
- Clear directional flows showing deployment triggers (e.g., from install.sh, deploy_imagebuilder.sh) and data flow between modules (e.g., API calls from the Demo App to the App Server, secure jumps from external to internal jump servers for Card Vault access).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Automation Tools"
        I1["Installation Scripts"]:::automation
        I2["Code Builder & Dependencies"]:::automation
    end

    subgraph "Infrastructure as Code"
        A1["cdk.json"]:::utility
        A2["awsconfig.ts"]:::utility
        A3["bin/hs-cdk.ts"]:::utility
        A4["lib/aws (CDK Stacks & Config)"]:::utility
        I3["AWS CDK Infrastructure"]:::utility
        D["AWS CDK Deployment Controller"]:::infrastructure
        AC["Component Templates"]:::utility
        LC["AWS Config Templates"]:::utility
        A1 --> A2 --> A3 --> A4
        A4 --> I3
        I3 --> D
        I3 --> AC
        I3 --> LC
    end

    subgraph "Core Application Services"
        S1["App Server (Rust)"]:::service
        S2["Scheduler Services"]:::service
        S3["Admin Control Center"]:::service
        S4["Demo App (SDK Integration)"]:::service
    end

    subgraph "Supporting Services"
        SS1["Card Vault Stack"]:::service
        SS2["Image Builder Stack"]:::service
        SS3["Jump Servers"]:::service
        SS41["Auto Scaling Groups"]:::utility
        SS42["Kubernetes/EKS"]:::utility
        SS43["RDS & Networking"]:::utility
        SS44["Lambda Functions"]:::utility
        SS45["Key Manager"]:::utility
    end

    subgraph "Cross Cloud Modules"
        CC1["Azure Stack"]:::crossCloud
        CC2["GCP Stack"]:::crossCloud
    end

    %% Deployment flow connections
    I1 --> D
    I2 --> D
    D --> S1
    D --> S2
    D --> S3
    D --> S4
    D --> SS1
    D --> SS2
    D --> SS3
    D --> SS41
    D --> SS42
    D --> SS43
    D --> SS44
    D --> SS45
    D --> CC1
    D --> CC2

    %% Card Vault secure access via Jump Servers
    SS3 --> SS1

    %% Click Events
    click A1 "https://github.com/juspay/hyperswitch-cdk/blob/main/cdk.json"
    click A2 "https://github.com/juspay/hyperswitch-cdk/blob/main/awsconfig.ts"
    click A3 "https://github.com/juspay/hyperswitch-cdk/blob/main/bin/hs-cdk.ts"
    click A4 "https://github.com/juspay/hyperswitch-cdk/tree/main/lib/aws/"
    click SS1 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/aws/card-vault/stack.ts"
    click SS2 "https://github.com/juspay/hyperswitch-cdk/blob/main/deploy_imagebuilder.sh"
    click SS3 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/aws/jumps.ts"
    click CC1 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/azure/stack.ts"
    click CC2 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/gcp/stack.ts"
    click I1 "https://github.com/juspay/hyperswitch-cdk/tree/main/bash/"
    click I2 "https://github.com/juspay/hyperswitch-cdk/tree/main/dependencies/code_builder/"
    click SS41 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/aws/auto_scaling_groups.ts"
    click SS42 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/aws/eks.ts"
    click SS43 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/aws/rds.ts"
    click SS44 "https://github.com/juspay/hyperswitch-cdk/tree/main/lib/aws/lambda/"
    click SS45 "https://github.com/juspay/hyperswitch-cdk/blob/main/lib/aws/keymanager/stack.ts"
    click AC "https://github.com/juspay/hyperswitch-cdk/tree/main/components/"
    click LC "https://github.com/juspay/hyperswitch-cdk/tree/main/lib/aws/config/"

    %% Styles
    classDef infrastructure fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef service fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef utility fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef automation fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef crossCloud fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
```
