# kimhongpham/atm-system architecture

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

- Interactive diagram: https://gitdiagram.com/kimhongpham/atm-system
- Repository: https://github.com/kimhongpham/atm-system

## Overview

##### Project Type and Purpose
- This is a full-stack, service-based (monolithic) ATM system built with Spring Boot.
- It supports customer ATM operations (withdrawal, transfer, balance inquiry, PIN change, OTP), and an admin/back-office UI for ATM management and cash updates.
- Security is enforced via JWT, and data persistence uses Spring Data JPA with MySQL.

##### File Structure
Top-level modules:
- src/main/java/com/atm – the core Spring Boot application
– config: SecurityConfig, AdminAuthenticationProvider
– controller: REST endpoints (AccountController, TransactionController, etc.)
– service: business logic (AccountService, TransactionService, OtpService)
– repository: data access (JpaRepositories for Account, Transaction, ATM, etc.)
– model: JPA entities
– dto: request/response payloads
– util: JWT filters, utilities
- src/main/java/com/frontend – CLI-style UI classes for ATM and admin menus
- src/main/resources/static & templates – Thymeleaf web UI for back-office
- src/main/resources/application.properties – configuration (DB, JWT secrets)
- src/main/resources/http-requests – sample HTTP calls for API testing
- build.gradle.kts, gradle wrapper – build scripts

##### Key Insights from README
- The chosen “service-based” architecture balances flexibility and cost.
- Future vision: evolve to microservices for mobile banking, e-wallet, fraud detection.
- Tech stack: Java21, Spring Boot3.1, Spring Security (JWT), Spring Data JPA, MySQL, Thymeleaf, Bootstrap.

## Diagram (Mermaid)

