# yassinean/gestion_budget architecture

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

- Interactive diagram: https://gitdiagram.com/yassinean/gestion_budget
- Repository: https://github.com/yassinean/gestion_budget

## Overview

1. **System type and runtime**
   - This is a **desktop JavaFX application** built with **Java 17** and **Maven**, not a web app.
   - It connects directly to **PostgreSQL** for persistence; there is no separate backend service or HTTP API.

2. **Application entry and modular boundary**
   - The app starts through `Launcher` / `HelloApplication`, with `module-info.java` defining the Java module boundary.
   - The initial UI is loaded from FXML resources under `src/main/resources/com/ba/budgetapp/Views`.

3. **Presentation layer**
   - The UI is organized around JavaFX controllers in `com.ba.budgetapp.controllers`:
     - `LoginController`, `RegisterController`, `ProfileController`
     - `BudgetController`, `CategoriesController`, `TransactionController`
     - `DashboardController`, `MainController`
   - Each controller owns one screen or a major UI region and is paired with an FXML view file.

4. **Navigation and session state**
   - `MainController` and `NavigationUtil` are the key UI composition/navigation pieces.
   - `SessionManager` holds the current logged-in user state so that authenticated screens can operate on the active account.

5. **Domain model**
   - Core business entities live in `com.ba.budgetapp.models.entities`:
     - `Account`, `Budget`, `Category`, `Transaction`
     - `TransactionType` for income vs expense classification
     - `TransactionView` for a UI-friendly projection used in lists/tables or reporting
   - These entities represent the data passed between UI, services, and persistence.

6. **Service layer and business rules**
   - Business logic is separated into service interfaces and implementations under `services.Interface` and `services.Impl`.
   - Main services include:
     - `AccountService`
     - `BudgetService`
     - `CategoryService`
     - `TransactionService`
     - `DashboardService` / `StatisticsService`
   - `DuplicateResourceException` indicates service-level validation for unique constraints such as duplicate names or records.

7. **Persistence layer**
   - Data access is abstracted by DAO interfaces in `models.DAO.Interface` and implemented in `models.DAO.Impl`.
   - `BaseDAO` likely centralizes shared JDBC CRUD logic, while `AccountDAOImpl`, `BudgetDAOImpl`, `CategoryDAOImpl`, and `TransactionDAOImpl` handle table-specific queries.
   - `DatabaseConnection` and `DatabaseConfig` provide the JDBC connection setup.

8. **Database and schema boundary**
   - The repository includes `budget_db.sql`, which defines the PostgreSQL schema and is part of the deployment/data setup boundary.
   - `src/main/resources/database.properties` externalizes connection settings, keeping the app configurable without code changes.

9. **Main data flow**
   - Typical flow is: **FXML view → controller → service → DAO → PostgreSQL → entity/view model → controller → JavaFX view**.
   - Authentication screens create or validate accounts, then the session state unlocks budget, category, transaction, and dashboard operations.

10. **Analytics and dashboard**
   - The dashboard is a separate functional subsystem, not just a UI page.
   - It aggregates income, expenses, balance, transaction counts, and category/monthly breakdowns for charts, likely using `DashboardService` and `StatisticsService`.

11. **Resources and styling**
   - UI assets are packaged in `src/main/resources/com/ba/budgetapp/Views` and `CSS/style.css`.
   - This makes the visual layer self-contained inside the desktop client.

12. **Architecture summary**
   - Overall, the repo follows a **layered MVC-style desktop architecture**:
     - **Controllers** orchestrate screens and user actions
     - **Services** enforce business rules
     - **DAOs** isolate database access
     - **Entities** carry domain data
     - **JavaFX FXML/CSS** define the presentation layer
   - The main architectural boundary is between the JavaFX client and the PostgreSQL database, with no networked middle tier.

