# governib/paymentib architecture

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

- Interactive diagram: https://gitdiagram.com/governib/paymentib
- Repository: https://github.com/governib/paymentib

## Overview

##### Project type and purpose
- From the file tree and README, we see that “paymentib” is not a standalone app but a horizontal software component (a library or SDK) that any application can embed to handle electronic or in-person payments.
- Its primary purpose is to provide a unified API and workflow to perform payments against different platforms, starting with the ATIB (Agència Tributària de les Illes Balears) payment gateway.

##### File structure
- Top-level files:
- .gitignore, LICENSE, README.md
- No “src/”, “lib/” or “examples/” folders are present in the root, but the README points to a `doc/` folder in the `paymentib-1.0` branch.
- We assume the real code resides in a `src/` or similar directory alongside:
– Core payment engine
– Platform adapters (e.g., ATIB)
– Configuration files
– Utility modules (logging, error handling, security tokens)
– Possibly integration tests

##### README for additional insights
- Describes functional scope: uniform payment interface + support for multiple payment platforms
- Mentions versioning, branching, and documentation location
- No explicit architecture is supplied, so we must infer a modular, adapter-based design

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        ClientApp["Client Application"]:::external
        Documentation["Documentation / Public API Overview"]:::api
        PaymentAPI["PaymentIB Core API\n(Public Interfaces)"]:::api
        RequestBuilder["PaymentRequestBuilder"]:::api
    end

    %% Business Layer
    subgraph "Business Logic Layer"
        direction TB
        CoreEngine["Core Engine"]:::business
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        Config["Configuration Module"]:::infra
        Security["Security Module"]:::infra
        Logging["Logging & Monitoring"]:::infra
    end

    %% Integration Layer
    subgraph "Integration Layer"
        direction TB
        AdapterFactory["Adapter Factory\n(Strategy)"]:::integration
        ATIBAdapter["ATIB Adapter"]:::integration
        FutureAdapter["Other PSP Adapter (Future)"]:::integration
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        ATIB["ATIB Payment Gateway"]:::external
        Webhook["Webhook / Notification Endpoint"]:::external
    end

    %% Connections
    ClientApp -->|invokes| PaymentAPI
    Documentation -->|references| PaymentAPI
    PaymentAPI -->|builds request| RequestBuilder
    RequestBuilder -->|passes DTO| CoreEngine
    CoreEngine -->|loads config| Config
    CoreEngine -->|uses security| Security
    CoreEngine -->|logs to| Logging
    CoreEngine -->|selects adapter| AdapterFactory
    AdapterFactory --> ATIBAdapter
    AdapterFactory --> FutureAdapter
    ATIBAdapter -->|HTTPS POST XML| ATIB
    ATIB -->|response| ATIBAdapter
    ATIBAdapter -->|translated DTO| CoreEngine
    ATIB -->|webhook callback| Webhook
    Webhook -->|event listener| CoreEngine
    CoreEngine -->|logs to| Logging

    %% Styles
    classDef api fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef business fill:#DFFFE0,stroke:#28A745,color:#28A745;
    classDef integration fill:#FFF4CC,stroke:#F4B400,color:#F4B400;
    classDef infra fill:#FBE8FD,stroke:#A626A4,color:#A626A4;
    classDef external fill:#FFEFE6,stroke:#D73A49,color:#D73A49;

    %% Click Events
    click Documentation "https://github.com/governib/paymentib/blob/master/README.md"
```
