A backend REST API application built with Java Spring Boot for expense tracking, featuring expense management, categorization, and comprehensive statistics endpoints.
- RESTful API with full CRUD operations
- SQLite database for data persistence
- Expense and Category management
- Comprehensive statistics endpoints:
- Total expenses
- Average expense
- Daily statistics
- Monthly statistics
- Category-based statistics
- Java 21
- Spring Boot 3.5.7
- Spring Data JPA
- SQLite Database
- Maven
expense-tracker/
└── backend/
└── expense-tracker/
├── src/
│ └── main/
│ ├── java/com/example/expense_tracker/
│ │ ├── model/ # Entity classes
│ │ ├── repository/ # Data access layer
│ │ ├── service/ # Business logic
│ │ └── controller/ # REST endpoints
│ └── resources/
│ └── application.properties
└── pom.xml
- Java 21 or higher
- Maven
- Navigate to the backend directory:
cd backend/expense-tracker- Build the project:
./mvnw clean install- Run the Spring Boot application:
./mvnw spring-boot:runThe backend server will start on http://localhost:8080
GET /api/categories- Get all categoriesGET /api/categories/{id}- Get category by IDPOST /api/categories- Create new categoryPUT /api/categories/{id}- Update categoryDELETE /api/categories/{id}- Delete category
GET /api/expenses- Get all expensesGET /api/expenses/{id}- Get expense by IDPOST /api/expenses- Create new expensePUT /api/expenses/{id}- Update expenseDELETE /api/expenses/{id}- Delete expenseGET /api/expenses/category/{categoryId}- Get expenses by category
GET /api/expenses/statistics- Get overall statistics (total, average)GET /api/expenses/statistics/daily- Get today's statisticsGET /api/expenses/statistics/monthly- Get current month's statisticsGET /api/expenses/statistics/by-category- Get expenses grouped by category
Use the REST API endpoints to:
- Create Categories: Create expense categories (e.g., Food, Transport, Entertainment)
- Add Expenses: Add expenses with description, amount, and category
- Filter Expenses: Query expenses by specific categories
- View Statistics: Get statistics on your spending including total, average, daily, and monthly summaries
- Manage Data: Update or delete expenses and categories as needed
The application uses SQLite database which is automatically created as expense_tracker.db in the backend project root directory when you first run the application.
- CRUD operations for expenses (description, amount, category)
- Retrieve all expenses with timestamps
- Filter expenses by category
- Get individual expense by ID
- CRUD operations for categories (name, description)
- Retrieve all categories
- Unique category names enforced
- Cascade deletion (deleting a category removes associated expenses)
- Overall statistics (total expenses, average expense)
- Daily expense tracking
- Monthly expense tracking
- Category-based expense grouping
The backend uses Spring Boot with JPA/Hibernate for database operations. SQLite dialect is configured for compatibility.