# 3lhelow/bank-system architecture

> Architecture diagram of the GitHub repository 3lhelow/bank-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/3lhelow/bank-system
- Repository: https://github.com/3lhelow/bank-system

## Overview

#### Purpose and Runtime
This is a Java 21 console application for managing bank client accounts: client CRUD, balance lookup/reporting, and deposits/withdrawals. It uses Maven to build and runs as a Java SE process with no web server, framework, database, or external service dependency.

Entry point: `src/main/java/org/bank/system/main/Application.java`.

#### Composition Root and Shared State
`src/main/java/org/bank/system/config/ApplicationContext.java` centralizes application constants and shared service/repository instances. It acts as the composition root/service locator used to connect UI actions to business and persistence layers.

The application’s durable state is the repository-relative flat file `client_data.txt`.

#### Console UI and Navigation
The UI is an interactive text-menu boundary. `src/main/java/org/bank/system/ui/MainMenu.java` presents primary client-management/reporting operations, while `src/main/java/org/bank/system/ui/TransactionsMenu.java` handles deposit and withdrawal workflows.

`src/main/java/org/bank/system/ui/BaseMenu.java` provides common menu behavior. `src/main/java/org/bank/system/ui/ConsoleInput.java` collects console input before it is validated and dispatched to services. `src/main/java/org/bank/system/ui/ClientTablePrinter.java` renders client/balance results for users.

#### Client Domain and CRUD Flow
`src/main/java/org/bank/system/model/Client.java` is the core account record, carrying client identity/details and balance state.

For add, update, delete, search, and list/report requests, the flow is:
UI menu → `src/main/java/org/bank/system/service/ClientService.java` → `src/main/java/org/bank/system/repository/FileRepository.java` → `client_data.txt`.

`ClientService` owns client-oriented business behavior and shields menus from file format and I/O concerns.

#### Transaction Flow and Financial Boundary
`src/main/java/org/bank/system/service/TransactionsService.java` owns balance mutations for deposits and withdrawals. `src/main/java/org/bank/system/service/TransactionType.java` defines the supported transaction modes (`DEPOSIT` and `WITHDRAW`).

Transaction menus gather an account/client target and amount, validate input and balance constraints, invoke `TransactionsService`, then persist the updated client set through the repository path. Withdrawal validation is a critical business boundary: balances must not be reduced below permitted limits.

#### Persistence Boundary
`src/main/java/org/bank/system/repository/FileRepository.java` is the sole persistence adapter. It reads and writes client records using the `#//#` flat-file delimiter, isolating serialization and filesystem details from services and UI.

Persistence is file-based rather than transactional: updates ultimately rewrite or modify `client_data.txt`; there is no database concurrency, locking, remote API, or audit/event infrastructure indicated.

#### Validation and Output Boundaries
`src/main/java/org/bank/system/util/ValidationUtil.java` supports validation of user-provided values before service operations. Input handling remains at the console boundary, business rules reside in services, and formatted output is isolated in `ClientTablePrinter`.

The primary control loop starts in `Application`, initializes context/menu dependencies, repeatedly accepts menu selections, executes service operations, displays results, and exits on the user’s termination choice.

Main entry points: [`src/main/java/org/bank/system/ui/MainMenu.java`](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/MainMenu.java) (MainMenu), [`src/main/java/org/bank/system/ui/TransactionsMenu.java`](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/TransactionsMenu.java) (TransactionsMenu), [`src/main/java/org/bank/system/service/TransactionsService.java`](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/TransactionsService.java) (TransactionsService), [`src/main/java/org/bank/system/config/ApplicationContext.java`](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/config/ApplicationContext.java) (ApplicationContext)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Java SE Runtime"]
  node_application["Application<br/>entry point<br/>[Application.java]"]
  node_context["ApplicationContext<br/>composition root"]
end

subgraph group_ui["Console UI"]
  node_main_menu["MainMenu<br/>console menu<br/>[MainMenu.java]"]
  node_transactions_menu["TransactionsMenu<br/>console menu"]
  node_base_menu["BaseMenu<br/>menu base<br/>[BaseMenu.java]"]
  node_console_input["ConsoleInput<br/>input adapter<br/>[ConsoleInput.java]"]
  node_table_printer["ClientTablePrinter<br/>output adapter"]
  node_validation["ValidationUtil<br/>validation utility"]
end

subgraph group_domain["Domain &amp; Services"]
  node_client["Client<br/>account model<br/>[Client.java]"]
  node_client_service["ClientService<br/>business service<br/>[ClientService.java]"]
  node_transactions_service["TransactionsService<br/>business service"]
  node_transaction_type["TransactionType<br/>transaction modes"]
end

subgraph group_persistence["Persistence"]
  node_file_repository["FileRepository<br/>persistence adapter"]
  node_client_data[("client_data.txt<br/>flat-file store<br/>[client_data.txt]")]
end

node_application -->|"initializes"| node_context
node_application -->|"runs loop"| node_main_menu
node_application -->|"runs flow"| node_transactions_menu
node_context -->|"provides"| node_client_service
node_context -->|"provides"| node_transactions_service
node_context -->|"provides"| node_file_repository
node_main_menu -->|"uses"| node_base_menu
node_transactions_menu -->|"uses"| node_base_menu
node_main_menu -->|"collects input"| node_console_input
node_transactions_menu -->|"collects input"| node_console_input
node_console_input -->|"validates"| node_validation
node_main_menu -->|"CRUD and reports"| node_client_service
node_transactions_menu -->|"deposit / withdraw"| node_transactions_service
node_main_menu -->|"renders results"| node_table_printer
node_transactions_menu -->|"renders balances"| node_table_printer
node_client_service -->|"manages"| node_client
node_transactions_service -->|"mutates balance"| node_client
node_transactions_service -->|"uses"| node_transaction_type
node_client_service -->|"persists clients"| node_file_repository
node_transactions_service -->|"persists updates"| node_file_repository
node_file_repository -->|"reads / writes"| node_client_data

click node_application "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/main/Application.java"
click node_context "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/config/ApplicationContext.java"
click node_main_menu "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/MainMenu.java"
click node_transactions_menu "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/TransactionsMenu.java"
click node_base_menu "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/BaseMenu.java"
click node_console_input "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/ConsoleInput.java"
click node_table_printer "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/ClientTablePrinter.java"
click node_validation "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/util/ValidationUtil.java"
click node_client "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/model/Client.java"
click node_client_service "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/ClientService.java"
click node_transactions_service "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/TransactionsService.java"
click node_transaction_type "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/TransactionType.java"
click node_file_repository "https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/repository/FileRepository.java"
click node_client_data "https://github.com/3lhelow/bank-system/blob/main/client_data.txt"

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_application,node_context toneBlue
class node_main_menu,node_transactions_menu,node_base_menu,node_console_input,node_table_printer,node_validation toneAmber
class node_client,node_client_service,node_transactions_service,node_transaction_type toneMint
class node_file_repository,node_client_data toneRose
```

## Components

### Java SE Runtime

- [Application](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/main/Application.java): entry point · Starts the interactive control loop. · `src/main/java/org/bank/system/main/Application.java`
- [ApplicationContext](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/config/ApplicationContext.java): composition root · Provides shared service and repository instances. · `src/main/java/org/bank/system/config/ApplicationContext.java`

### Console UI

- [MainMenu](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/MainMenu.java): console menu · Handles client management and reporting actions. · `src/main/java/org/bank/system/ui/MainMenu.java`
- [TransactionsMenu](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/TransactionsMenu.java): console menu · Handles deposit and withdrawal workflows. · `src/main/java/org/bank/system/ui/TransactionsMenu.java`
- [BaseMenu](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/BaseMenu.java): menu base · Supplies common menu behavior. · `src/main/java/org/bank/system/ui/BaseMenu.java`
- [ConsoleInput](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/ConsoleInput.java): input adapter · Collects interactive user input. · `src/main/java/org/bank/system/ui/ConsoleInput.java`
- [ClientTablePrinter](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/ui/ClientTablePrinter.java): output adapter · Renders client and balance results. · `src/main/java/org/bank/system/ui/ClientTablePrinter.java`
- [ValidationUtil](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/util/ValidationUtil.java): validation utility · Validates user-provided values before operations. · `src/main/java/org/bank/system/util/ValidationUtil.java`

### Domain & Services

- [Client](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/model/Client.java): account model · Client identity, details, and balance state. · `src/main/java/org/bank/system/model/Client.java`
- [ClientService](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/ClientService.java): business service · Owns client CRUD, search, list, and reporting behavior. · `src/main/java/org/bank/system/service/ClientService.java`
- [TransactionsService](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/TransactionsService.java): business service · Applies deposits and constrained withdrawals. · `src/main/java/org/bank/system/service/TransactionsService.java`
- [TransactionType](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/service/TransactionType.java): transaction modes · Defines DEPOSIT and WITHDRAW modes. · `src/main/java/org/bank/system/service/TransactionType.java`

### Persistence

- [FileRepository](https://github.com/3lhelow/bank-system/blob/main/src/main/java/org/bank/system/repository/FileRepository.java): persistence adapter · Serializes client records with the #//# delimiter. · `src/main/java/org/bank/system/repository/FileRepository.java`
- [client_data.txt](https://github.com/3lhelow/bank-system/blob/main/client_data.txt): flat-file store · Durable client record storage. · `client_data.txt`

## Connections

- Application → ApplicationContext: initializes
- Application → MainMenu: runs loop
- Application → TransactionsMenu: runs flow
- ApplicationContext → ClientService: provides
- ApplicationContext → TransactionsService: provides
- ApplicationContext → FileRepository: provides
- MainMenu → BaseMenu: uses
- TransactionsMenu → BaseMenu: uses
- MainMenu → ConsoleInput: collects input
- TransactionsMenu → ConsoleInput: collects input
- ConsoleInput → ValidationUtil: validates
- MainMenu → ClientService: CRUD and reports
- TransactionsMenu → TransactionsService: deposit / withdraw
- MainMenu → ClientTablePrinter: renders results
- TransactionsMenu → ClientTablePrinter: renders balances
- ClientService → Client: manages
- TransactionsService → Client: mutates balance
- TransactionsService → TransactionType: uses
- ClientService → FileRepository: persists clients
- TransactionsService → FileRepository: persists updates
- FileRepository → client_data.txt: reads / writes
