# hendi-arch/bank-transfer-app architecture

> Architecture diagram of the GitHub repository hendi-arch/bank-transfer-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hendi-arch/bank-transfer-app
- Repository: https://github.com/hendi-arch/bank-transfer-app

## Overview

##### Main Components

a) Client Layer
- External clients (Web/Mobile)
- API Gateway (Port 3333)

b) Application Layers (Following Clean Architecture)
1. Infrastructure Layer
- Controllers (REST endpoints)
- Security Components
- Database Repositories
- Schema Definitions
2. Use Case Layer
- Business Logic Components
- Service Implementations
3. Entity Layer
- Domain Models
- Gateway Interfaces

c) Database Layer
- PostgreSQL Database

##### Component Relationships

- Client requests flow through Security Filters
- Controllers depend on Use Cases
- Use Cases depend on Entity Gateways
- Infrastructure implements Gateway interfaces
- Database Gateways implement Entity Gateway interfaces

##### Detailed Component Breakdown

Core Modules:
**Users Module:**
- Authentication/Authorization
- User Management
- Role Management
- Token Management

**Transactions Module:**
- Fund Transfers
- Transaction Management

##### Security Layer Representation

A dedicated security section showing:
- JWT Authentication flow
- RBAC Authorization
- Security Filters
- Token Management

##### Specific Implementation Details

- Clean Architecture boundaries
- Dependency flow (outside-in)
- Interface segregation
- Database access through repositories
- DTO transformations between layers

##### Key Components to Detail

**Controllers:**
- UserController
- TransactionController
- UserRoleController
- UserTokenController

**Use Cases:**
- User Management
- Transaction Processing
- Role Management
- Token Handling

**Entities:**
- User
- Transaction
- UserRole
- UserToken

**Infrastructure:**
- Security Filters
- Database Gateways
- Web Configurations

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Clients
    subgraph Clients
        WC[Web Client]:::client
        MC[Mobile Client]:::client
    end

    %% API Gateway
    AG["API Gateway (Port 3333)"]:::gateway

    %% Infrastructure Layer
    subgraph Infrastructure
        %% Controllers
        UC["User Controller"]:::controller
        TC["Transaction Controller"]:::controller
        RC["UserRole Controller"]:::controller
        TOC["UserToken Controller"]:::controller

        %% Security
        subgraph Security
            SF[Security Filters]:::security
            JU[JWT Utils]:::security
            SC[Security Config]:::security
        end

        %% Database Gateways
        UDG[User DB Gateway]:::dbgateway
        TDG[Transaction DB Gateway]:::dbgateway
        RDG[UserRole DB Gateway]:::dbgateway
        TODG[UserToken DB Gateway]:::dbgateway
    end

    %% Use Case Layer
    subgraph UseCases
        UUC[User Use Cases]:::usecase
        TUC[Transaction Use Cases]:::usecase
        RUC[UserRole Use Cases]:::usecase
        TOUC[UserToken Use Cases]:::usecase
    end

    %% Entity Layer
    subgraph Entities
        %% Domain Models
        UM[User Model]:::entity
        TM[Transaction Model]:::entity
        RM[UserRole Model]:::entity
        TOM[UserToken Model]:::entity

        %% Gateway Interfaces
        UG[User Gateway]:::gateway
        TG[Transaction Gateway]:::gateway
        RG[UserRole Gateway]:::gateway
        TOG[UserToken Gateway]:::gateway
    end

    %% Database
    DB[(PostgreSQL)]:::database

    %% Relationships
    WC & MC --> AG
    AG --> SF
    SF --> SC
    SC --> JU
    SF --> UC & TC & RC & TOC

    UC --> UUC
    TC --> TUC
    RC --> RUC
    TOC --> TOUC

    UUC --> UG
    TUC --> TG
    RUC --> RG
    TOUC --> TOG

    UDG --> UG
    TDG --> TG
    RDG --> RG
    TODG --> TOG

    UDG & TDG & RDG & TODG --> DB

    %% Click Events
    click UM "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/user/model/UserAccountModel.java"
    click TM "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/transaction/model/TransactionModel.java"
    click RM "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/userrole/model/UserRoleModel.java"
    click TOM "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/usertoken/model/UserTokenModel.java"
    
    click UC "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/user/controller/UserController.java"
    click TC "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/transaction/controller/TransactionController.java"
    click RC "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/userrole/controller/UserRoleController.java"
    click TOC "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/usertoken/controller/UserTokenController.java"
    
    click SC "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/config/web/security/config/AppSecurityConfig.java"
    click JU "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/config/web/security/util/JwtUtils.java"
    click SF "https://github.com/Hendi-arch/bank-transfer-app/tree/main/src/main/java/com/hendi/banktransfersystem/infrastructure/config/web/security/filter"
    
    click UUC "https://github.com/Hendi-arch/bank-transfer-app/tree/main/src/main/java/com/hendi/banktransfersystem/usecase/user"
    click TUC "https://github.com/Hendi-arch/bank-transfer-app/tree/main/src/main/java/com/hendi/banktransfersystem/usecase/transaction"
    click RUC "https://github.com/Hendi-arch/bank-transfer-app/tree/main/src/main/java/com/hendi/banktransfersystem/usecase/userrole"
    click TOUC "https://github.com/Hendi-arch/bank-transfer-app/tree/main/src/main/java/com/hendi/banktransfersystem/usecase/usertoken"
    
    click UG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/user/gateway/UserGateway.java"
    click TG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/transaction/gateway/TransactionGateway.java"
    click RG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/userrole/gateway/UserRoleGateway.java"
    click TOG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/entity/usertoken/gateway/UserTokenGateway.java"
    
    click UDG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/user/gateway/UserDatabaseGateway.java"
    click TDG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/transaction/gateway/TransactionDatabaseGateway.java"
    click RDG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/userrole/gateway/UserRoleDatabaseGateway.java"
    click TODG "https://github.com/Hendi-arch/bank-transfer-app/blob/main/src/main/java/com/hendi/banktransfersystem/infrastructure/usertoken/gateway/UserTokenDatabaseGateway.java"

    %% Styles
    classDef client fill:#gray
    classDef gateway fill:#purple
    classDef controller fill:#blue
    classDef security fill:#red
    classDef dbgateway fill:#blue
    classDef usecase fill:#green
    classDef entity fill:#yellow
    classDef database fill:#orange

    %% Legend
    subgraph Legend
        L1[Client]:::client
        L2[Gateway]:::gateway
        L3[Controller]:::controller
        L4[Security]:::security
        L5[Use Case]:::usecase
        L6[Entity]:::entity
        L7[Database]:::database
    end
```
