Simple REST API built using Spring Boot, Spring Data JPA, and PostgreSQL.
- CRUD operations for expenses
- Get expense by ID
- Get total expense count
- Get total amount grouped by category
- Java
- Spring Boot
- Spring Data JPA
- PostgreSQL
- src/main/java/com/prac/practice
- controller
- service
- repository
- entity
- PracticeApplication.java
- Clone the repository
- Create PostgreSQL database named
expense_db - Update credentials in
application.properties - Mainly password from
application.properties - Run the application with: mvn spring-boot:run
- Base URL: http://localhost:8080/expenses
The following operations can be tested using Postman.
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /expenses | Create an expense |
| GET | /expenses | Get all expenses |
| GET | /expenses/id/{id} | Get expense by ID |
| PUT | /expenses/id/{id} | Update an expense |
| DELETE | /expenses/id/{id} | Delete an expense |
| GET | /expenses/count | Get total number of expenses |
| GET | /expenses/total-by-category | Get total amount grouped by category |
{ "title": "Coffee", "category": "Food", "amount": 120 }