```mermaid
graph TB
  %% UI Layer
  subgraph "Client Layer"
    CLIUI["ATM CLI UI"]:::frontend
    subgraph "Web Back-office UI"
      Templates["Templates (Thymeleaf)"]:::frontend
      StaticAssets["Static Assets (CSS/JS/Images)"]:::frontend
    end
    APITools["API Testing (HTTP-requests)"]:::frontend
  end

  %% API Layer
  subgraph "API Layer"
    JWTFilter["JWTAuthenticationFilter 🔒"]:::api
    SecurityConfig["SecurityConfig 🔒"]:::api
    AdminProvider["AdminAuthenticationProvider"]:::api
    subgraph "Controllers"
      AccountCtrl["AccountController"]:::api
      TransactionCtrl["TransactionController"]:::api
      BalanceCtrl["BalanceController"]:::api
      CredentialCtrl["CredentialController"]:::api
      UserCtrl["UserController"]:::api
      BackOfficeCtrl["BackOfficeController"]:::api
    end
  end

  %% Service Layer
  subgraph "Service Layer"
    AccService["AccountService"]:::service
    TransService["TransactionService"]:::service
    OtpService["OtpService"]:::service
    ATMService["ATMService"]:::service
    UserService["UserService"]:::service
    BalanceService["BalanceService"]:::service
    CredService["CredentialService"]:::service
  end

  %% Repository Layer
  subgraph "Data Access Layer"
    AccRepo["AccountRepository"]:::repository
    TransRepo["TransactionRepository"]:::repository
    BalanceRepo["BalanceRepository"]:::repository
    CredRepo["CredentialRepository"]:::repository
    UserRepo["UserRepository"]:::repository
    ATMRepo["ATMRepository"]:::repository
  end

  %% Database
  MySQL[(MySQL DB)]:::db

  %% External Services
  subgraph "External/Infrastructures"
    OTPGateway["OTP Gateway"]:::external
    JWTSecretMgr["JWT Secret Manager"]:::external
  end

  %% Connections
  CLIUI -->|method call| AccountCtrl
  CLIUI -->|method call| TransactionCtrl
  CLIUI -->|method call| BalanceCtrl
  CLIUI -->|method call| CredentialCtrl
  CLIUI -->|method call| UserCtrl

  Templates -->|HTTP/JSON| JWTFilter
  StaticAssets -->|HTTP/JSON| JWTFilter
  APITools -->|HTTP/JSON| JWTFilter

  JWTFilter -->|authorizes| SecurityConfig
  JWTFilter -->|authenticates| AdminProvider
  JWTFilter -->|forwards| AccountCtrl
  JWTFilter -->|forwards| TransactionCtrl
  JWTFilter -->|forwards| BalanceCtrl
  JWTFilter -->|forwards| CredentialCtrl
  JWTFilter -->|forwards| UserCtrl
  JWTFilter -->|forwards| BackOfficeCtrl

  AccountCtrl -->|calls| AccService
  TransactionCtrl -->|calls| TransService
  BalanceCtrl -->|calls| BalanceService
  CredentialCtrl -->|calls| CredService
  UserCtrl -->|calls| UserService
  BackOfficeCtrl -->|calls| ATMService

  AccService -->|CRUD| AccRepo
  TransService -->|CRUD| TransRepo
  BalanceService -->|CRUD| BalanceRepo
  CredService -->|CRUD| CredRepo
  UserService -->|CRUD| UserRepo
  ATMService -->|CRUD| ATMRepo

  OTPService -->|send/verify| OTPGateway
  JWTSecretMgr -->|provides keys| SecurityConfig

  AccRepo -->|JDBC| MySQL
  TransRepo -->|JDBC| MySQL
  BalanceRepo -->|JDBC| MySQL
  CredRepo -->|JDBC| MySQL
  UserRepo -->|JDBC| MySQL
  ATMRepo -->|JDBC| MySQL

  AdminProvider -->|validates| UserRepo

  %% Click Events
  click CLIUI "https://github.com/kimhongpham/atm-system/tree/main/ATMSystem/src/main/java/com/frontend"
  click Templates "https://github.com/kimhongpham/atm-system/tree/main/ATMSystem/src/main/resources/templates"
  click StaticAssets "https://github.com/kimhongpham/atm-system/tree/main/ATMSystem/src/main/resources/static"
  click APITools "https://github.com/kimhongpham/atm-system/tree/main/ATMSystem/src/main/resources/http-requests"
  click AccountCtrl "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/controller/AccountController.java"
  click TransactionCtrl "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/controller/TransactionController.java"
  click BalanceCtrl "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/controller/BalanceController.java"
  click CredentialCtrl "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/controller/CredentialController.java"
  click UserCtrl "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/controller/UserController.java"
  click BackOfficeCtrl "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/controller/BackOfficeController.java"
  click JWTFilter "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/util/JwtAuthenticationFilter.java"
  click SecurityConfig "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/config/SecurityConfig.java"
  click AdminProvider "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/config/AdminAuthenticationProvider.java"
  click AccService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/AccountService.java"
  click TransService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/TransactionService.java"
  click OtpService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/OtpService.java"
  click ATMService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/ATMService.java"
  click UserService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/UserService.java"
  click BalanceService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/BalanceService.java"
  click CredService "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/service/CredentialService.java"
  click AccRepo "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/repository/AccountRepository.java"
  click TransRepo "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/repository/TransactionRepository.java"
  click BalanceRepo "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/repository/BalanceRepository.java"
  click CredRepo "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/repository/CredentialRepository.java"
  click UserRepo "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/repository/UserRepository.java"
  click ATMRepo "https://github.com/kimhongpham/atm-system/blob/main/ATMSystem/src/main/java/com/atm/repository/ATMRepository.java"

  %% Styles
  classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
  classDef api fill:#d4edda,stroke:#155724,color:#155724
  classDef service fill:#fff3cd,stroke:#856404,color:#856404
  classDef repository fill:#e2e3e5,stroke:#383d41,color:#383d41
  classDef external fill:#f8f9fa,stroke:#6c757d,color:#6c757d
  classDef db fill:#f5c6cb,stroke:#721c24,color:#721c24
```
