# ezolo/budget-project architecture

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

- Interactive diagram: https://gitdiagram.com/ezolo/budget-project
- Repository: https://github.com/ezolo/budget-project

## Overview

##### Project Type and Purpose
- This is a Java desktop Budget Management Application built with Eclipse.
- It follows an MVC-style pattern: a Swing-based presentation layer (“pages” and custom components), controller/utilities, and a data access layer connecting via JDBC to a MySQL database.
- Purpose: allow users to register/login, create budgets, manage expenses, run saving challenges, and remove subscriptions.

##### File Structure Analysis
- Top-level:
- src/budgetapp/auth – handles user authentication (LoginApp.java)
- src/budgetapp/components – custom Swing fields (LineTextField, LinePasswordField)
- src/budgetapp/controller – shared menu/navigation logic (MenuUtilities.java)
- src/budgetapp/connection – DatabaseConnection.java wraps JDBC logic
- src/budgetapp/pages – one class per screen (AccountsPage, AddRecordPage, AnalysisPage, etc.) plus BaseFrame
- resources – sample data for accounts, categories, records
- DDL.sql/DML.sql – schema and seed data for “budget_management” database

##### README Insights
- The app uses MySQL via JDBC (requires Connector/J).
- Features: user registration/login, budget creation, expense tracking, analysis, challenges, subscription management.
- It’s in development; everything runs in a single desktop client connecting to a remote or local MySQL server.

##### Main Components
a. Presentation Layer (Desktop Client)
- UI Frames & Pages: BaseFrame, LoginApp, RegisterPage, AccountsPage, RecordsPage, AnalysisPage, ChallengesPage, SubscriptionPage, etc.
- Custom UI Components: LineTextField, LinePasswordField
b. Controller / Business Logic
- MenuUtilities (handles navigation, shared UI logic)
- Inline logic within page classes (validation, formatting)
c. Data Access Layer
- DatabaseConnection: opens/closes JDBC connections, executes queries
- DAO-style methods embedded in page classes or a separate DAO package (future refactor)
d. Database Server
- MySQL “budget_management” schema and six tables (users, accounts, categories, records, useraddedcategories, subscriptions)
e. External Dependencies
- MySQL Connector/J driver
- Eclipse settings (for build)

##### Relationships and Interactions
- UI Pages ←→ Controller/Utilities ←→ Data Access Layer ←→ MySQL Database
- On login or register: LoginApp/RegisterPage call DatabaseConnection → users table
- On CRUD operations (accounts, categories, records): Pages call DatabaseConnection → respective tables
- AnalysisPage retrieves aggregated data (GROUP BY queries)
- ChallengesPage and SubscriptionPage use business logic + data queries
- Static resources (CSV or JSON) loaded at startup or for defaults

##### Architectural Patterns & Design Principles
- Layered Architecture (Presentation → Business Logic → Persistence)
- MVC-inspired separation: each “Page” encapsulates its own view & partial controller logic
- Single responsibility for DatabaseConnection (connection pooling or reuse can be added)
- Future extensibility: extract DAOs, services, or move to microservices or web layers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Desktop Client Container
    subgraph "Desktop Client"
        direction TB

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            LoginApp["LoginApp"]:::presentation
            RegisterPage["RegisterPage"]:::presentation
            BaseFrame["BaseFrame"]:::presentation

            subgraph "Pages"
                direction TB
                AccountsPage["AccountsPage"]:::presentation
                AddAccountPage["AddAccountPage"]:::presentation
                EditAccountPage["EditAccountPage"]:::presentation
                CategoriesPage["CategoriesPage"]:::presentation
                AddCategoryPage["AddCategoryPage"]:::presentation
                EditCategoryPage["EditCategoryPage"]:::presentation
                RecordsPage["RecordsPage"]:::presentation
                AddRecordPage["AddRecordPage"]:::presentation
                EditRecordPage["EditRecordPage"]:::presentation
                BudgetPage["BudgetPage"]:::presentation
                AnalysisPage["AnalysisPage"]:::presentation
                ChallengesPage["ChallengesPage"]:::presentation
                SubscriptionPage["SubscriptionPage"]:::presentation
            end

            subgraph "UI Components"
                direction TB
                LineTextField["LineTextField"]:::presentation
                LinePasswordField["LinePasswordField"]:::presentation
            end
        end

        %% Controller Layer
        subgraph "Controller Layer"
            direction TB
            MenuUtilities["MenuUtilities"]:::controller
        end

        %% Data Access Layer
        subgraph "Data Access Layer"
            direction TB
            DatabaseConnection["DatabaseConnection"]:::dataaccess
        end
    end

    %% External Dependencies
    StaticResources["Static Resources (CSV/JSON)"]:::external
    MySQLConnector["MySQL Connector/J"]:::external
    MySQLDB["MySQL Database\n(budget_management schema)"]:::external

    %% Relationships
    LoginApp -->|"render()"| BaseFrame
    BaseFrame -->|"render()"| AccountsPage
    BaseFrame -->|"render()"| RecordsPage
    BaseFrame -->|"render()"| AnalysisPage
    BaseFrame -->|"render()"| ChallengesPage
    BaseFrame -->|"render()"| SubscriptionPage
    RegisterPage -->|"render()"| BaseFrame

    AccountsPage -->|"navigate()"| AddAccountPage
    AccountsPage -->|"navigate()"| EditAccountPage
    CategoriesPage -->|"navigate()"| AddCategoryPage
    CategoriesPage -->|"navigate()"| EditCategoryPage
    RecordsPage -->|"navigate()"| AddRecordPage
    RecordsPage -->|"navigate()"| EditRecordPage

    %% Presentation to Controller
    LoginApp -->|"navigate()"| MenuUtilities
    RegisterPage -->|"navigate()"| MenuUtilities
    BaseFrame -->|"navigate()"| MenuUtilities
    AccountsPage -->|"navigate()"| MenuUtilities
    RecordsPage -->|"navigate()"| MenuUtilities
    AnalysisPage -->|"navigate()"| MenuUtilities
    ChallengesPage -->|"navigate()"| MenuUtilities
    SubscriptionPage -->|"navigate()"| MenuUtilities

    %% Controller to Data Access
    MenuUtilities -->|"executeQuery()"| DatabaseConnection

    %% Direct Data Access calls
    LoginApp -->|"executeQuery()"| DatabaseConnection
    RegisterPage -->|"executeQuery()"| DatabaseConnection
    AccountsPage -->|"executeQuery()"| DatabaseConnection
    CategoriesPage -->|"executeQuery()"| DatabaseConnection
    RecordsPage -->|"executeQuery()"| DatabaseConnection
    AnalysisPage -->|"executeQuery()"| DatabaseConnection
    ChallengesPage -->|"executeQuery()"| DatabaseConnection
    SubscriptionPage -->|"executeQuery()"| DatabaseConnection

    %% Data Access to External
    DatabaseConnection -->|"uses"| MySQLConnector
    MySQLConnector -->|"connect()"| MySQLDB

    %% Static resources loaded
    StaticResources -->|"loadDefaults()"| BaseFrame
    StaticResources -->|"loadDefaults()"| CategoriesPage
    StaticResources -->|"loadDefaults()"| RecordsPage

    %% Click Events
    click LoginApp "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/auth/LoginApp.java"
    click RegisterPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/RegisterPage.java"
    click BaseFrame "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/BaseFrame.java"
    click AccountsPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/AccountsPage.java"
    click AddAccountPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/AddAccountPage.java"
    click EditAccountPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/EditAccountPage.java"
    click CategoriesPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/CategoriesPage.java"
    click AddCategoryPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/AddCategoryPage.java"
    click EditCategoryPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/EditCategoryPage.java"
    click RecordsPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/RecordsPage.java"
    click AddRecordPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/AddRecordPage.java"
    click EditRecordPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/EditRecordPage.java"
    click BudgetPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/BudgetPage.java"
    click AnalysisPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/AnalysisPage.java"
    click ChallengesPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/ChallengesPage.java"
    click SubscriptionPage "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/pages/SubscriptionPage.java"
    click LineTextField "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/components/LineTextField.java"
    click LinePasswordField "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/components/LinePasswordField.java"
    click MenuUtilities "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/controller/MenuUtilities.java"
    click DatabaseConnection "https://github.com/ezolo/budget-project/blob/main/Budget_App/src/budgetapp/connection/DatabaseConnection.java"
    click StaticResources "https://github.com/ezolo/budget-project/tree/main/Budget_App/src/resources/"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#004085,color:#004085
    classDef controller fill:#d4edda,stroke:#155724,color:#155724
    classDef dataaccess fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
