# mohinik7/budgettracker architecture

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

- Interactive diagram: https://gitdiagram.com/mohinik7/budgettracker
- Repository: https://github.com/mohinik7/budgettracker

## Overview

##### Main Components
- User Interface (UI) Layer: This comprises the Java Swing components (e.g., LoginFrame, BudgetFrame, AccountFrame, etc.) that handle user interactions.
- Business Logic / Controller Layer: This layer ideally processes inputs, leverages validation (via classes like ValidationUtils), and manages workflow between the UI and data access components.
- Data Access Layer: The DAO classes (AccountsDAO, BudgetsDAO, CategoriesDAO, RecordsDAO, UsersDAO) encapsulate interactions with the database.
- Database Layer: The MySQL backend which stores tables such as users, accounts, categories, records, and budgets.
- Database Connection: The DatabaseConnection class is responsible for establishing the JDBC connection between the application and the MySQL database.

##### Relationships and Interactions
- The User Interface (frames) communicates with the Business Logic layer to process users’ commands (e.g., log in, record a transaction, set a budget).
- The Business Logic layer calls the Data Access Objects (DAO) to retrieve or persist data.
- Data access operations rely on the DatabaseConnection to execute queries against the MySQL database.
- There is also a configuration and initialization process outlined in the README (e.g., setting up the database and establishing the connection).

##### Architectural Patterns and Technologies
- That the project uses the DAO pattern for data management, ensuring separation of concerns between business logic and database operations.
- The UI is built using Java Swing; thus, associate all *Frame classes (e.g., LoginFrame, DashboardFrame) with the presentation layer.
- The interplay between UI, Validations (ValidationUtils), and the DAOs should be captured clearly.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer (Java Swing)"
        UI1["LoginFrame"]:::ui
        UI2["BudgetFrame"]:::ui
        UI3["AccountFrame"]:::ui
        UI4["DashboardFrame"]:::ui
        UI5["RegisterFrame"]:::ui
        UI6["RecordFrame"]:::ui
        UI7["AddBudgetDialog"]:::ui
        UI8["UpdateBudgetDialog"]:::ui
    end

    subgraph "Business Logic Layer"
        BL1["ValidationUtils"]:::business
        BL2["UIConstants"]:::business
    end

    subgraph "Data Access Layer (DAO Pattern)"
        DAO1["AccountsDAO"]:::dao
        DAO2["BudgetsDAO"]:::dao
        DAO3["CategoriesDAO"]:::dao
        DAO4["RecordsDAO"]:::dao
        DAO5["UsersDAO"]:::dao
    end

    subgraph "Database Connectivity"
        DBConn["DatabaseConnection"]:::db
        MySQL["MySQL Database"]:::db
    end

    %% Connections
    UI4 -->|"triggers"| BL1
    BL1 -->|"calls"| DAO1
    DAO1 -->|"queries via"| DBConn
    DBConn -->|"executes on"| MySQL

    %% Click Events for UI Layer
    click UI1 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/LoginFrame.java"
    click UI2 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/BudgetFrame.java"
    click UI3 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/AccountFrame.java"
    click UI4 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/DashboardFrame.java"
    click UI5 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/RegisterFrame.java"
    click UI6 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/RecordFrame.java"
    click UI7 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/AddBudgetDialog.java"
    click UI8 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/UpdateBudgetDialog.java"

    %% Click Events for Business Logic Layer
    click BL1 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/ValidationUtils.java"
    click BL2 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/UIConstants.java"

    %% Click Events for Data Access Layer
    click DAO1 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/AccountsDAO.java"
    click DAO2 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/BudgetsDAO.java"
    click DAO3 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/CategoriesDAO.java"
    click DAO4 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/RecordsDAO.java"
    click DAO5 "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/UsersDAO.java"

    %% Click Event for Database Connection
    click DBConn "https://github.com/mohinik7/budgettracker/blob/main/src/dbms_minip/DatabaseConnection.java"

    %% Styles
    classDef ui fill:#FFF2CC,stroke:#D79B00,stroke-width:2px;
    classDef business fill:#CCE5FF,stroke:#4D8CC7,stroke-width:2px;
    classDef dao fill:#DFF0D8,stroke:#5CB85C,stroke-width:2px;
    classDef db fill:#F2DEDE,stroke:#D9534F,stroke-width:2px;
```