Main entry points: [`src/main/resources/com/ba/budgetapp/Views/MainLayout.fxml`](https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/com/ba/budgetapp/Views/MainLayout.fxml) (FXML views), [`src/main/java/com/ba/budgetapp/models/DAO/Impl/AccountDAOImpl.java`](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/DAO/Impl/AccountDAOImpl.java) (DAOs), [`src/main/java/com/ba/budgetapp/models/entities/Account.java`](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/entities/Account.java) (Entities), [`src/main/java/com/ba/budgetapp/controllers/BudgetController.java`](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/BudgetController.java) (Budget screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap & module"]
  node_launcher(("Launcher<br/>entrypoint<br/>[Launcher.java]"))
  node_app["App"]
  node_module["Module info<br/>module boundary<br/>[module-info.java]"]
end

subgraph group_presentation["JavaFX UI"]
  node_mainctl["Main view<br/>ui shell"]
  node_nav["Navigation<br/>ui util"]
  node_session["Session<br/>auth state"]
  node_authctl["Auth screens<br/>controllers"]
  node_budgetctl["Budget screens<br/>controllers"]
  node_transctl["Transactions<br/>controllers"]
  node_dashctl["Dashboard<br/>analytics ui"]
end

subgraph group_domain["Domain model"]
  node_entities[("Entities<br/>domain model<br/>[Account.java]")]
end

subgraph group_service["Services"]
  node_acctsvc["Account svc"]
  node_budsvc["Budget svc"]
  node_catsvc["Category svc"]
  node_transsvc["Transaction svc"]
  node_dashsvc["Stats svc<br/>analytics service"]
  node_dup{{"Duplicate rule<br/>service error"}}
end

subgraph group_persistence["Persistence"]
  node_basedao["Base DAO<br/>jdbc base<br/>[BaseDAO.java]"]
  node_daos["DAOs<br/>data access"]
  node_dbconn["DB config<br/>jdbc setup"]
end

subgraph group_resources["Resources & schema"]
  node_fxml["FXML views<br/>ui resources<br/>[MainLayout.fxml]"]
  node_css["Styles<br/>ui resource<br/>[style.css]"]
  node_dbprops["DB props<br/>config resource"]
  node_schema[("Schema<br/>[budget_db.sql]")]
end

node_launcher -->|"starts"| node_app
node_app -->|"runs in"| node_module
node_app -->|"loads UI"| node_fxml
node_fxml -->|"binds"| node_mainctl
node_fxml -->|"binds"| node_authctl
node_fxml -->|"binds"| node_budgetctl
node_fxml -->|"binds"| node_transctl
node_fxml -->|"binds"| node_dashctl
node_mainctl -->|"navigates"| node_nav
node_authctl -->|"sets user"| node_session
node_budgetctl -->|"reads user"| node_session
node_transctl -->|"reads user"| node_session
node_dashctl -->|"reads user"| node_session
node_authctl -->|"calls"| node_acctsvc
node_budgetctl -->|"calls"| node_budsvc
node_budgetctl -->|"calls"| node_catsvc
node_transctl -->|"calls"| node_transsvc
node_dashctl -->|"calls"| node_dashsvc
node_acctsvc -->|"uses"| node_daos
node_budsvc -->|"uses"| node_daos
node_catsvc -->|"uses"| node_daos
node_transsvc -->|"uses"| node_daos
node_dashsvc -->|"reads"| node_daos
node_daos -->|"extends"| node_basedao
node_basedao -->|"connects"| node_dbconn
node_dbconn -->|"configures"| node_dbprops
node_dbconn -->|"targets"| node_schema
node_acctsvc -->|"raises"| node_dup
node_budsvc -->|"raises"| node_dup
node_catsvc -->|"raises"| node_dup
node_transsvc -->|"maps"| node_entities
node_acctsvc -->|"maps"| node_entities
node_budsvc -->|"maps"| node_entities
node_catsvc -->|"maps"| node_entities
node_dashsvc -->|"aggregates"| node_entities
node_css -->|"styles"| node_fxml

click node_launcher "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/Launcher.java"
click node_app "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/HelloApplication.java"
click node_module "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/module-info.java"
click node_mainctl "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/MainController.java"
click node_nav "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/utils/NavigationUtil.java"
click node_session "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/utils/SessionManager.java"
click node_authctl "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/LoginController.java"
click node_budgetctl "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/BudgetController.java"
click node_transctl "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/TransactionController.java"
click node_dashctl "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/DashboardController.java"
click node_entities "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/entities/Account.java"
click node_acctsvc "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/AccountServiceImpl.java"
click node_budsvc "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/BudgetServiceImpl.java"
click node_catsvc "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/CategoryServiceImpl.java"
click node_transsvc "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/TransactionServiceImpl.java"
click node_dashsvc "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/DashboardServiceImpl.java"
click node_dup "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/DuplicateResourceException.java"
click node_basedao "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/DAO/BaseDAO.java"
click node_daos "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/DAO/Impl/AccountDAOImpl.java"
click node_dbconn "https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/config/DatabaseConnection.java"
click node_fxml "https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/com/ba/budgetapp/Views/MainLayout.fxml"
click node_css "https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/com/ba/budgetapp/CSS/style.css"
click node_dbprops "https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/database.properties"
click node_schema "https://github.com/yassinean/gestion_budget/blob/main/budget_db.sql"

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_launcher,node_app,node_module toneBlue
class node_mainctl,node_nav,node_session,node_authctl,node_budgetctl,node_transctl,node_dashctl toneAmber
class node_entities toneMint
class node_acctsvc,node_budsvc,node_catsvc,node_transsvc,node_dashsvc,node_dup toneRose
class node_basedao,node_daos,node_dbconn toneIndigo
class node_fxml,node_css,node_dbprops,node_schema toneTeal
```

## Components

### Bootstrap & module

Application entry points and module boundary.

- [Launcher](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/Launcher.java): entrypoint · JVM launch class for the desktop app. · `src/main/java/com/ba/budgetapp/Launcher.java`
- [App](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/HelloApplication.java): javafx app · JavaFX application bootstrap and primary stage setup. · `src/main/java/com/ba/budgetapp/HelloApplication.java`
- [Module info](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/module-info.java): module boundary · Java module descriptor defining exported and required modules. · `src/main/java/module-info.java`

### JavaFX UI

Controllers, navigation, session state, and packaged views.

- [Main view](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/MainController.java): ui shell · Main layout controller coordinating screen composition. · `src/main/java/com/ba/budgetapp/controllers/MainController.java`
- [Navigation](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/utils/NavigationUtil.java): ui util · Screen switching and view loading helper. · `src/main/java/com/ba/budgetapp/utils/NavigationUtil.java`
- [Session](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/utils/SessionManager.java): auth state · Holds the active logged-in user context. · `src/main/java/com/ba/budgetapp/utils/SessionManager.java`
- [Auth screens](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/LoginController.java): controllers · Login, registration, and profile controllers. · `src/main/java/com/ba/budgetapp/controllers/LoginController.java`
- [Budget screens](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/BudgetController.java): controllers · Budget and category management controllers. · `src/main/java/com/ba/budgetapp/controllers/BudgetController.java`
- [Transactions](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/TransactionController.java): controllers · Transaction entry and listing controller. · `src/main/java/com/ba/budgetapp/controllers/TransactionController.java`
- [Dashboard](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/controllers/DashboardController.java): analytics ui · Dashboard controller for summaries and charts. · `src/main/java/com/ba/budgetapp/controllers/DashboardController.java`

### Domain model

Business entities and UI-facing projections.

- [Entities](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/entities/Account.java): domain model · Core account, budget, category, transaction, and projection types. · `src/main/java/com/ba/budgetapp/models/entities/Account.java`

### Services

Business rules and analytics orchestration.

- [Account svc](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/AccountServiceImpl.java): service · Account registration and validation logic. · `src/main/java/com/ba/budgetapp/services/Impl/AccountServiceImpl.java`
- [Budget svc](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/BudgetServiceImpl.java): service · Budget business rules and persistence coordination. · `src/main/java/com/ba/budgetapp/services/Impl/BudgetServiceImpl.java`
- [Category svc](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/CategoryServiceImpl.java): service · Category management and duplicate checks. · `src/main/java/com/ba/budgetapp/services/Impl/CategoryServiceImpl.java`
- [Transaction svc](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/TransactionServiceImpl.java): service · Transaction creation, lookup, and classification logic. · `src/main/java/com/ba/budgetapp/services/Impl/TransactionServiceImpl.java`
- [Stats svc](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/DashboardServiceImpl.java): analytics service · Dashboard aggregation and statistics computation. · `src/main/java/com/ba/budgetapp/services/Impl/DashboardServiceImpl.java`
- [Duplicate rule](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/services/Impl/DuplicateResourceException.java): service error · Signals duplicate-resource validation failures. · `src/main/java/com/ba/budgetapp/services/Impl/DuplicateResourceException.java`

### Persistence

DAO layer and JDBC connection setup.

- [Base DAO](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/DAO/BaseDAO.java): jdbc base · Shared CRUD and JDBC support for DAO implementations. · `src/main/java/com/ba/budgetapp/models/DAO/BaseDAO.java`
- [DAOs](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/models/DAO/Impl/AccountDAOImpl.java): data access · Account, budget, category, and transaction DAO implementations. · `src/main/java/com/ba/budgetapp/models/DAO/Impl/AccountDAOImpl.java`
- [DB config](https://github.com/yassinean/gestion_budget/blob/main/src/main/java/com/ba/budgetapp/config/DatabaseConnection.java): jdbc setup · Connection creation and database configuration helpers. · `src/main/java/com/ba/budgetapp/config/DatabaseConnection.java`

### Resources & schema

FXML, styling, configuration, and database schema assets.

- [FXML views](https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/com/ba/budgetapp/Views/MainLayout.fxml): ui resources · Packaged JavaFX layouts for login, main, and feature screens. · `src/main/resources/com/ba/budgetapp/Views/MainLayout.fxml`
- [Styles](https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/com/ba/budgetapp/CSS/style.css): ui resource · Global JavaFX styling for the desktop client. · `src/main/resources/com/ba/budgetapp/CSS/style.css`
- [DB props](https://github.com/yassinean/gestion_budget/blob/main/src/main/resources/database.properties): config resource · Externalized JDBC connection properties. · `src/main/resources/database.properties`
- [Schema](https://github.com/yassinean/gestion_budget/blob/main/budget_db.sql): postgresql schema · Database schema and deployment SQL. · `budget_db.sql`

## Connections

- Launcher → App: starts · Launch class delegates to the JavaFX application.
- App → Module info: runs in · Application is constrained by the module descriptor.
- App → FXML views: loads UI · Initial scenes and layouts are loaded from FXML.
- FXML views → Main view: binds · Main layout and screens are controlled by JavaFX controllers.
- FXML views → Auth screens: binds · Authentication screens are paired with controllers.
- FXML views → Budget screens: binds · Budget and category views are paired with controllers.
- FXML views → Transactions: binds · Transaction views are paired with controllers.
- FXML views → Dashboard: binds · Dashboard view is paired with its controller.
- Main view → Navigation: navigates · Main shell delegates screen changes to the navigation helper.
- Auth screens → Session: sets user · Successful login or register updates active session state.
- Budget screens → Session: reads user · Budget and category actions are scoped to the active account.
- Transactions → Session: reads user · Transaction operations use the current account context.
- Dashboard → Session: reads user · Dashboard aggregates data for the active account.
- Auth screens → Account svc: calls · Authentication and profile actions use account services.
- Budget screens → Budget svc: calls · Budget screen delegates business operations to budget services.
- Budget screens → Category svc: calls · Category management is handled through category services.
- Transactions → Transaction svc: calls · Transaction screen delegates persistence and validation work.
- Dashboard → Stats svc: calls · Dashboard controller requests aggregated metrics.
- Account svc → DAOs: uses · Services persist and fetch data through DAOs.
- Budget svc → DAOs: uses · Budget service depends on DAO implementations.
- Category svc → DAOs: uses · Category service depends on DAO implementations.
- Transaction svc → DAOs: uses · Transaction service depends on DAO implementations.
- Stats svc → DAOs: reads · Dashboard computations read data from persistence.
- DAOs → Base DAO: extends · Concrete DAO classes share common JDBC behavior.
- Base DAO → DB config: connects · DAO base uses the JDBC connection setup.
- DB config → DB props: configures · Connection settings are externalized in properties.
- DB config → Schema: targets · Application data is stored in the PostgreSQL schema.
- Account svc → Duplicate rule: raises · Duplicate detection is surfaced as a service-level exception.
- Budget svc → Duplicate rule: raises · Budget operations enforce uniqueness constraints.
- Category svc → Duplicate rule: raises · Category operations enforce uniqueness constraints.
- Transaction svc → Entities: maps · Transactions are transformed to and from domain entities.
- Account svc → Entities: maps · Account business logic operates on domain entities.
- Budget svc → Entities: maps · Budget business logic operates on domain entities.
- Category svc → Entities: maps · Category business logic operates on domain entities.
- Stats svc → Entities: aggregates · Statistics and dashboard metrics are derived from entities.
- Styles → FXML views: styles · Packaged stylesheet supports the JavaFX layouts.
