# shady1997/-mobile_bank_api_restful architecture

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

- Interactive diagram: https://gitdiagram.com/shady1997/-mobile_bank_api_restful
- Repository: https://github.com/shady1997/-mobile_bank_api_restful

## Overview

##### Project type and purpose
- This is a standalone Spring Boot 3.2.0 RESTful API service (“Mobile Banking REST API”) implemented in Java 17.
- Purpose: Provide core mobile banking operations (user, account, transaction management) via HTTP endpoints, with H2 in-memory DB for persistence, Swagger/OpenAPI docs, basic auth security, and comprehensive testing.

##### File structure
- Top level:
- dockerfile, pom.xml, README.md, LICENSE, .github (CI/CD deploy.yml)
- src/main/java/org/banking:
– config (SecurityConfig, OpenApiConfig)
– controller (AccountController, TransactionController, UserController)
– service (AccountService, TransactionService, UserService)
– repository (Spring Data JPA interfaces)
– model (JPA entities)
– dto (API data transfer objects)
– exception (custom exceptions, global handler)
– entrypoint: MobileBankingApiApplication.java
- src/main/resources/application.yml (datasource, H2, Hikari)
- src/test: unit & integration tests
- Pattern: classic layered MVC (Controller → Service → Repository → Database), plus cross-cutting concerns (security, validation, global exception handling).

##### README for additional insights
- Confirms tech stack (Spring Boot, Java, H2, JPA/Hibernate, Spring Security, OpenAPI, RestAssured).
- Lists features (CRUD, transactions, validations, error handling, Swagger UI, H2 console).
- Outlines DB schema (users, accounts, transactions tables).
- Mentions deployment (Dockerfile), CI/CD workflow, and production security recommendations.

##### Final recommendations
- Every package as a component: config, controller, service, repository, model, dto, exception.
- Infrastructure (Docker, CI/CD) and non-functional elements (security, validation, testing) as side modules.
- Use this detailed layered view to communicate the complete architecture to stakeholders and new team members.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entities
    Client["Client (Mobile App / Postman / Swagger UI)"]:::external
    SecurityFilterChain["Security Filter Chain"]:::crosscut
    App["MobileBankingApiApplication"]:::app

    subgraph "API Layer (Controllers)"
        direction TB
        UC["UserController"]:::api
        AC["AccountController"]:::api
        TC["TransactionController"]:::api
    end

    subgraph "Service Layer"
        direction TB
        US["UserService"]:::service
        AS["AccountService"]:::service
        TS["TransactionService"]:::service
    end

    subgraph "Repository Layer"
        direction TB
        UR["UserRepository"]:::repository
        AR["AccountRepository"]:::repository
        TR["TransactionRepository"]:::repository
    end

    H2DB["H2 Database"]:::database

    subgraph "Cross-cutting Concerns"
        direction TB
        OpenApiConfig["OpenApiConfig"]:::crosscut
        SecurityConfig["SecurityConfig"]:::crosscut
        GlobalExceptionHandler["GlobalExceptionHandler"]:::crosscut
    end

    subgraph "Infrastructure"
        direction TB
        Docker["Docker Container"]:::infra
        CICD["GitHub Actions CI/CD"]:::infra
    end

    %% Relationships
    Client -->|"HTTP requests (Basic Auth)"| SecurityFilterChain
    SecurityFilterChain -->|"Bootstrap"| App
    App -->|"Scans Controllers"| UC
    App --> AC
    App --> TC
    UC -->|"POST/GET/PUT/DELETE /api/users"| US
    AC -->|"POST/GET/PUT/DELETE /api/accounts"| AS
    TC -->|"POST/GET /api/transactions"| TS

    US -->|"uses DTOs"| UC
    AS -->|"uses DTOs"| AC
    TS -->|"uses DTOs"| TC

    US -->|"calls save()/find() etc."| UR
    AS -->|"calls save()/find() etc."| AR
    TS -->|"calls save()/find() etc."| TR

    UR -->|"JPA SQL"| H2DB
    AR --> H2DB
    TR --> H2DB

    UC -->|"docs at /swagger-ui"| OpenApiConfig
    AC --> OpenApiConfig
    TC --> OpenApiConfig

    UC --x|"Exception"| GlobalExceptionHandler --> Client
    US --x|"Exception"| GlobalExceptionHandler --> Client
    AS --x|"Exception"| GlobalExceptionHandler --> Client
    TS --x|"Exception"| GlobalExceptionHandler --> Client

    CICD --> Docker
    Docker --> App

    %% Click Events
    click App "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/MobileBankingApiApplication.java"
    click UC "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/controller/UserController.java"
    click AC "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/controller/AccountController.java"
    click TC "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/controller/TransactionController.java"
    click US "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/service/UserService.java"
    click AS "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/service/AccountService.java"
    click TS "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/service/TransactionService.java"
    click UR "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/repository/UserRepository.java"
    click AR "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/repository/AccountRepository.java"
    click TR "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/repository/TransactionRepository.java"
    click OpenApiConfig "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/config/OpenApiConfig.java"
    click SecurityConfig "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/config/SecurityConfig.java"
    click GlobalExceptionHandler "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/java/org/banking/exception/GlobalExceptionHandler.java"
    click Docker "https://github.com/shady1997/-mobile_bank_api_restful/tree/master/dockerfile"
    click CICD "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/.github/workflows/deploy.yml"
    click H2DB "https://github.com/shady1997/-mobile_bank_api_restful/blob/master/src/main/resources/application.yml"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef app fill:#ccf,stroke:#333,stroke-width:1px
    classDef api fill:#9cf,stroke:#333,stroke-width:1px
    classDef service fill:#afa,stroke:#333,stroke-width:1px
    classDef repository fill:#ff9,stroke:#333,stroke-width:1px
    classDef database fill:#fc9,stroke:#333,stroke-width:1px
    classDef crosscut fill:#ddd,stroke:#333,stroke-width:1px
    classDef infra fill:#eee,stroke:#333,stroke-width:1px
```
