How sarthakpawar0912/expense-income-tracker works
Project Type & Purpose
• This is a backend-only, monolithic RESTful API built with Spring Boot 3.1.5 and Java 17, using MySQL as its persistence store.
• Purpose: Expose endpoints for managing expenses, incomes, and financial analytics (stats/chart).
File Structure & Architectural Pattern
• Layered (MVC) Architecture
• src/main/java/com/SRP/ExpenseTracker/Controller → REST Controllers (API layer)
• src/main/java/com/SRP/ExpenseTracker/Service → Business logic (Service layer)
• src/main/java/com/SRP/ExpenseTracker/Repository → Data access (Repository/DAO layer)
• src/main/java/com/SRP/ExpenseTracker/entity → JPA Entities (Domain model)
• src/main/java/com/SRP/ExpenseTracker/dto → Data Transfer Objects for API I/O
• Configuration & Build
• pom.xml, mvnw → Maven build and dependency management
• src/main/resources/application.properties → DataSource and Spring Boot settings
Main Components
a. Clients (e.g., Postman, Web Frontend, Mobile App)
b. API Layer
• ExpenseController
• IncomeController
• StatsController
c. Service Layer
• ExpenseServiceImpl (implements ExpenseService)
• IncomeServiceImpl
• StatsServiceImpl
d. Repository Layer
• ExpenseRepository (extends JPA Repository)
• IncomeRepository
e. Database
• MySQL instance (finance_db schema)
f. Supporting Infrastructure
• Spring Boot Application Context (ExpenseTrackerApplication)
• Maven/Wrapped build process
Relationships & Data Flow
1. Client → Controller: HTTP requests (POST/GET/PUT/DELETE) to /api/expense, /api/income, /api/stats.
2. Controller → Service: Controllers delegate validation and business logic to Service layer.
3. Service → Repository: Services call JPA Repositories to perform CRUD.
4. Repository → Database: Repositories map Entity objects to MySQL tables via Spring Data JPA.
5. StatsService may call both ExpenseRepository and IncomeRepository, aggregate results, and return StatsDTO or GraphDTO.
Architectural Patterns & Principles
• Separation of Concerns: Controllers handle HTTP and DTO translation; Services contain business logic; Repositories abstract persistence.
• DTO Pattern: Prevents exposing Entities directly, eases versioning.
• Layered Modularity: Each package clearly delineates responsibility, improving testability (see src/test/java/...).
• Clear layer separation (API / Service / Data).