# gdiael/jbank architecture

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

- Interactive diagram: https://gitdiagram.com/gdiael/jbank
- Repository: https://github.com/gdiael/jbank

## Overview

1. **Overall shape**
   - `jbank` is a small **Spring Boot / Java 17** application organized as a layered domain app: **adapter → service → repository → model**.
   - The package names suggest a light **hexagonal/clean architecture style**, even though the codebase is compact.

2. **Runtime entry points**
   - `com.ufrn.jbank.JbankApplication` is the Spring Boot bootstrap class and the main application boundary.
   - `com.ufrn.jbank.adapter.MainCli` indicates the primary user-facing entry point is a **CLI**, not a web UI or REST API.

3. **Adapter layer**
   - `adapter/AccountLoader` and `adapter/MainCli` form the outer layer that handles interaction with the outside world.
   - `AccountLoader` likely populates the system with initial account data, while `MainCli` likely parses commands and invokes application services.

4. **Domain model**
   - `model/Account` is the core domain abstraction.
   - `model/SavingsAccount` and `model/BonusAccount` are concrete account variants, implying business rules differ by account type.
   - The model package is the central business boundary and should remain independent of CLI or persistence concerns.

5. **Application services**
   - `service/AccountService` is the main orchestration layer for account-related use cases.
   - `service/BonusCalculatorService` is a focused domain service for calculating bonuses, likely used by `AccountService` and/or account subtypes.
   - Business rules appear to live here rather than in the CLI or repository.

6. **Repository boundary**
   - `repository/AccountRepository` is the persistence abstraction for accounts.
   - Because there is only one repository interface/file, the storage mechanism is probably simple and localized rather than a full database-centric architecture.
   - The repository sits behind services, so the domain and CLI should not depend directly on storage details.

7. **Main data flow**
   - Typical flow is: **CLI input → `MainCli` → `AccountService` → `AccountRepository` / `BonusCalculatorService` → domain model**.
   - `AccountLoader` likely feeds startup or test data into the same service/repository path.
   - This keeps command handling separate from business logic and persistence.

8. **Business specialization**
   - The presence of both `SavingsAccount` and `BonusAccount` suggests different account behaviors are modeled explicitly rather than with flags.
   - `BonusCalculatorService` likely encapsulates cross-cutting calculation logic instead of duplicating it across account classes.

9. **Configuration and packaging**
   - `src/main/resources/application.properties` contains Spring Boot runtime configuration.
   - There are no visible infrastructure integrations such as databases, message brokers, or external APIs in the tree, so the architecture appears self-contained.

10. **Build and execution**
   - The project uses **Maven** with the wrapper (`mvnw`), which makes the build reproducible.
   - Execution is via `spring-boot:run`, confirming this is a standard Spring Boot application.

11. **Testing**
   - `src/test/java/.../JbankApplicationTests.java` is present, indicating at least a Spring Boot smoke/integration test baseline.
   - The test footprint is small, which suggests the architecture is currently focused on core application structure rather than broad automated coverage.

12. **Diagram takeaway**
   - When drawing the architecture, show a central **domain/service core** with a **CLI adapter** on one side and a **repository boundary** on the other.
   - `AccountLoader` is best treated as a supporting adapter for initial data setup, while `BonusCalculatorService` is a domain service supporting account behavior.

Main entry points: [`jbank/src/main/java/com/ufrn/jbank/service/AccountService.java`](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/service/AccountService.java) (Account Service), [`jbank/src/main/java/com/ufrn/jbank/JbankApplication.java`](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/JbankApplication.java) (Jbank App), [`jbank/src/main/java/com/ufrn/jbank/model/Account.java`](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/Account.java) (Account), [`jbank/src/main/java/com/ufrn/jbank/adapter/MainCli.java`](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/adapter/MainCli.java) (Main CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_bootstrap["Bootstrap"]
  node_n_app(("Jbank App<br/>spring boot entry"))
end

subgraph group_g_adapter["Adapters"]
  node_n_cli["Main CLI<br/>cli adapter<br/>[MainCli.java]"]
  node_n_loader["Account Loader<br/>startup adapter<br/>[AccountLoader.java]"]
end

subgraph group_g_domain["Domain"]
  node_n_account(("Account<br/>domain model<br/>[Account.java]"))
  node_n_savings(("Savings<br/>account variant"))
  node_n_bonus(("Bonus<br/>account variant<br/>[BonusAccount.java]"))
end

subgraph group_g_service["Services"]
  node_n_account_service["Account Service<br/>application service"]
  node_n_bonus_service["Bonus Calc<br/>domain service"]
end

subgraph group_g_repo["Repository"]
  node_n_repo[("Account Repo<br/>repository port")]
end

subgraph group_g_config["Config"]
  node_n_props["App Config<br/>runtime config"]
end

node_n_cli -->|"invokes"| node_n_account_service
node_n_loader -->|"loads via"| node_n_account_service
node_n_account_service -->|"persists through"| node_n_repo
node_n_account_service -->|"calculates with"| node_n_bonus_service
node_n_account_service -->|"operates on"| node_n_account
node_n_bonus_service -->|"supports"| node_n_bonus
node_n_savings -.->|"extends"| node_n_account
node_n_bonus -.->|"extends"| node_n_account
node_n_app -->|"starts"| node_n_cli
node_n_app -->|"initializes"| node_n_loader
node_n_app -->|"reads"| node_n_props

click node_n_app "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/JbankApplication.java"
click node_n_cli "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/adapter/MainCli.java"
click node_n_loader "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/adapter/AccountLoader.java"
click node_n_account "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/Account.java"
click node_n_savings "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/SavingsAccount.java"
click node_n_bonus "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/BonusAccount.java"
click node_n_account_service "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/service/AccountService.java"
click node_n_bonus_service "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/service/BonusCalculatorService.java"
click node_n_repo "https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/repository/AccountRepository.java"
click node_n_props "https://github.com/gdiael/jbank/blob/main/jbank/src/main/resources/application.properties"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_app toneBlue
class node_n_cli,node_n_loader toneAmber
class node_n_account,node_n_savings,node_n_bonus toneMint
class node_n_account_service,node_n_bonus_service toneRose
class node_n_repo toneIndigo
class node_n_props toneTeal
```

## Components

### Bootstrap

Application entry points and startup boundary

- [Jbank App](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/JbankApplication.java): spring boot entry · Main Spring Boot application bootstrap · `jbank/src/main/java/com/ufrn/jbank/JbankApplication.java`

### Adapters

CLI and startup data ingestion

- [Main CLI](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/adapter/MainCli.java): cli adapter · Primary command-line user interface · `jbank/src/main/java/com/ufrn/jbank/adapter/MainCli.java`
- [Account Loader](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/adapter/AccountLoader.java): startup adapter · Loads initial account data through the application flow · `jbank/src/main/java/com/ufrn/jbank/adapter/AccountLoader.java`

### Domain

Core account model and variants

- [Account](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/Account.java): domain model · Core account abstraction · `jbank/src/main/java/com/ufrn/jbank/model/Account.java`
- [Savings](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/SavingsAccount.java): account variant · Savings account behavior and rules · `jbank/src/main/java/com/ufrn/jbank/model/SavingsAccount.java`
- [Bonus](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/model/BonusAccount.java): account variant · Bonus account behavior and rules · `jbank/src/main/java/com/ufrn/jbank/model/BonusAccount.java`

### Services

Use-case orchestration and business rules

- [Account Service](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/service/AccountService.java): application service · Coordinates account use cases · `jbank/src/main/java/com/ufrn/jbank/service/AccountService.java`
- [Bonus Calc](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/service/BonusCalculatorService.java): domain service · Calculates account bonuses · `jbank/src/main/java/com/ufrn/jbank/service/BonusCalculatorService.java`

### Repository

Persistence boundary

- [Account Repo](https://github.com/gdiael/jbank/blob/main/jbank/src/main/java/com/ufrn/jbank/repository/AccountRepository.java): repository port · Persistence abstraction for accounts · `jbank/src/main/java/com/ufrn/jbank/repository/AccountRepository.java`

### Config

Spring Boot runtime configuration

- [App Config](https://github.com/gdiael/jbank/blob/main/jbank/src/main/resources/application.properties): runtime config · Spring Boot application properties · `jbank/src/main/resources/application.properties`

## Connections

- Main CLI → Account Service: invokes · CLI routes commands into application use cases
- Account Loader → Account Service: loads via · Startup data uses the same account workflow
- Account Service → Account Repo: persists through · Service depends on the repository boundary
- Account Service → Bonus Calc: calculates with · Service delegates bonus logic to a dedicated calculator
- Account Service → Account: operates on · Use cases work with the core account model
- Bonus Calc → Bonus: supports · Bonus calculation is tied to bonus account behavior
- Savings → Account: extends · Savings account specializes the base account model
- Bonus → Account: extends · Bonus account specializes the base account model
- Jbank App → Main CLI: starts · Spring Boot boots the command-line adapter
- Jbank App → Account Loader: initializes · Application startup can wire initial data loading
- Jbank App → App Config: reads · Runtime configuration is loaded at startup
