Skip to content

UjjawalPrabhat/expense-tracker-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Expense Tracker API

A production-grade Backend API for tracking personal expenses, built with Spring Boot and MySQL. This project is designed to simulate a real-world financial application with secure authentication, complex queries, and external integrations.

🚀 Features

  • User Management: Secure Sign Up & Login with JWT Authentication.
  • Expense Tracking: CRUD operations for expenses (Title, Amount, Category, Date) with Pagination & Sorting.
  • Advanced Analytics: Monthly spending breakdown by category.
  • Security: Role-based access (RBAC), Rate Limiting (10 req/min), and Stateless Session.
  • Integrations:
    • File Upload: Attach receipts to expenses.
    • Email Notification: (Mock) Welcome emails on registration.
    • Currency Exchange: Real-time USD exchange rates via external API.
  • Performance: Caching support for expense retrieval.

🛠️ Tech Stack

  • Language: Java 11
  • Framework: Spring Boot 2.7.x
  • Database: MySQL 8.0
  • Security: Spring Security & JJWT
  • Documentation: Swagger UI / OpenAPI 3.0

⚙️ Prerequisites

  • Java 11 SDK installed.
  • Maven installed.
  • MySQL Server running on localhost:3306.

📦 Setup & Installation

1. Database Setup

Create a database named expense_tracker in MySQL:

CREATE DATABASE expense_tracker;

2. Configure Credentials

This project uses Environmental Variables for security (Zero hardcoded secrets). You must pass these values when running the application.

  • DB_USERNAME: Your MySQL username (e.g., root)
  • DB_PASSWORD: Your MySQL password.
  • JWT_SECRET: A secure random string (min 32 chars).

▶️ How to Run

Using Maven (Command Line)

Open your terminal in the project root and run:

mvn spring-boot:run "-Dspring-boot.run.arguments=--DB_USERNAME=root --DB_PASSWORD=your_password --JWT_SECRET=your_secret_key"

Using IntelliJ IDEA / Eclipse

  1. Open Run/Debug Configurations.
  2. Add the following to Environment Variables:
    • DB_USERNAME=root
    • DB_PASSWORD=your_password
    • JWT_SECRET=your_secret_key
  3. Click Run.

📖 API Documentation

Once the server is running, access the interactive Swagger UI to test all endpoints: http://localhost:8080/swagger-ui/index.html

Authentication:

  1. Use POST /api/auth/signin to get a token.
  2. Click the Authorize button (top right).
  3. Enter Bearer <your_token>.

📂 Project Structure

src/main/java/com/expensetracker/
├── config/        # Security, Swagger, CORS, RateLimiting
├── controller/    # REST API Endpoints
├── dto/           # Data Transfer Objects
├── model/         # JPA Entities
├── repository/    # Database Access Layer
├── service/       # Business Logic & External Integrations
├── exception/     # Global Error Handling
└── util/          # Helper classes (JWT)

About

A production-grade Spring Boot backend for an Expense Tracker application strictly following MVC architecture. Features secure JWT authentication, complex filtering, analytics, rate limiting, and external API integrations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages