π Role-Based Access Control β’ π Analytics β’ β‘ Spring Boot
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 | 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 |
- Admin-only user creation
- Role assignment (
VIEWER,ANALYST,ADMIN) - Soft delete using
activestatus - Password encryption using BCrypt
- Create, update, delete financial records (admin-only)
- Categorization and type (INCOME / EXPENSE)
- Ownership-based access for viewers
- Global read access for analysts
- Total income, expenses, and balance
- Category-wise aggregation
- Monthly trends
- Recent transactions
- Spring Security with HTTP Basic Authentication
- Role-based endpoint protection
- Service-layer data filtering (user vs global access)
- Disabled users cannot authenticate
Authorization Header:
Authorization: Basic base64(email:password)
Example:
Authorization: Basic YWRtaW5AdmF1bHRpZnkuY29tOmFkbWluMTIz
gut
- VIEWER β personal data only
- ANALYST β read-only global access
- ADMIN β full control
Even if a user can access an endpoint, the service layer ensures:
- VIEWER β only their data
- ANALYST β global data
- ADMIN β full control
- Users are not removed from DB
- Instead:
active = false - Integrated with Spring Security (
isEnabled())
- First admin is auto-created using
CommandLineRunner - Solves system initialization problem
404β resource not found409β conflict (already exists)403β forbidden action400β validation error
Client β Controller β Service β Repository β Database
- Spring Security intercepts request
- User loaded via
CustomUserDetailsService - Role mapped to
ROLE_* - Access granted based on role
- Input validated
- Linked to user
- Stored in DB
- Access controlled based on role
-
Fetch records (user-specific or global)
-
Aggregate:
- income vs expense
- category totals
- monthly trends
POST /user/create
GET /user/getAllUser
PUT /user/update/{id}
PUT /user/status/{id}
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}
GET /dashboard/summary
GET /dashboard/category
GET /dashboard/recent
GET /dashboard/monthly
GET /dashboard/category-type
{
"username": "john",
"email": "john@example.com",
"password": "1234",
"role": "ANALYST",
"dob": "2002-05-10"
}POST /records/create?userEmail=john@example.com
{
"amount": 5000,
"description": "Freelance payment",
"type": "INCOME",
"date": "12-04-2026",
"category": "Salary"
}{
"totalIncome": 50000,
"totalExpense": 30000,
"balance": 20000
}- Java 17+
- Maven 3.8+
- Database (H2 / MySQL β configurable)
Example application.properties:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.hibernate.ddl-auto=update
server.port=8080git clone https://github.com/YOUR_USERNAME/Vaultify.git
cd Vaultify
mvn spring-boot:runEmail: admin@vaultify.com
Password: admin123
- HTTP Basic authentication used for simplicity
- Admin is required to create users and records
- Users are soft-deleted via
activeflag - 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
- π JWT Authentication
- π Swagger / OpenAPI documentation
- π Advanced analytics (yearly trends, forecasting)
- βοΈ Deployment (Docker + Cloud)
- π Advanced filtering & search
Kaustub (Cos) Backend Developer | Learning System Design π
If you like this project, give it a β on GitHub! g