# salahashraf253/banksystem architecture

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

- Interactive diagram: https://gitdiagram.com/salahashraf253/banksystem
- Repository: https://github.com/salahashraf253/banksystem

## Overview

##### Project Type and Purpose
- This is a full-stack desktop banking application built with JavaFX (frontend), Java (backend), and MySQL (database).
- It supports two user roles (Client and Admin), provides account operations (open/close accounts, deposit/withdraw, transfer, loan management), and integrates external services (email notifications and currency conversion).

##### High-Level Component Identification
a. Presentation Layer (JavaFX GUI)
- Package: com.example.GUI
- Controllers (e.g., LoginFormController, HomeController, MoneyTransferController, etc.)
- FXML views and CSS under src/main/resources/com/example/banksystem
b. Business Logic Layer
- Core domain: com.example.banksystem (Account, Transaction, Login, MainClass)
- Loan module: com.example.LoanPackage (LoanFactory, specific loan types, Iterator for requests)
- UserFactory: com.example.UserFactory (FactoryUser, Client, Staff)
- Generator: com.example.Generator (IdGenerator, PasswordGenerator)
c. Data Access Layer
- Package: com.example.dataBase
- DataBase (Singleton), DataBaseMapping, and CRUD helpers (DataBaseReader, DataBaseWriter, DataBaseUpdater)
d. External Integrations
- Email API: com.example.Api.EmailApi (AuthenticationEmail, Email, NotifierEmail)
- Currency Converter API: com.example.Api.currencyConverter (CurrencyApi, URLBuilder)
e. Notification Observer
- Package: com.example.NotificationsObserver
- Observer pattern classes (Subject, NotificationBuilder, EmailNotification, DesktopNotification, etc.)

##### Relationships and Data Flows
- User → GUI Controller → Business Logic
- Business Logic → Data Access Layer → MySQL (DB)
- Business Logic → External APIs (Email sending, Currency conversion)
- Business Logic publishes events to Subject → Observer classes send notifications
- Sequence: e.g., “Transfer money” use case → MoneyTransferController calls Transaction in business logic → DataBaseUpdater commits → Subject notifies observers → NotifierEmail or DesktopNotification sends update

##### Architectural Patterns & Design Principles
- Factory: UserFactory creates Client or Staff; LoanFactory produces different Loan types
- Singleton: DataBase class ensures single DB connection
- Observer: NotificationsObserver implements pub-sub for events
- MVC-like separation: FXML (View), Controllers (Controller), Domain classes (Model)

##### Technologies & Frameworks
- JavaFX for UI (FXML + Controllers)
- Java 11+ modules (module-info.java)
- JDBC/MySQL via custom DataBaseMapping
- External REST calls for currency (CurrencyApi)
- JavaMail (or custom) for email notifications

##### Final Checklist
- Layered view: Presentation, Business Logic, Data Access, External Services
- Annotations for applied design patterns (Factory, Singleton, Observer)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        GUIControllers["GUI Controllers"]:::presentation
        FXMLResources["FXML Views & CSS"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        Domain["Core Domain\n(Account, Transaction, Login, MainClass)"]:::business
        LoanModule["Loan Module\n(LoanFactory, Loans, Iterator)"]:::business
        UserFactoryModule["UserFactory\n(FactoryUser, Client, Staff)"]:::business
        GeneratorModule["Generator\n(IdGenerator, PasswordGenerator)"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DBSingleton["DataBase (Singleton)"]:::data
        DBMapping["DataBaseMapping"]:::data
        CRUD["CRUD Helpers\n(Reader, Writer, Updater)"]:::data
        MySQL[(MySQL Database)]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        EmailAPI["Email API\n(AuthenticationEmail, Email, NotifierEmail)"]:::external
        CurrencyAPI["Currency Converter API\n(CurrencyApi, URLBuilder)"]:::external
    end

    %% Observer / Notification
    subgraph "Notification Observer"
        direction TB
        Subject["Subject"]:::observer
        NotificationBuilder["NotificationBuilder"]:::observer
        EmailNotification["EmailNotification"]:::observer
        DesktopNotification["DesktopNotification"]:::observer
        SendHelper["SendNotificationHelper"]:::observer
    end

    %% User
    User["User"]:::user

    %% Connections
    User -->|"interacts with"| GUIControllers
    GUIControllers -->|"calls controllers"| Domain
    GUIControllers -->|"loads views"| FXMLResources

    Domain -->|"uses"| DBSingleton
    LoanModule -->|"uses Factory"| Domain
    UserFactoryModule -->|"creates users"| Domain
    GeneratorModule -->|"generates IDs/passwords"| Domain

    DBSingleton --> DBMapping
    DBMapping --> CRUD
    CRUD --> MySQL

    Domain -->|"sends events to"| Subject
    Subject --> NotificationBuilder
    NotificationBuilder --> EmailNotification
    NotificationBuilder --> DesktopNotification
    EmailNotification --> SendHelper
    DesktopNotification --> SendHelper

    Domain --> EmailAPI
    Domain --> CurrencyAPI

    %% Click Events - Presentation
    click GUIControllers "https://github.com/salahashraf253/banksystem/tree/main/src/main/java/com/example/GUI"
    click FXMLResources "https://github.com/salahashraf253/banksystem/tree/main/src/main/resources/com/example/banksystem"

    click GUIControllers "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/GUI/LoginFormController.java"
    click GUIControllers "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/GUI/HomeController.java"
    click GUIControllers "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/GUI/MoneyTransferController.java"

    %% Click Events - Business
    click Domain "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/banksystem/Account/Account.java"
    click Domain "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/banksystem/Transaction.java"
    click Domain "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/banksystem/Login.java"
    click Domain "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/banksystem/MainClass.java"

    click LoanModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/LoanPackage/Loan/LoanFactory.java"
    click LoanModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/LoanPackage/Loan/EducationalLoan.java"
    click LoanModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/LoanPackage/Loan/HomeLoan.java"
    click LoanModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/LoanPackage/Loan/PersonalLoan.java"
    click LoanModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/LoanPackage/LoanIterator/Iterator.java"
    click LoanModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/LoanPackage/LoanIterator/LoanRequestsIterator.java"

    click UserFactoryModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/UserFactory/FactoryUser.java"
    click UserFactoryModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/UserFactory/Client.java"
    click UserFactoryModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/UserFactory/Staff.java"

    click GeneratorModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Generator/IdGenerator.java"
    click GeneratorModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Generator/PasswordGenerator.java"
    click GeneratorModule "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Generator/Generator.java"

    %% Click Events - Data Access
    click DBSingleton "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/dataBase/DataBase.java"
    click DBMapping "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/dataBase/DataBaseMapping.java"
    click CRUD "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/dataBase/Functions/DataBaseReader.java"
    click CRUD "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/dataBase/Functions/DataBaseWriter.java"
    click CRUD "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/dataBase/Functions/DataBaseUpdater.java"

    %% Click Events - External Services
    click EmailAPI "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Api/EmailApi/AuthenticationEmail.java"
    click EmailAPI "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Api/EmailApi/Email.java"
    click EmailAPI "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Api/EmailApi/NotifierEmail.java"

    click CurrencyAPI "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Api/currencyConverter/CurrencyApi.java"
    click CurrencyAPI "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/Api/currencyConverter/URLBuilder.java"

    %% Click Events - Observer
    click Subject "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/NotificationsObserver/Subject.java"
    click NotificationBuilder "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/NotificationsObserver/NotificationBuilder.java"
    click EmailNotification "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/NotificationsObserver/EmailNotification.java"
    click DesktopNotification "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/NotificationsObserver/DesktopNotification.java"
    click SendHelper "https://github.com/salahashraf253/banksystem/blob/main/src/main/java/com/example/NotificationsObserver/SendNotificationHelper.java"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef business fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef observer fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef user fill:#FFFFFF,stroke:#000,stroke-width:1px,stroke-dasharray: 2 2
```
