This project is a Budget and Expense Management System designed to help users track their expenses and manage their budgets efficiently. The system allows users to manage categories, expenses, and products, leveraging Spring Boot for the backend and Thymeleaf for the frontend.
- Project Structure
- Technology Stack
- MVC Architecture
- Design Patterns
- Principles
- Setup and Installation
- Usage
-
yourtech.demo.models.Observor:Subject: Interface defining methods for observer management.Observer: Interface defining the update method for observers.GoalObserver: Implements theObserverinterface to check if budget goals are met.BudgetSubject: Implements theSubjectinterface to manage and notify observers.
-
yourtech.demo.controllers:BudgetController: Manages budget-related operations and interactions with the user.ExpenseController: Handles expense-related operations.ProductsController: Manages product-related operations, including image uploads.
-
yourtech.demo.services:BudgetService: Service layer for budget-related logic.ExpenseService: Service layer for expense-related logic.ProductsRepository: Repository for product data access.
- Backend: Spring Boot, Java
- Frontend: Thymeleaf, HTML, CSS
- Database: MySQL
- Build Tool: Maven
The project follows the Model-View-Controller (MVC) architecture:
-
Model: Represents the data layer and business logic. In this project, models are represented by entities like
Category,Expense, andProduct. The repository classes interact with the database to perform CRUD operations. -
View: The presentation layer, managed by Thymeleaf templates, displays the data to the user. For example,
budget.htmlandexpenses.htmlare Thymeleaf templates that present budget and expense information. -
Controller: Manages user input and interactions. Controllers like
BudgetController,ExpenseController, andProductsControllerhandle HTTP requests, invoke service methods, and return appropriate views.
- Purpose: Allows a subject to notify multiple observers about changes. This pattern is used in the
GoalObserverandBudgetSubjectclasses. - Implementation:
Subjectinterface defines methods for managing observers.Observerinterface defines theupdatemethod that observers implement.GoalObserverobserves changes in categories and updates based on expense goals.BudgetSubjectmaintains a list of observers and notifies them of changes.
- Purpose: Ensures a class has only one instance and provides a global point of access. Although not explicitly shown in the provided code, this pattern is commonly used in Spring Boot applications to manage beans and services with a single instance.
- Purpose: Creates objects without specifying the exact class of object that will be created. In the project, although not explicitly implemented, a factory pattern can be used to manage the creation of different types of services or controllers.
- Purpose: Defines a family of algorithms, encapsulates each one, and makes them interchangeable. This pattern can be used for different budget calculation strategies or expense tracking methods.
- Implementation: The project separates the data handling (models), user interface (views), and request handling (controllers) into different components, promoting a clean and manageable codebase.
- Implementation: Spring Boot’s dependency injection mechanism is used to manage dependencies, such as injecting
BudgetServiceandExpenseServiceinto controllers. This reduces coupling and improves testability.
- Implementation: Each class has a single responsibility. For example,
BudgetControllerhandles budget-related user interactions, whileBudgetServicemanages business logic related to budgets.
- Implementation: The system is designed to be open for extension but closed for modification. New features or changes can be added with minimal modifications to existing code, adhering to principles of extensibility and maintainability.
-
Clone the Repository
git clone https://github.com/yourusername/budget-expense-management-system.git