Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Expense Tracker Application

Java Maven MySQL Swing License

A modern, feature-rich desktop Expense Tracker application built with Java Swing and MySQL, designed to help you manage your expenses and budgets efficiently with a clean and intuitive user interface.

Features

  • Category Management - Create, update, and delete expense categories for better organization
  • Expense Tracking - Add, edit, and remove expenses with detailed information
  • CRUD Operations - Complete Create, Read, Update, and Delete functionality for both categories and expenses
  • Table View - Organized display of all expenses and categories with timestamps
  • Inline Editing - Select and edit expenses/categories directly from the table
  • Amount Tracking - Precise decimal amount handling with BigDecimal
  • Persistent Storage - MySQL database integration for reliable data storage
  • Native Look & Feel - System-native UI for a familiar user experience
  • Real-time Updates - Instant refresh and synchronization
  • Timestamp Tracking - Automatic creation and update timestamps for all records

Tech Stack

Technology Version Purpose
Java 17 Core programming language
Maven 3.8+ Build automation and dependency management
MySQL 8.0.33 Database for persistent storage
Swing Built-in GUI framework
JDBC 8.0.33 Database connectivity
Protobuf 3.9.1 Data serialization

Prerequisites

Before running this application, ensure you have the following installed:

  • Java Development Kit (JDK) 17 or higher
  • Apache Maven 3.8 or higher
  • MySQL Server 8.0 or higher
  • Git (for cloning the repository)

Getting Started

1. Clone the Repository

git clone https://github.com/siby369/expense-tracker-Maven.git
cd expense-tracker-Maven

2. Database Setup

Create a MySQL database and configure the connection:

CREATE DATABASE expense_tracker_db;
USE expense_tracker_db;

-- Categories table
CREATE TABLE categories (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL UNIQUE,
    description TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Expenses table
CREATE TABLE expenses (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    description TEXT,
    amount DECIMAL(10, 2) NOT NULL,
    category_id INT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE
);

3. Configure Database Connection

Update the database credentials in src/main/java/com/expense/util/DatabaseConnection.java:

private static final String URL = "jdbc:mysql://localhost:3306/expense_tracker_db";
private static final String USER = "your_username";
private static final String PASSWORD = "your_password";

4. Build the Project

mvn clean install

5. Run the Application

Option 1: Using Maven

mvn exec:java

Option 2: Using the JAR file

java -jar target/expense-tracker-0.0.1-SNAPSHOT.jar

Usage Guide

Managing Categories

Adding a Category

  1. Navigate to the Categories tab
  2. Enter a Category Name (required)
  3. Add a Description (optional)
  4. Click Add Category

Updating a Category

  1. Select a category from the table
  2. Modify the name or description
  3. Click Update Category

Deleting a Category

  1. Select a category from the table
  2. Click Delete Category
  3. Confirm the deletion (Note: This will also delete all associated expenses)

Managing Expenses

Adding an Expense

  1. Navigate to the Expenses tab
  2. Enter a Title (required)
  3. Add a Description (optional)
  4. Enter the Amount (required, decimal format)
  5. Select a Category from the dropdown
  6. Click Add Expense

Updating an Expense

  1. Select an expense from the table
  2. Modify the title, description, amount, or category
  3. Click Update Expense

Deleting an Expense

  1. Select an expense from the table
  2. Click Delete Expense
  3. Confirm the deletion

Project Structure

expense-tracker-Maven/
├── src/
│   └── main/
│       └── java/
│           └── com/
│               └── expense/
│                   ├── Main.java                       # Application entry point
│                   ├── dao/
│                   │   └── ExpenseTrackerDAO.java      # Data Access Object
│                   ├── gui/
│                   │   └── ExpenseTrackerGUI.java      # Swing GUI implementation
│                   ├── model/
│                   │   ├── Category.java               # Category entity model
│                   │   └── Expense.java                # Expense entity model
│                   └── util/
│                       └── DatabaseConnection.java     # Database connection utility
├── pom.xml                                             # Maven configuration
├── .gitignore
└── README.md

Architecture

The application follows a layered architecture pattern:

  • Presentation Layer (gui/) - Swing-based user interface with tabbed panels
  • Business Logic Layer (dao/) - Data access and business operations
  • Data Layer (model/) - Entity models (Expense, Category) and database schema
  • Utility Layer (util/) - Helper classes and database connections

Key Components

Models

  • Expense - Represents an expense with title, description, amount, category reference, and timestamps
  • Category - Represents an expense category with name, description, and timestamps

DAO (Data Access Object)

  • ExpenseTrackerDAO - Handles all database operations for expenses and categories

GUI

  • ExpenseTrackerGUI - Main application window with tabbed interface for categories and expenses

Database Schema

Categories Table

Column Type Constraints
id INT PRIMARY KEY, AUTO_INCREMENT
name VARCHAR(100) NOT NULL, UNIQUE
description TEXT -
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
updated_at TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

Expenses Table

Column Type Constraints
id INT PRIMARY KEY, AUTO_INCREMENT
title VARCHAR(255) NOT NULL
description TEXT -
amount DECIMAL(10, 2) NOT NULL
category_id INT FOREIGN KEY → categories(id)
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
updated_at TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

🔧 Maven Plugins

  • maven-compiler-plugin (3.11.0) - Compiles Java source code with Java 17
  • exec-maven-plugin (3.1.0) - Executes the application via Maven
  • maven-shade-plugin (3.4.1) - Creates executable JAR with all dependencies

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

siby369

Acknowledgments

  • Java Swing Documentation
  • MySQL Documentation
  • Maven Central Repository

Troubleshooting

Database Connection Issues

  • Ensure MySQL server is running
  • Verify database credentials in DatabaseConnection.java
  • Check if the database and tables are created correctly

Build Errors

  • Ensure Java 17 is installed and configured
  • Run mvn clean before building
  • Check Maven installation with mvn --version

GUI Not Appearing

  • Verify the main class is set correctly in pom.xml
  • Check console for error messages
  • Ensure all dependencies are properly installed

Support

If you encounter any issues or have questions, please open an issue on GitHub.


Made with ❤️ by siby369

About

Desktop expense tracking application with category management, built using Java 17, Maven, and MySQL

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages