# jay-abre/payment-gateway-system-springboot architecture

> Architecture diagram of the GitHub repository jay-abre/payment-gateway-system-springboot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jay-abre/payment-gateway-system-springboot
- Repository: https://github.com/jay-abre/payment-gateway-system-springboot

## Overview

##### Project type and purpose
- This is a backend-only, full-blown microservices system (“Digital Wallet Microservice Application”) built on Java/Spring Boot.
- Each service is independently deployed (Docker + docker-compose), communicates via Kafka, and persists to its own PostgreSQL database.
- A shared “common” library holds cross-cutting event definitions and configuration.

##### File-structure analysis
- Top-level:
– docker-compose.yml (orchestrates services, Kafka, Postgres, Prometheus, Grafana)
– payment-gateway-services/ (root for all microservices + common module + per-service folders)
- Per service (user-service, account-service, transaction-service, payment-gateway-service, bank-reconciliation-service, notification-service):
– src/main/java: standard Spring Boot layers (config, controller, service, repository, security, entity, dto, mapper, exception)
– src/main/resources/application.yml: service-specific configuration (port, DB, Kafka topics, Swagger)
– Dockerfile + mvnw wrapper + pom.xml
– src/test/java: unit/integration tests (TDD style)
- common/: reusable configs and event classes (AccountCreatedEvent, PaymentSuccessEvent, etc.)

##### README insights
- Microservices with real-time streaming (Kafka).
- Containerized (Docker), monitored (Prometheus/Grafana), logged (SLF4J).
- CI/CD in GitHub Actions.
- Exposed Swagger UIs on distinct ports per service.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestration Layer
    subgraph "Orchestration (Docker-Compose)" 
        direction TB
        DC["Docker-Compose"]:::orchestration
        Prom["Prometheus"]:::monitor
        Graf["Grafana"]:::monitor
        Kafka["Kafka Cluster"]:::kafka
        Common["Common Library"]:::common
        subgraph "Microservices"
            direction TB
            US["User Service<br/>(Port 8081)"]:::service
            AS["Account Service<br/>(Port 8082)"]:::service
            TS["Transaction Service<br/>(Port 8083)"]:::service
            PGS["Payment Gateway Service<br/>(Port 8084)"]:::service
            BRS["Bank Reconciliation Service<br/>(Port 8085)"]:::service
            NS["Notification Service<br/>(Port 8086)"]:::service
        end
        subgraph "PostgreSQL Databases"
            direction TB
            USDb[(User DB)]:::db
            ASDb[(Account DB)]:::db
            TSDb[(Transaction DB)]:::db
            PGSDb[(Payment DB)]:::db
            BRSDb[(Reconciliation DB)]:::db
            NSDb[(Notification DB)]:::db
        end
    end

    %% External Systems
    Client["Client Application"]:::external
    StripeAPI["Stripe External API"]:::external

    %% Client REST Calls
    Client -->|"REST POST/GET"| US
    Client -->|"REST POST/GET"| AS
    Client -->|"REST POST/GET"| TS
    Client -->|"REST POST/GET"| PGS
    Client -->|"REST POST/GET"| BRS
    Client -->|"REST POST/GET"| NS

    %% Service to DB
    US -->|reads/writes| USDb
    AS -->|reads/writes| ASDb
    TS -->|reads/writes| TSDb
    PGS -->|reads/writes| PGSDb
    BRS -->|reads/writes| BRSDb
    NS -->|reads/writes| NSDb

    %% Event Bus Interactions
    US -.->|UserCreatedEvent| Kafka
    AS -.->|AccountCreatedEvent| Kafka
    TS -.->|TransactionInitiatedEvent| Kafka
    PGS -.->|PaymentSuccessEvent| Kafka
    BRS -.->|ReconciliationCompletedEvent| Kafka
    NS -.->|NotificationEvent| Kafka

    Kafka -.->|UserCreatedEvent| AS
    Kafka -.->|AccountCreatedEvent| TS
    Kafka -.->|TransactionInitiatedEvent| PGS
    Kafka -.->|PaymentSuccessEvent| NS
    Kafka -.->|ReconciliationCompletedEvent| NS

    %% External Integration
    PGS -->|"HTTP API"| StripeAPI
    StripeAPI -->|Webhook| BRS
    BRS -.->|StripeWebhookEvent| Kafka

    %% Monitoring
    US -->|metrics| Prom
    AS -->|metrics| Prom
    TS -->|metrics| Prom
    PGS -->|metrics| Prom
    BRS -->|metrics| Prom
    NS -->|metrics| Prom
    Prom -->|dashboards| Graf

    %% Common Library Usage
    Common --> US
    Common --> AS
    Common --> TS
    Common --> PGS
    Common --> BRS
    Common --> NS

    %% Click Events
    click US "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/user-service/"
    click AS "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/account-service/"
    click TS "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/transaction-service/"
    click PGS "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/payment-gateway-service/"
    click BRS "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/bank-reconciliation-service/"
    click NS "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/notification-service/"
    click Common "https://github.com/jay-abre/payment-gateway-system-springboot/tree/main/payment-gateway-services/common/"
    click DC "https://github.com/jay-abre/payment-gateway-system-springboot/blob/main/payment-gateway-services/docker-compose.yml"

    %% Styles
    classDef service fill:#e0f7fa,stroke:#006064,color:#004d40;
    classDef db fill:#ffe0b2,stroke:#ef6c00,color:#e65100;
    classDef kafka fill:#c8e6c9,stroke:#2e7d32,color:#1b5e20;
    classDef orchestration fill:#eceff1,stroke:#37474f,color:#263238,shape:hexagon;
    classDef monitor fill:#f3e5f5,stroke:#6a1b9a,color:#4a148c;
    classDef external fill:#ffebee,stroke:#c62828,color:#b71c1c;
    classDef common fill:#fff9c4,stroke:#f9a825,color:#f57f17;
```
