Expense-Tracker is a simple web application that helps users track their expenses and incomes. It allows users to categorize their expenses, view their spending history, and set monthly budgets. Built with Java Spring Boot and PostgreSQL, the app provides a secure and scalable solution for personal financial management.
The Expense-Tracker database diagram visually represents the structure of the database used in the Expense-Tracker application. It outlines the relationships between different entities, such as users, expenses, incomes, and budgets. This diagram serves as a reference for developers and database administrators to understand the data model and facilitate effective database management and development
- Features
- Technologies
- Requirements
- Installation
- Running the Application
- Database Configuration
- API Endpoints
- JWT Authentication
- Swagger Documentation
- Contributing
- License
- User Authentication: Secure login and registration using JWT authentication.
- Expense Management: Add, edit, delete, and view expenses.
- Income Management: Track and manage multiple income sources.
- Expense Categories: Categorize expenses into predefined or custom categories (e.g., groceries, entertainment, utilities).
- Monthly Budgeting: Set and manage monthly budgets for different categories.
- Spending Reports: Visual representation of monthly spending, categorized expenses, and budget adherence.
- Secure API: All sensitive endpoints are protected by JWT tokens to ensure user data security.
- API Documentation: Swagger UI provides a convenient interface for API exploration and testing.
- Java 21
- Spring Boot 3.x
- Spring Data JPA (for ORM)
- Spring Security (for authentication)
- Spring Web (for building RESTful APIs)
- PostgreSQL (for database management)
- JWT (JSON Web Tokens) (for authentication)
- Hibernate (for ORM and database schema management)
- Swagger (SpringFox) (for API documentation)
- Docker (optional, for containerized deployment)
Before you begin, ensure you have the following installed on your system:
- Java 21
- PostgreSQL (version 13 or higher)
- Maven (for managing dependencies)
- Docker (optional, for containerization)
git clone https://github.com/wastech/Expense-Tracker.git
cd expense-tracker
Ensure that PostgreSQL is installed and running on your system. Create a database named Expense_Tracker.
CREATE DATABASE Expense_Tracker;
Update the src/main/resources/application.properties file with your PostgreSQL credentials and other configuration options.
spring.application.name=Expense-Tracker
server.port=8081
# Database Configuration
spring.datasource.url=jdbc:postgresql://localhost:5432/Expense_Tracker
spring.datasource.username=postgres
spring.datasource.password=your_password
spring.datasource.driver-class-name=org.postgresql.Driver
# JPA and Hibernate Settings
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
# JWT Settings
spring.app.jwtSecret=your_jwt_secret
spring.app.jwtExpirationMs=3000000
spring.ecom.app.jwtCookieName=springBootEcom
# Enable Swagger
springfox.documentation.swagger-ui.enabled=true
Use Maven to build the project:
mvn clean install
Start the application using Maven:
mvn spring-boot:run
To run the application with Docker, follow these steps:
# Build the Docker image
docker build -t expense-tracker .
# Run the PostgreSQL container
docker run --name postgres -e POSTGRES_DB=Expense_Tracker -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=your_password -p 5432:5432 -d postgres
# Run the Expense-Tracker container
docker run --name expense-tracker --link postgres -p 8081:8081 -d expense-tracker
The app uses PostgreSQL as the database and Hibernate for ORM. Database schema is managed automatically by Hibernate with the following settings:
- DDL-Auto: update (automatically updates the schema based on entity classes)
- Dialect: PostgreSQLDialect (automatically detects dialect for PostgreSQL)
- POST /auth/register: Register a new user.
- POST /auth/login: Log in and receive a JWT token.
- GET /expenses: List all expenses for the logged-in user.
- POST /expenses: Add a new expense.
- PUT /expenses/{id}: Update an existing expense.
- DELETE /expenses/{id}: Delete an expense.
- GET /income: List all incomes for the logged-in user.
- POST /income: Add new income.
- POST /budget: Set a budget for a specific category.
- GET /budget/{month}: View monthly budget details.
Swagger UI is integrated for exploring the APIs. You can access it at: http://localhost:8081/swagger-ui/index.html
We welcome contributions! To contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Commit your changes
git commit -m 'Add some feature'
4. **Push to the branch:**
```bash git push origin feature-branch
This project is licensed under the MIT License - see the LICENSE file for details.
- Open a pull request. Please ensure your code follows the project standards and includes relevant tests.