# transbankdevelopers/transbank-sdk-nodejs architecture

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

- Interactive diagram: https://gitdiagram.com/transbankdevelopers/transbank-sdk-nodejs
- Repository: https://github.com/transbankdevelopers/transbank-sdk-nodejs

## Overview

##### Project type and purpose
- This is an SDK/library (not an end-user app) written in Node.js/TypeScript that wraps Transbank’s payment APIs (Webpay, Patpass) into a consumable module.
- Its purpose is to expose a set of clients and request builders that your own Node.js services can call to integrate with Transbank’s external REST endpoints.

##### File structure
- Top-level files:
- package.json, tsconfig.json, build & test scripts → build/test pipeline
- lib/ → the compiled TypeScript output placed under src-coded folders
- tests/ → Jest tests and mock data
- Under lib/transbank:
- common/ → shared abstractions (API constants, base transaction, request base, error handling, validation)
- webpay/ → three products (oneclick, transaccion_completa, webpay_plus), each with:
– common (environment, transaction/installments detail)
– transaction models
– requests (start, commit, refund, status, etc.)
- patpass/ → transaction models & request builders for Patpass Recurring
- Config files: .github/workflows/*.yml → CI pipelines, jest.config.js → test runner, sonar-project.properties → code analysis

##### README for additional insights
- Clarifies supported environments (integration, production)
- Lists installation, build & test commands
- Points to external documentation (Transbank developer portal)

##### Elements
- From Client App → SDK public methods
- SDK internal flow: Config → Common → Product Module → HTTP Transport → Transbank API → back

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Application
    ClientApp["Client Application"]:::client

    %% SDK Module Group
    subgraph "SDK Module" 
        direction TB
        SDKEntry["SDK Entry Point"]:::sdk

        subgraph "Configuration / Environment"
            direction TB
            Options["Default Options & Overrides"]:::sdk
            IntegrationKeys["Integration API Keys"]:::sdk
            CommerceCodes["Integration Commerce Codes"]:::sdk
            WebpayEnv["Webpay Environments"]:::sdk
            PatpassEnv["Patpass Environments"]:::sdk
        end

        subgraph "Common Abstractions"
            direction TB
            APIConstants["API Constants"]:::sdk
            BaseTransaction["Base Transaction Model"]:::sdk
            RequestBase["Request Base Class"]:::sdk
            TransbankError["Centralized Error Handling"]:::sdk
            ValidationUtil["Validation Utilities"]:::sdk
        end

        HTTP["HTTP Transport Layer"]:::sdk

        subgraph "Product Modules"
            direction TB
            subgraph "Webpay"
                direction TB
                WC1["Oneclick"]:::sdk
                WTC["Transaccion Completa"]:::sdk
                WP["Webpay Plus"]:::sdk
            end
            subgraph "Patpass"
                direction TB
                PP["Patpass Recurring"]:::sdk
            end
        end
    end

    %% External Transbank API
    TransbankAPI["Transbank API"]:::external

    %% Build & Test Pipeline
    subgraph "Build & Test Pipeline"
        direction TB
        TSConfig["tsconfig.json"]:::pipeline
        JestConfig["jest.config.js"]:::pipeline
        CI["GitHub Actions"]:::pipeline
        Sonar["sonar-project.properties"]:::pipeline
    end

    %% Connections
    ClientApp -->|"calls SDK methods"| SDKEntry
    SDKEntry --> Options
    SDKEntry --> IntegrationKeys
    SDKEntry --> CommerceCodes
    SDKEntry --> WebpayEnv
    SDKEntry --> PatpassEnv

    Options --> APIConstants
    IntegrationKeys --> APIConstants
    CommerceCodes --> APIConstants
    WebpayEnv --> APIConstants
    PatpassEnv --> APIConstants

    APIConstants --> BaseTransaction
    BaseTransaction --> RequestBase
    RequestBase --> TransbankError
    TransbankError --> ValidationUtil
    ValidationUtil --> HTTP

    HTTP --> WC1
    HTTP --> WTC
    HTTP --> WP
    HTTP --> PP

    WC1 --> HTTP
    WTC --> HTTP
    WP --> HTTP
    PP --> HTTP

    HTTP -->|"HTTPS REST JSON"| TransbankAPI
    TransbankAPI -->|"JSON Response"| HTTP

    %% Pipeline flow
    SDKEntry --> TSConfig
    SDKEntry --> JestConfig
    SDKEntry --> CI
    SDKEntry --> Sonar

    %% Click Events
    click SDKEntry "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/index.ts"
    click Options "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/options.ts"
    click IntegrationKeys "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/integration_api_keys.ts"
    click CommerceCodes "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/integration_commerce_codes.ts"
    click WebpayEnv "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/webpay/common/environment.ts"
    click PatpassEnv "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/patpass/common/environment.ts"
    click APIConstants "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/api_constants.ts"
    click BaseTransaction "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/base_transaction.ts"
    click RequestBase "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/request_base.ts"
    click TransbankError "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/transbank_error.ts"
    click ValidationUtil "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/validation_util.ts"
    click HTTP "https://github.com/transbankdevelopers/transbank-sdk-nodejs/blob/master/lib/transbank/common/request_service.ts"
    click WC1 "https://github.com/transbankdevelopers/transbank-sdk-nodejs/tree/master/lib/transbank/webpay/oneclick"
    click WTC "https://github.com/transbankdevelopers/transbank-sdk-nodejs/tree/master/lib/transbank/webpay/transaccion_completa"
    click WP "https://github.com/transbankdevelopers/transbank-sdk-nodejs/tree/master/lib/transbank/webpay/webpay_plus"
    click PP "https://github.com/transbankdevelopers/transbank-sdk-nodejs/tree/master/lib/transbank/patpass"
    
    %% Styles
    classDef client fill:#b3ffb3,stroke:#333,stroke-width:1px
    classDef sdk fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef external fill:#ffd1a9,stroke:#333,stroke-width:1px
    classDef pipeline fill:#e8e8e8,stroke:#333,stroke-width:1px
```
