Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Finance Dashboard Backend

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.


🚀 Tech Stack

  • Backend: Spring Boot (Java)
  • Database: MySQL
  • ORM: Spring Data JPA (Hibernate)
  • Testing Tool: Postman

📌 Features

1. User & Role Management

  • Create and manage users
  • Assign roles (ADMIN, ANALYST, VIEWER)
  • Role-based access control implemented using request headers

2. Financial Records Management

  • Create, view, and delete financial records

  • Fields include:

    • Amount
    • Type (INCOME / EXPENSE)
    • Category
    • Date
  • Supports filtering by:

    • Type
    • Category
    • Date range

3. Dashboard Summary

  • Total income
  • Total expenses
  • Net balance

🔐 Access Control

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

📡 API Endpoints

👤 Users

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

💰 Records

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

🧪 Sample Requests

Create Record

{
  "amount": 5000,
  "type": "INCOME",
  "category": "Salary",
  "date": "2026-04-01",
  "user": {
    "id": 1
  }
}

Summary Response

{
  "totalIncome": 5000,
  "totalExpense": 2000,
  "netBalance": 3000
}

⚙️ Setup Instructions

  1. Clone the repository

  2. Configure MySQL database:

    CREATE DATABASE finance_db;
  3. Update application.properties:

    spring.datasource.url=jdbc:mysql://localhost:3306/finance_db
    spring.datasource.username=root
    spring.datasource.password=your_password
    
  4. Run the application

  5. Test APIs using Postman


💡 Design Decisions

  • 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

⚠️ Assumptions

  • Roles are predefined in the database
  • Authentication is mocked using request headers
  • Categories are flexible (not restricted to fixed values)

📌 Future Improvements

  • Add JWT authentication
  • Add update APIs
  • Pagination and search
  • Category-wise analytics
  • Better exception handling (global handler)

✅ Conclusion

The project focuses on clean structure, proper separation of concerns, and correct implementation of backend logic rather than unnecessary complexity.

About

Backend system for managing financial records with role-based access control, filtering, and dashboard analytics.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages