Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

64 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ ApnaBudget Backend

Java Spring Boot JWT Redis Docker License

A production-style modular monolithic financial management backend system built using Java 21, Spring Boot, Spring Security, JWT Authentication, Redis Cache, Scheduler Automation, Rate Limiting, and MySQL/PostgreSQL persistence.


๐Ÿ“ฑ About ApnaBudget

ApnaBudget is a modern personal finance management platform designed to simplify financial tracking, budget management, savings planning, and financial analytics.

The platform helps users:

  • Track income and expenses
  • Manage monthly budgets
  • Monitor spending patterns
  • Create and manage savings goals
  • Analyze financial trends
  • Receive automated budget alerts
  • Visualize real-time financial insights
  • Maintain better financial discipline

The backend architecture powers a complete financial ecosystem with:

  • Secure JWT authentication
  • Real-time financial calculations
  • Dynamic analytics aggregation
  • Budget monitoring engine
  • Goal reservation system
  • Background automation
  • Redis caching
  • Notification processing
  • Production-style modular architecture

ApnaBudget is designed not only as a CRUD-based application, but as a scalable financial management system demonstrating real-world backend engineering concepts.


๐ŸŒ Live Application

Frontend + Backend Deployment


๐Ÿ—๏ธ System Design Architecture

The backend architecture follows a modular monolithic architecture where all business modules exist inside a single deployable backend application while maintaining clean separation of concerns.

Full System Architecture

diagram-export-5-23-2026-12_29_22-PM

๐Ÿ›๏ธ Architecture Style

Modular Monolithic Architecture

ApnaBudget is designed as a:

Modular Monolithic Backend Application

This means:

  • All modules are deployed together as one backend application.
  • Each module is internally separated using layered architecture.
  • Business domains are isolated into independent services.
  • Shared authentication, scheduler, analytics, and caching systems are used across modules.

๐Ÿง  Internal Architecture Principles

The backend follows:

  • Layered Architecture
  • Modular Domain Separation
  • Stateless JWT Authentication
  • Read-Optimized Analytics Design
  • Scheduler-Based Automation
  • Async Notification Processing
  • Strategy Pattern Based Notification System
  • Redis-Based Caching Layer
  • Financial Aggregation Architecture

๐Ÿ“– Overview

ApnaBudget is a modern financial management backend system built using Spring Boot. The system is designed to help users manage personal finances efficiently through transaction tracking, budget monitoring, goal allocation, financial analytics, automated alerts, and intelligent background processing.

The backend architecture follows a layered and modular design using:

  • Spring Boot
  • Spring Security
  • JWT Authentication
  • Spring Data JPA
  • MySQL
  • Redis Cache
  • Scheduler & Background Jobs
  • Strategy Pattern
  • Dockerized Infrastructure

The system is designed with production-style backend principles such as:

  • Clean layered architecture
  • Separation of concerns
  • Background automation
  • Caching
  • JWT-based stateless authentication
  • Financial analytics aggregation
  • Notification extensibility
  • Domain-driven module separation

โœจ Application Features


๐Ÿ” Authentication & Security

  • User Registration
  • Secure Login System
  • JWT-Based Authentication
  • Stateless Authentication
  • Protected APIs
  • Spring Security Integration
  • Password Encryption
  • Custom Authentication Provider
  • Bucket4j Rate Limiting
  • IP-Based Request Protection

๐Ÿ’ธ Transaction Management

  • Add Income Transactions
  • Add Expense Transactions
  • Transaction History Tracking
  • Category-Based Transactions
  • Payment Type Support
  • Real-Time Balance Updates
  • Weekly Transaction Analysis
  • Latest Transactions Feed

๐Ÿ“Š Budget Management

  • Create Monthly Budgets
  • Category-Specific Budgets
  • Default Budget Support
  • Budget Consumption Tracking
  • Automatic Budget Condition Detection
  • Warning Budget Detection
  • Exceeded Budget Detection
  • Real-Time Budget Updates
  • Budget Alert System

๐ŸŽฏ Goal Management

  • Create Financial Goals
  • Allocate Money To Goals
  • Withdraw Money From Goals
  • Reserved Balance System
  • Goal Progress Tracking
  • Goal Expiry Monitoring
  • Automatic Goal Balance Restoration
  • Goal-Based Financial Planning

๐Ÿ“ˆ Dashboard Analytics

  • Total Balance Analytics
  • Available Balance Tracking
  • Reserved Goal Balance Tracking
  • Income vs Expense Analysis
  • Weekly Financial Comparison
  • Spending Trend Analysis
  • Category-Wise Expense Analysis
  • Budget Utilization Analysis
  • Goal Progress Analytics
  • Financial Insight Generation
  • Dashboard Summary System

๐Ÿ”” Notification System

  • Email Notification Support
  • Budget Alert Emails
  • Strategy Pattern Notification Architecture
  • Async Notification Processing
  • Gmail Integration

โฐ Background Automation

  • Scheduler-Based Goal Monitoring
  • Automatic Goal Expiry Processing
  • Budget Monitoring Scheduler
  • Automated Notification Triggering
  • Async Financial Processing

โšก Redis Caching

  • Dashboard Analytics Caching
  • Wallet Information Caching
  • Reduced Database Load
  • Faster API Responses
  • Analytics Optimization

๐Ÿณ Infrastructure Features

  • Dockerized Redis
  • Production Deployment
  • RESTful APIs
  • Scalable Backend Design
  • Redis Integration
  • Production-Ready Architecture

๐Ÿ—๏ธ System Architecture

High-Level Architecture

User
  โ†“
React Frontend
  โ†“
REST APIs
  โ†“
Spring Security Layer
  โ†“
Spring Boot Backend
  โ”œโ”€โ”€ Authentication Module
  โ”œโ”€โ”€ Transaction Module
  โ”œโ”€โ”€ Budget Module
  โ”œโ”€โ”€ Goal Module
  โ”œโ”€โ”€ Dashboard Analytics Engine
  โ”œโ”€โ”€ Wallet Analytics Module
  โ”œโ”€โ”€ Notification System
  โ”œโ”€โ”€ Scheduler (Background Jobs)
  โ””โ”€โ”€ Redis Cache Layer
  โ†“
MySQL Database

๐Ÿ›๏ธ Backend Architecture

Layered Architecture

Controller Layer
      โ†“
Service Layer
      โ†“
Repository Layer
      โ†“
Database

Controller Layer

Responsibilities:

  • Handle HTTP requests
  • Validate incoming DTOs
  • Return API responses
  • Route requests to services

Service Layer

Responsibilities:

  • Business logic
  • Financial calculations
  • Analytics generation
  • Transaction management
  • Scheduler processing
  • Notification triggering

Repository Layer

Responsibilities:

  • Database interaction
  • JPA queries
  • Data retrieval
  • Aggregation queries
  • Pagination
  • Filtering

๐Ÿ”„ Authentication Flow

Registration Flow

User
  โ†“
/register
  โ†“
Spring Security Filter Chain
  โ†“
Controller
  โ†“
Service Layer
  โ†“
Password Encoding
  โ†“
Save User in Database
  โ†“
Success Response

Login Flow

User
  โ†“
/login
  โ†“
RateLimiterFilter
  โ†“
Spring Security Filter Chain
  โ†“
Authentication Manager
  โ†“
Custom Authentication Provider
  โ†“
UserDetailsService
  โ†“
Database Validation
  โ†“
JWT Generation
  โ†“
Return JWT Token

Protected API Flow

Frontend Request + JWT
  โ†“
RateLimiterFilter
  โ†“
JWT Validation Filter
  โ†“
Token Validation
  โ†“
SecurityContext Authentication
  โ†“
Controller Execution

๐Ÿ›ก๏ธ Rate Limiting System

ApnaBudget uses:

  • Bucket4j
  • Token Bucket Algorithm
  • IP-Based Request Limiting

Features

  • Prevents API abuse
  • Prevents brute-force attacks
  • Protects public APIs
  • Configurable token refill strategy
  • Independent bucket per IP address

Example Configuration

10 Requests / 2 Seconds

๐Ÿ’ฐ Financial System Design

Student Balance Architecture

The system maintains:

Available Balance

The actual usable balance available to the user.

Reserved Goal Balance

Funds allocated to goals are reserved and removed from available balance.

Main Balance

Represents:

Available Balance + Goal Reserved Balance

This architecture allows:

  • Accurate financial tracking
  • Goal reservation
  • Real-world financial simulation
  • Safer spending analysis

๐Ÿ”„ Transaction Processing Flow

Income Flow

Add Income Transaction
  โ†“
Save Transaction
  โ†“
Increase Student Available Balance
  โ†“
Update Dashboard Analytics

Expense Flow

Add Expense Transaction
  โ†“
Save Transaction
  โ†“
Decrease Student Available Balance
  โ†“
Update Budget Current Amount
  โ†“
Recalculate Budget Condition
  โ†“
Update Dashboard Analytics

๐Ÿ“Š Budget System

Budget Conditions

NORMAL

Budget consumption below warning threshold.

WARNING

Budget nearing target limit.

EXCEED

Budget target exceeded.


Budget Consumption Formula

(CurrentAmount ร— 100) / TargetAmount

Budget Monitoring System

The system automatically:

  • Tracks expenses
  • Updates budget current amount
  • Detects warning conditions
  • Detects exceeded budgets
  • Triggers notification system

๐ŸŽฏ Goal Allocation System

Goal Allocation Flow

Allocate Balance
  โ†“
Check Available Balance
  โ†“
Deduct Student Balance
  โ†“
Increase Goal Current Amount
  โ†“
Persist Changes

Goal Withdrawal Flow

Withdraw Goal Balance
  โ†“
Decrease Goal Current Amount
  โ†“
Return Amount To Available Balance
  โ†“
Persist Changes

โฐ Scheduler & Background Jobs

The application contains automated background processing.


Goal Expiry Scheduler

Responsibilities:

  • Check expired goals
  • Restore reserved balance
  • Update student balance
  • Mark goal state

Budget Monitoring Scheduler

Responsibilities:

  • Detect exceeded budgets
  • Detect warning budgets
  • Trigger notification system

๐Ÿ”” Notification System

The application uses:

Strategy Pattern

for extensible notification handling.

Notification Architecture

Notification Context
      โ†“
Notification Strategy
      โ†“
Email Strategy
SMS Strategy
Push Strategy

Current Implementation

  • Gmail Notification Service
  • Async Notification Processing
  • Automated Budget Alert Emails

โšก Redis Caching Layer

Redis is used for:

  • Dashboard analytics caching
  • Wallet analytics caching
  • Frequently accessed financial data
  • Performance optimization

Why Redis?

Redis significantly reduces:

  • Database load
  • Analytics recomputation
  • Repeated aggregation queries

and improves:

  • API response time
  • Scalability
  • User experience

๐Ÿณ Docker Infrastructure

The application uses Dockerized infrastructure for:

  • Redis containerization
  • Consistent deployment
  • Environment portability
  • Easier production setup

๐Ÿ—„๏ธ Database Design

Main Entities

Student

Stores:

  • User information
  • Authentication details
  • Available balance

Transaction

Stores:

  • Income transactions
  • Expense transactions
  • Payment type
  • Transaction category
  • Transaction timestamp

Budget

Stores:

  • Budget target amount
  • Current consumed amount
  • Budget condition
  • Budget duration
  • Associated category

Goal

Stores:

  • Goal target amount
  • Current allocated amount
  • Goal duration
  • Goal progress

Category

Stores:

  • Category name
  • Category type
  • Default categories
  • User-defined categories

๐Ÿ“‰ Financial Analytics

The analytics engine calculates:

  • Weekly spending trends
  • Income vs expense comparison
  • Percentage difference analysis
  • Category-based spending analysis
  • Budget utilization
  • Goal progress analysis
  • Financial insights

๐Ÿง  Weekly Analysis Logic

The application compares:

Current Week vs Previous Week

to generate:

  • Spending increase insights
  • Spending reduction insights
  • Financial trend observations

๐Ÿ›ก๏ธ Security Features

JWT Security

  • Stateless authentication
  • Secure token validation
  • Protected API access
  • SecurityContext integration

Password Security

  • Password hashing
  • Encoded credential storage
  • Secure authentication flow

Rate Limiting Protection

  • Bucket4j token bucket algorithm
  • API abuse prevention
  • Brute-force attack protection
  • Per-IP request limiting

๐Ÿš„ Performance Optimizations

The backend includes:

  • Redis caching
  • Aggregation queries
  • Efficient financial calculations
  • Scheduler-based automation
  • Read-only analytics processing
  • Layered modular architecture
  • Background async processing

๐Ÿง  Design Patterns Used

Pattern Usage
Strategy Pattern Notification System
Layered Architecture Backend Structure
DTO Pattern Request/Response Separation
Scheduler Pattern Background Automation
Repository Pattern Database Abstraction

๐Ÿ›๏ธ Key Backend Concepts Demonstrated

This project demonstrates:

  • Enterprise-style backend architecture
  • Financial domain modeling
  • Spring Security lifecycle
  • JWT authentication
  • Background job processing
  • Caching strategies
  • Modular system design
  • Analytics aggregation systems
  • Notification extensibility
  • Clean service separation
  • Rate limiting architecture
  • Production-grade security flow

๐Ÿ”ฎ Future Enhancements

Infrastructure & Scalability

  • Horizontal backend scaling
  • Load balancer integration
  • Distributed Redis caching
  • Kubernetes orchestration
  • API Gateway integration
  • Multi-environment deployment pipelines

Performance Optimization

  • Advanced Redis caching strategies
  • Query optimization & indexing
  • Asynchronous event-driven processing
  • Backend response optimization
  • Batch processing for analytics
  • Database connection pooling optimization

Security Improvements

  • Refresh Token Authentication
  • Role-Based Access Control (RBAC)
  • OAuth2 & Google Authentication
  • Advanced API security hardening
  • CSRF/XSS protection improvements
  • Device/session management
  • Suspicious login detection
  • Distributed rate limiting using Redis
  • Request fingerprinting
  • API abuse monitoring

Architecture Improvements

  • AOP-based centralized logging
  • AOP-based performance monitoring
  • AOP-based exception handling
  • Event-driven notification architecture
  • Microservices migration strategy
  • Distributed scheduler support
  • CQRS-based analytics separation

Monitoring & Observability

  • Centralized logging system
  • Prometheus metrics integration
  • Grafana monitoring dashboards
  • Real-time backend health monitoring
  • Distributed tracing
  • Request lifecycle tracking

Financial Intelligence Features

  • AI-powered spending prediction
  • Smart financial recommendations
  • Financial anomaly detection
  • Expense forecasting
  • Intelligent savings suggestions
  • Monthly financial health scoring

Notification System Expansion

  • SMS notifications
  • Push notifications
  • WebSocket real-time alerts
  • Multi-channel notification system
  • Notification preference management

Reporting & Analytics

  • PDF financial report exports
  • Excel report generation
  • Advanced financial dashboards
  • Custom analytics reports
  • Historical financial trend analysis

DevOps & Deployment

  • CI/CD pipeline integration
  • Docker Compose orchestration
  • Blue-Green deployment strategy
  • Automated backup systems
  • Cloud-native deployment
  • Infrastructure monitoring

โš™๏ธ Running The Backend

Prerequisites

  • Java 21+
  • MySQL
  • Redis
  • Maven
  • Docker

Clone Repository

git clone <repository-url>

Configure Database

Update:

application.properties

with:

spring.datasource.url=
spring.datasource.username=
spring.datasource.password=

Configure Redis

spring.data.redis.host=
spring.data.redis.port=

Configure Mail Sender

spring.mail.username=
spring.mail.password=

Run Application

mvn spring-boot:run

๐ŸŒŸ Project Highlights

ApnaBudget is not just a CRUD application.

The backend includes:

  • Financial analytics engine
  • Scheduler automation
  • Strategy pattern notification system
  • Goal reservation architecture
  • Budget monitoring engine
  • JWT-based security
  • Redis caching
  • Docker infrastructure
  • Rate limiting architecture
  • Modular enterprise architecture

โœ… Conclusion

ApnaBudget Backend is designed as a scalable financial management system that combines:

  • Modern backend architecture
  • Financial analytics
  • Automation
  • Caching
  • Asynchronous processing
  • Secure authentication
  • Extensible notification systems
  • Rate limiting protection
  • Production-grade backend engineering

The project demonstrates practical implementation of production-level backend engineering concepts using the Spring ecosystem.

About

ApnaBudget is an enterprise-grade, high-performance web ecosystem engineered specifically as an intelligent personal finance and money management application for students.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages