Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’° Vaultify

Secure Finance Data Processing Backend

πŸ” Role-Based Access Control β€’ πŸ“Š Analytics β€’ ⚑ Spring Boot


πŸš€ Overview

Vaultify is a backend system for managing financial records with strict role-based access control and analytics capabilities.

It is designed to simulate a real-world system where:

  • users have different levels of access
  • data ownership is enforced
  • admins control system-wide operations

πŸ‘₯ Role-Based Access Model

Role Access Level
VIEWER Can view only their own records and personal dashboard
ANALYST Can view all records globally and global dashboard analytics
ADMIN Full access: create, update, delete records and manage users

✨ Features

πŸ‘€ User Management

  • Admin-only user creation
  • Role assignment (VIEWER, ANALYST, ADMIN)
  • Soft delete using active status
  • Password encryption using BCrypt

πŸ’Έ Record Management

  • Create, update, delete financial records (admin-only)
  • Categorization and type (INCOME / EXPENSE)
  • Ownership-based access for viewers
  • Global read access for analysts

πŸ“Š Dashboard Analytics

  • Total income, expenses, and balance
  • Category-wise aggregation
  • Monthly trends
  • Recent transactions

πŸ” Security

  • Spring Security with HTTP Basic Authentication
  • Role-based endpoint protection
  • Service-layer data filtering (user vs global access)
  • Disabled users cannot authenticate

πŸ”‘ Authentication Example

Authorization Header:

Authorization: Basic base64(email:password)

Example:

Authorization: Basic YWRtaW5AdmF1bHRpZnkuY29tOmFkbWluMTIz

gut

🧠 Key Design Decisions

πŸ”Ή 1. Strict Role Separation

  • VIEWER β†’ personal data only
  • ANALYST β†’ read-only global access
  • ADMIN β†’ full control

πŸ”Ή 2. Data-Level Authorization

Even if a user can access an endpoint, the service layer ensures:

  • VIEWER β†’ only their data
  • ANALYST β†’ global data
  • ADMIN β†’ full control

πŸ”Ή 3. Soft Delete Strategy

  • Users are not removed from DB
  • Instead: active = false
  • Integrated with Spring Security (isEnabled())

πŸ”Ή 4. Admin Bootstrapping

  • First admin is auto-created using CommandLineRunner
  • Solves system initialization problem

πŸ”Ή 5. Proper Error Semantics

  • 404 β†’ resource not found
  • 409 β†’ conflict (already exists)
  • 403 β†’ forbidden action
  • 400 β†’ validation error

πŸ— Architecture

Client β†’ Controller β†’ Service β†’ Repository β†’ Database

βš™οΈ How It Works

πŸ” Authentication Flow

  • Spring Security intercepts request
  • User loaded via CustomUserDetailsService
  • Role mapped to ROLE_*
  • Access granted based on role

πŸ’Έ Record Flow

  • Input validated
  • Linked to user
  • Stored in DB
  • Access controlled based on role

πŸ“Š Dashboard Flow

  • Fetch records (user-specific or global)

  • Aggregate:

    • income vs expense
    • category totals
    • monthly trends

🌐 API Endpoints

πŸ‘€ Users (ADMIN only)

POST   /user/create
GET    /user/getAllUser
PUT    /user/update/{id}
PUT    /user/status/{id}

πŸ’Έ Records

POST   /records/create        (ADMIN)
PUT    /records/update/{id}   (ADMIN)
DELETE /records/delete/{id}   (ADMIN)

GET    /records/getAllRecords (VIEWER / ANALYST / ADMIN)
GET    /records/{id}          (VIEWER / ANALYST / ADMIN)
GET    /records/type/{type}
GET    /records/category/{category}

πŸ“Š Dashboard

GET /dashboard/summary
GET /dashboard/category
GET /dashboard/recent
GET /dashboard/monthly
GET /dashboard/category-type

πŸ“₯ Sample Requests

➀ Create User (ADMIN)

{
  "username": "john",
  "email": "john@example.com",
  "password": "1234",
  "role": "ANALYST",
  "dob": "2002-05-10"
}

➀ Create Record (ADMIN)

POST /records/create?userEmail=john@example.com
{
  "amount": 5000,
  "description": "Freelance payment",
  "type": "INCOME",
  "date": "12-04-2026",
  "category": "Salary"
}

➀ Dashboard Response Example

{
  "totalIncome": 50000,
  "totalExpense": 30000,
  "balance": 20000
}

βš™οΈ Setup & Running

βœ… Prerequisites

  • Java 17+
  • Maven 3.8+
  • Database (H2 / MySQL β€” configurable)

βš™οΈ Configuration

Example application.properties:

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.hibernate.ddl-auto=update

server.port=8080

▢️ Run Project

git clone https://github.com/YOUR_USERNAME/Vaultify.git
cd Vaultify
mvn spring-boot:run

πŸ”‘ Default Admin (Auto-created)

Email: admin@vaultify.com
Password: admin123

πŸ“Œ Assumptions

  • HTTP Basic authentication used for simplicity
  • Admin is required to create users and records
  • Users are soft-deleted via active flag
  • VIEWER cannot modify any data
  • ANALYST has read-only global access
  • ADMIN has full control over system
  • Records are linked to users via email during creation
  • Database schema is auto-generated

🚧 Future Improvements

  • πŸ”‘ JWT Authentication
  • πŸ“„ Swagger / OpenAPI documentation
  • πŸ“Š Advanced analytics (yearly trends, forecasting)
  • ☁️ Deployment (Docker + Cloud)
  • πŸ” Advanced filtering & search

πŸ‘¨β€πŸ’» Author

Kaustub (Cos) Backend Developer | Learning System Design πŸš€


⭐ Support

If you like this project, give it a ⭐ on GitHub! g

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages