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.
- 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.
- Language: Java 11
- Framework: Spring Boot 2.7.x
- Database: MySQL 8.0
- Security: Spring Security & JJWT
- Documentation: Swagger UI / OpenAPI 3.0
- Java 11 SDK installed.
- Maven installed.
- MySQL Server running on localhost:3306.
Create a database named expense_tracker in MySQL:
CREATE DATABASE expense_tracker;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).
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"- Open Run/Debug Configurations.
- Add the following to Environment Variables:
DB_USERNAME=rootDB_PASSWORD=your_passwordJWT_SECRET=your_secret_key
- Click Run.
Once the server is running, access the interactive Swagger UI to test all endpoints: http://localhost:8080/swagger-ui/index.html
Authentication:
- Use
POST /api/auth/signinto get a token. - Click the Authorize button (top right).
- Enter
Bearer <your_token>.
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)