This project is a backend system for managing financial records with role-based access control and basic analytics support. It is designed to simulate a finance dashboard where different users interact with data based on their roles.
- Backend: Spring Boot (Java)
- Database: MySQL
- ORM: Spring Data JPA (Hibernate)
- Testing Tool: Postman
- Create and manage users
- Assign roles (ADMIN, ANALYST, VIEWER)
- Role-based access control implemented using request headers
-
Create, view, and delete financial records
-
Fields include:
- Amount
- Type (INCOME / EXPENSE)
- Category
- Date
-
Supports filtering by:
- Type
- Category
- Date range
- Total income
- Total expenses
- Net balance
Role-based restrictions are enforced at the controller level:
| Role | Permissions |
|---|---|
| VIEWER | View records only |
| ANALYST | View records, filtering, summary |
| ADMIN | Full access (users + records) |
Role is passed via request header:
role: ADMIN
| Method | Endpoint | Description |
|---|---|---|
| POST | /users |
Create user (ADMIN only) |
| GET | /users |
Get all users (ADMIN only) |
| GET | /users/{id} |
Get user by ID |
| DELETE | /users/{id} |
Delete user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /records |
Create record (ADMIN, ANALYST) |
| GET | /records |
Get all records |
| GET | /records/{id} |
Get record by ID |
| DELETE | /records/{id} |
Delete record |
| GET | /records/filter |
Filter records |
| GET | /records/summary |
Dashboard summary |
{
"amount": 5000,
"type": "INCOME",
"category": "Salary",
"date": "2026-04-01",
"user": {
"id": 1
}
}{
"totalIncome": 5000,
"totalExpense": 2000,
"netBalance": 3000
}-
Clone the repository
-
Configure MySQL database:
CREATE DATABASE finance_db;
-
Update
application.properties:spring.datasource.url=jdbc:mysql://localhost:3306/finance_db spring.datasource.username=root spring.datasource.password=your_password -
Run the application
-
Test APIs using Postman
- Used simple role-based access via headers instead of full authentication for simplicity
- Kept entities minimal and focused on required fields
- Used JPA query methods for filtering and JPQL for aggregation
- Service layer handles validation and business logic
- Roles are predefined in the database
- Authentication is mocked using request headers
- Categories are flexible (not restricted to fixed values)
- Add JWT authentication
- Add update APIs
- Pagination and search
- Category-wise analytics
- Better exception handling (global handler)
The project focuses on clean structure, proper separation of concerns, and correct implementation of backend logic rather than unnecessary complexity.