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.
- 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
| 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 |
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)
git clone https://github.com/siby369/expense-tracker-Maven.git
cd expense-tracker-MavenCreate 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
);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";mvn clean installOption 1: Using Maven
mvn exec:javaOption 2: Using the JAR file
java -jar target/expense-tracker-0.0.1-SNAPSHOT.jar- Navigate to the Categories tab
- Enter a Category Name (required)
- Add a Description (optional)
- Click Add Category
- Select a category from the table
- Modify the name or description
- Click Update Category
- Select a category from the table
- Click Delete Category
- Confirm the deletion (Note: This will also delete all associated expenses)
- Navigate to the Expenses tab
- Enter a Title (required)
- Add a Description (optional)
- Enter the Amount (required, decimal format)
- Select a Category from the dropdown
- Click Add Expense
- Select an expense from the table
- Modify the title, description, amount, or category
- Click Update Expense
- Select an expense from the table
- Click Delete Expense
- Confirm the deletion
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
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
- Expense - Represents an expense with title, description, amount, category reference, and timestamps
- Category - Represents an expense category with name, description, and timestamps
- ExpenseTrackerDAO - Handles all database operations for expenses and categories
- ExpenseTrackerGUI - Main application window with tabbed interface for categories and expenses
| 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 |
| 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-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
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
siby369
- GitHub: @siby369
- Java Swing Documentation
- MySQL Documentation
- Maven Central Repository
- Ensure MySQL server is running
- Verify database credentials in
DatabaseConnection.java - Check if the database and tables are created correctly
- Ensure Java 17 is installed and configured
- Run
mvn cleanbefore building - Check Maven installation with
mvn --version
- Verify the main class is set correctly in
pom.xml - Check console for error messages
- Ensure all dependencies are properly installed
If you encounter any issues or have questions, please open an issue on GitHub.