This is the project i am trying to built:
I. Project Description
The project, named WealthGuardian, is a comprehensive personal financial management
application designed to help individuals monitor and manage their daily economic activities.
WealthGuardian was chosen as the name because it emphasizes the app’s role in guarding and
optimizing users’ wealth through insightful financial monitoring and guidance. The core functionalities of
WealthGuardian include budget tracking, which allows users to set monthly spending limits and track
day-to-day expenses to ensure they stay on budget. The investment tracker enables users to monitor
their portfolio performance, providing insights on stocks, bonds, and other investments (although this
part may be an overreach on the dev’s part).
Additionally, WealthGuardian offers a savings goal tracker that motivates and assists users in
achieving their short and long-term saving objectives by setting incremental landmarks. Finally, the
application integrates a debt management plan that offers tailored advice on reducing liabilities and
improving financial health. Overall, the aim of WealthGuardian is to offer an intuitive and accessible
interface that empowers users to enhance their financial literacy and achieve greater economic security.
Using the MoSCoW method, application of prioritization to WealthGuardian:
Essentials (MUST have)
- User authentication and management.
- Basic transaction tracking.
- Basic budget creation and tracking.
Important (SHOULD have)
- A detailed dashboard for a quick overview of financial health.
- Alerts or notifications for budget limits.
Nice to Have (COULD have)
- Investment tracking (simplified version).
- Use of interactive charts for financial data visualization.
Non-Essential (WON’T have this time)
- Comprehensive debt management tools.
- Advanced investment analysis features.
- In-depth financial health reports.
II. Model and Table Structure
List of Models:
1. User - Manages user information and authentication details.
2. Transaction - Records individual financial transactions to monitor spending and investments.
3. Account - Represents various financial accounts, such as checking, savings, or investment accounts.
4. Budget - Helps in setting and tracking monthly spending limits and financial goals.
List of Tables:
1. Table Name: Users
- Primary Key: user_id
- Model Related: User
2. Table Name: Transactions
- Primary Key: transaction_id
3- Foreign Key: account_id (links to Accounts table)
- Model Related: Transaction
3. Table Name: Accounts
- Primary Key: account_id
- Foreign Key: user_id (links to Users table)
- Model Related: Account
4. Table Name: Budgets
- Primary Key: budget_id
- Foreign Key: user_id (links to Users table)
- Model Related: Budget
III.List of Web Pages:
1. Dashboard - Provides an overview of all financial metrics including recent transactions, budget
summary, and savings goals.
2. Transaction History - Displays a detailed log of all financial transactions allowing users to review past
expenses and deposits.
3. Budget Management - Enables users to create, edit, and monitor their monthly budgets, visualizing
data to aid in financial decision-making.
4. Investments Tracker - Offers a comprehensive view of investment portfolios with performance
metrics and individual asset reviews.
5. Savings Goals - Allows setting and tracking of various saving objectives, offering motivational insights
and progress reports.
6. Debt Overview - Shows all liabilities and provides plans and suggestions for efficient debt
management.5. Savings Goals - Allows setting and tracking of various saving objectives, offering motivational insights
and progress reports.
6. Debt Overview - Shows all liabilities and provides plans and suggestions for efficient debt
this is what i have so far:
structure the project as follows:
1. Project Package Structure (2%)
- Create packages for models, repositories, services, controllers, exceptions, etc.
- Example structure:

com.wealthGuardian
├── controller
├── service
├── model
├── repository
├── exception
└── util


2. Class Comments (2%)
- Add class-level Javadoc. Example:

/**
* Represents a user in the WealthGuardian application.
* Manages user information and authentication details.
*/
public class User {}


3. GitHub Hosting (5%)
- Push your code to GitHub early. Include a README.md with an overview of your project.
- Example README:

# WealthGuardian
WealthGuardian is a comprehensive personal financial management application designed to help individuals monitor and manage their daily economic activities.


4. Standard Java Naming Conventions (3%)
- Follow PascalCase for class names, camelCase for variables, methods, and URLs, snake_case for file names, and lowercase with dots for packages.
- Example:

package org.yourname.wealthguardian.controller;


### II. Core Java and Models (16%)

1. Constants in Java Classes (2%)
- Use constants for unchanging variables. Example:

public class AppConstants {
public static final String USER_TABLE = “Users”;
}


2. Models and Tables (12%)
- Ensure you have four models: User, Transaction, Account, Budget.
- Create corresponding tables in your database. Ensure correct implementations and optimize the schema.

3. Exception Handling (2%)
- Implement global exception handling using @ControllerAdvice.

@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
public ResponseEntity<String> handleException(Exception e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}


### III. Database, ORM, and Hibernate (18%)

1. MySQL DBMS (2%)
- Ensure MySQL is used as your DBMS.

2. Schema Diagram and SQL (2%)
- Include a schema diagram and SQL creation scripts in your documentation.

3. Spring Initializr Configuration (2%)
- Configure application.properties correctly.

spring.datasource.url=jdbc:mysql://localhost:3306/wealthguardian
spring.datasource.username=root
spring.datasource.password=password


4. Custom Queries (3%)
- Implement at least three custom queries in your repositories.

5. Use Hibernate/JPA (3%)
- Use Spring Data JPA for data access.

6. CRUD Operations (6%)
- Ensure you perform Create, Read, Update, and Delete operations in your application.

### IV. Front-end Development (16%)

1. Styling with CSS (3%)
- Use external CSS and possibly Bootstrap for minimal styling.

2. Six Views/Pages (4%)
- Ensure you have six distinct views: Dashboard, Transaction History, Budget Management, Investments Tracker, Savings Goals, Debt Overview.

3. HTML and Thymeleaf (3%)
- Use Thymeleaf for dynamic web pages.

4. JavaScript External Scripts (3%)
- Include at least one external JavaScript file.

5. Navigation (3%)
- Include a reusable navigation bar across your pages.

### V. Spring Framework (25%)

1. Spring Boot (2%)
- Develop your project using Spring Boot.

2. Data Binding and Validation (3%)
- Annotate models for data binding and validation.

3. Repositories and Services (4%)
- Include at least two repositories and two interconnected service classes/interfaces.

4. Managed Beans/Objects (2%)
- Create managed beans using @Component, @Service, or other relevant annotations.

5. Dependency Injection (3%)
- Use @Autowired for dependency injection correctly.

6. Session Management (3%)
- Implement session management, possibly using Spring Security.

7. Transaction and Request/Response Logging (2%)
- Add transaction and logging mechanisms.

8. Web Services (3%)
- Implement RESTful web services using Spring REST.

9. Sign-up and Login with BCrypt (3%)
- Implement user registration and login with password encryption using BCrypt.

### VI. Unit Testing (8%)

1. Test Query Methods (3%)
- Write unit tests for repository query methods.

2. Service Method Tests (3%)
- Unit test at least one method in each service class.

3. Parameterized Test (2%)
- Include at least one parameterized test
User.java:

Purpose: Represents a user in the WealthGuardian application, managing user information and authentication details.

Annotations:

@Entity: Indicates that this class is an entity that maps to a database table.
@Table(name = "users"): Specifies the table name for this entity in the database.
Summary of Responsibilities:

Defines the structure of a user entity with properties like userId, username, password, and accounts.
Uses @OneToMany to establish a one-to-many relationship with Account entities through the accounts field.
Provides getters and setters for accessing and modifying entity properties.

UserRepository.java:

Purpose: Manages the persistence of User entities, providing methods for CRUD operations.

Annotations:

@Repository: Marks this interface as a repository component managed by Spring for data access.
Summary of Responsibilities:

Extends JpaRepository<User, Long> to inherit methods for CRUD operations on User entities.
Defines additional query methods such as findByUsername for custom data retrieval operations.

UserService.java:

Purpose: Implements business logic operations related to User entities, utilizing UserRepository for data access.

Annotations:

@Service: Indicates that this class is a service component in the Spring framework, managing business logic.
Summary of Responsibilities:

Provides methods to manage User entities:saveUser(User user): Saves a new user or updates an existing one.
getUserById(Long userId): Retrieves a user by their ID.
getAllUsers(): Retrieves all users stored in the repository.
findByUsername(String username): Retrieves a user by their username.
Uses UserRepository for data access operations.

UserController.java:

Purpose: Defines HTTP endpoints for CRUD operations on User entities, serving as an interface between clients and the application's business logic.

Annotations:

@RestController: Indicates that this class is a REST controller, facilitating RESTful endpoints.
@RequestMapping("/api/users"): Specifies the base URL path for handling requests related to users.
Summary of Responsibilities:

Defines HTTP endpoints (POST, GET) for managing User entities:createUser: Handles HTTP POST requests to create a new user.
getUserById: Handles HTTP GET requests to retrieve a user by their ID.
getAllUsers: Handles HTTP GET requests to retrieve all users.
Uses UserService to delegate business logic operations.
Returns appropriate ResponseEntity objects with status codes for success or failure scenarios.

Summary of Responsibilities (Overall):

User.java: Defines the structure and relationships of a user entity, including one-to-many with Account.
UserRepository.java: Manages the persistence of User entities, providing methods for CRUD operations and custom queries.
UserService.java: Implements business logic operations for User entities, such as creation, retrieval, and deletion, utilizing UserRepository.
UserController.java: Defines RESTful endpoints for handling HTTP requests related to users, facilitating create and retrieve operations and error handling with appropriate responses.



Transaction.java:
Purpose: This class represents a financial transaction in the WealthGuardian application.
Annotations (@Entity, @Table, @Id, @GeneratedValue, @ManyToOne, @JoinColumn, @Temporal): These annotations are used by the JPA (Java Persistence API) to map this class to a database table (transactions). They define the primary key (transactionId), relationships (many-to-one with Account), and temporal data (date).
Attributes (transactionId, account, type, amount, date): These attributes represent the data associated with a transaction (e.g., ID, linked account, type of transaction, amount, date).
Getters and Setters: These methods are standard Java bean-style getters and setters used to access and mutate the private attributes of the class.

TransactionRepository.java:
Purpose: This class serves as a repository for managing Transaction objects in memory (or potentially persistently with a database, though currently it's in-memory with a Map).
Attributes (transactions): A Map (HashMap) that stores transactions with transactionId as the key.
Methods:
findById(Long transactionId): Finds a transaction by its ID.
findByAccountId(Long accountId): Finds transactions associated with a specific account ID.
save(Transaction transaction): Saves a transaction into the repository (transactions map).
delete(Long transactionId): Deletes a transaction from the repository.
getAllTransactions(): Retrieves all transactions stored in the repository.

TransactionService.java:
Purpose: This class provides business logic and acts as an intermediary between the TransactionController and TransactionRepository.
Attributes (transactionRepository): Holds an instance of TransactionRepository to interact with the data layer.
Methods:
addTransaction(Transaction transaction): Delegates to TransactionRepository to save a new transaction.
getAllTransactions(): Retrieves all transactions from TransactionRepository.
getTransactionById(Long transactionId): Retrieves a transaction by its ID from TransactionRepository.
deleteTransaction(Long transactionId): Delegates to TransactionRepository to delete a transaction.

TransactionController.java:
Purpose: This class acts as a REST controller for handling HTTP requests related to transactions.
Annotations (@RestController, @RequestMapping, @PostMapping, @GetMapping, @PathVariable, @RequestBody): These annotations are used by Spring MVC to map HTTP requests to Java methods and manage the RESTful API.
Attributes (transactionService): Holds an instance of TransactionService to handle business logic related to transactions.
Methods:
createTransaction(Transaction transaction): Handles HTTP POST requests to create a new transaction.
getAllTransactions(): Handles HTTP GET requests to retrieve all transactions.
getTransactionById(Long id): Handles HTTP GET requests to retrieve a transaction by its ID.
ResponseEntity: Wraps responses to include HTTP status codes (e.g., HttpStatus.CREATED, HttpStatus.OK, HttpStatus.NOT_FOUND).


Summary(Transaction)
Transaction.java: Defines the structure of a financial transaction entity.
TransactionRepository.java: Manages the storage and retrieval of Transaction objects.
TransactionService.java: Provides business logic operations on Transaction objects.
TransactionController.java: Handles HTTP requests and serves as the interface between the client and the TransactionService.



Account.java
Purpose: Represents a financial account in the WealthGuardian application, such as checking, savings, or investment accounts.

Annotations:

@Entity: Indicates that this class is an entity mapped to a database table.
@Table(name = "accounts"): Specifies the name of the database table corresponding to this entity.
@Id: Denotes the primary key field of the entity.
@GeneratedValue(strategy = GenerationType.IDENTITY): Specifies that the primary key value is generated by the database (auto-increment).
AccountRepository.java
Purpose: Provides data access methods for managing Account entities.

Annotations:

None in this simplified version, but typically, Spring Data repositories might use annotations like @Repository.
AccountService.java
Purpose: Implements business logic operations related to Account entities.

Annotations:

@Service: Indicates that this class is a service component in the Spring framework.
AccountController.java
Purpose: Handles HTTP requests related to Account entities, acting as the entry point for account-related operations.

Annotations:

@RestController: Indicates that this class is a REST controller that handles HTTP requests and returns JSON or XML responses.
@RequestMapping("/api/accounts"): Specifies the base URL path for which this controller will handle requests related to accounts.
Summary of Responsibilities:
Account.java: Defines the structure of an account entity, including its properties and relationships with other entities.
AccountRepository.java: Manages the persistence of Account entities, providing methods for CRUD operations (Create, Read, Update, Delete).
AccountService.java: Contains business logic operations related to Account entities, such as creating, retrieving, updating, and deleting accounts.
AccountController.java: Defines endpoints to handle HTTP requests for account operations (e.g., create, retrieve by ID, retrieve all). Acts as an interface between the client (e.g., web browser or mobile app) and the application's business logic (via AccountService).


 
 
 Budget.java:

Purpose: Represents a budget entity in the WealthGuardian application, defining its structure and relationships.

Annotations:

@Entity: Specifies that this class is an entity that maps to a database table.
@Table(name = "budgets"): Maps this entity to the "budgets" table in the database.
Summary of Responsibilities:

Defines the structure of a budget entity with properties like budgetId, user, monthlyLimit, and currentSpending.
Establishes a Many-to-One relationship with the User entity through the user field.
Provides getters and setters for accessing and modifying entity properties.

BudgetRepository.java:

Purpose: Manages the persistence and retrieval of Budget entities using an in-memory data structure.

Annotations:

@Repository: Indicates that this class is a repository component managed by Spring for data access.
Summary of Responsibilities:

Provides methods to interact with Budget entities:findById(Long budgetId): Retrieves a budget by its ID.
save(Budget budget): Saves a budget entity.
delete(Long budgetId): Deletes a budget by its ID.
findAll(): Retrieves all budgets stored in the repository.
Uses a HashMap (budgets) to store Budget entities temporarily in memory.

BudgetService.java:

Purpose: Implements business logic operations related to Budget entities, facilitating interaction between the repository and controllers.

Annotations:

@Service: Marks this class as a service component in the Spring framework, managing business logic.
Summary of Responsibilities:

Provides methods to manage Budget entities:createBudget(Budget budget): Saves a new budget.
getBudgetById(Long budgetId): Retrieves a budget by its ID.
getAllBudgets(): Retrieves all budgets.
deleteBudget(Long budgetId): Deletes a budget by its ID.
Uses BudgetRepository for data access operations.

BudgetController.java:

Purpose: Defines HTTP endpoints for CRUD operations on Budget entities, acting as an interface between clients and the application's business logic.

Annotations:

@RestController: Indicates that this class is a REST controller, facilitating RESTful endpoints.
Summary of Responsibilities:

Defines HTTP endpoints (POST, GET, DELETE) for managing Budget entities:createBudget: Handles HTTP POST requests to create a new budget.
getBudgetById: Handles HTTP GET requests to retrieve a budget by its ID.
getAllBudgets: Handles HTTP GET requests to retrieve all budgets.
deleteBudget: Handles HTTP DELETE requests to delete a budget by its ID.
Uses BudgetService to delegate business logic operations.

Summary of Responsibilities (Overall):

Budget.java: Defines the structure and relationships of a budget entity.
BudgetRepository.java: Manages the persistence of Budget entities using an in-memory HashMap, providing CRUD operations.
BudgetService.java: Implements business logic operations for Budget entities, including creation, retrieval, and deletion.
BudgetController.java: Defines RESTful endpoints for handling HTTP requests related to budgets, facilitating create, retrieve, and delete operations.


Exceptions:

1. Custom Exception Classes:
- ResourceNotFoundException.java:
- Purpose: To signal when a requested resource (e.g., user, transaction) is not found in the system.
- Usage: Throw this exception when a specific resource identified by a unique identifier (e.g., userId) does not exist.

- BadRequestException.java:
- Purpose: To signal when the client sends a bad or malformed request to the server.
- Usage: Throw this exception when the input data from the client is invalid or does not adhere to expected formats or constraints.

2. Global Exception Handler:
- GlobalExceptionHandler.java:
- Purpose: To handle exceptions globally across the application, ensuring a consistent error response structure.
- Annotations: @ControllerAdvice to manage application-wide exception handling.
- Methods:
- handleResourceNotFoundException: Returns a NOT_FOUND (404) status with an error message for ResourceNotFoundException.
- handleBadRequestException: Returns a BAD_REQUEST (400) status with an error message for BadRequestException.
- handleGlobalException: Catches any other exceptions, returning an INTERNAL_SERVER_ERROR (500) status with the error message.

Utility Classes:

1. Date Utility:
- DateUtil.java:
- Purpose: To provide common methods for date handling and formatting.
- Methods:
- stringToDate(String dateString): Converts a date string into a Date object.
- dateToString(Date date): Converts a Date object into a string formatted as yyyy-MM-dd.

2. Input Validation Utility:
- InputValidator.java:
- Purpose: To provide common validation methods for input data.
- Methods:
- isStringValid(String input): Checks if a given string is neither null nor empty after trimming whitespace.

3. Response Utility:
- ResponseUtil.java:
- Purpose: To standardize API response creation.
- Methods:
- createSuccessResponse(Object body): Returns a ResponseEntity with an OK (200) status and the given response body.
- createCreatedResponse(Object body): Returns a ResponseEntity with a CREATED (201) status and the given response body.
- createErrorResponse(String message, HttpStatus status): Returns a ResponseEntity with the specified status and an error message.

Summary:

- Exceptions:
- Created two custom exceptions (ResourceNotFoundException, BadRequestException) for handling specific error conditions.
- Implemented a global exception handler (GlobalExceptionHandler) to manage and format exception responses consistently.

- Utilities:
- Developed utility classes to handle common tasks:
- DateUtil: For date parsing and formatting.
- InputValidator: For input validation checks.
- ResponseUtil: For standardized API response generation.

These implementations help standardize error handling and common functionalities across your WealthGuardian application, making the application more robust and maintainable.


///////////////////////////////////////////////////////////
Components Already Done:
- Models (User, Transaction, Account, Budget)
- Repositories
- Services
- Controllers
- Exception Handling
- Utility Classes

### Let’s review and check any remaining key components:

### Database, ORM, and Hibernate
1. Schema Diagram and SQL Creation Scripts:
- Ensure you’ve documented your database schema and have SQL scripts for creating tables.

2. Spring Initializr Configuration:
- The application.properties file should be correctly configured for your MySQL database.

3. Custom Queries and CRUD Operations:
- Verify three custom queries are created in your repositories, and CRUD operations are properly implemented.

### Front-End Development
1. Styling with CSS:
- Use external CSS (or Bootstrap) for minimal styling.

2. Six Pages:
- Ensure you have the following views:
- Dashboard
- Transaction History
- Budget Management
- Investments Tracker
- Savings Goals
- Debt Overview

3. HTML and Thymeleaf:
- Use Thymeleaf for dynamic content rendering in HTML.

4. JavaScript External Scripts:
- Make sure there is at least one external JavaScript file if you’re using any client-side logic.

5. Navigation:
- Include a reusable navigation bar across pages for seamless user experience.

### Spring Framework Integration
1. Data Binding and Validation:
- Ensure models are annotated correctly for data validation.

2. Repositories and Services:
- Verify at least two interconnected service classes/interfaces are provided.

3. Managed Beans/Objects:
- Ensure components are annotated with @Component, @Service, etc.

4. Dependency Injection:
- Use @Autowired for dependency injection correctly.

5. Session Management:
- Implement session management, potentially using Spring Security.

6. Transaction and Request/Response Logging:
- Add mechanisms for logging transactions and any request/response tracking.

7. Web Services:
- Implement RESTful web services using Spring REST.

8. Sign-up and Login with BCrypt:
- Implement user authentication with BCrypt encryption.

### Unit Testing
1. Test Query Methods:
- Write unit tests for repository query methods.

2. Service Method Tests:
- Unit test at least one method in each service class.

3. Parameterized Test:
- Include at least one parameterized test.

### Additional Areas to Ensure Completeness:
1. GitHub Hosting:
- Ensure your code is pushed early to GitHub with a well-documented README.md.

2. Class Comments and Documentation:
- Ensure class-level Javadoc and proper inline comments in your code.

### Action Checklist:
1. Review Database and ORM:
- Ensure all aspects related to MySQL, schema diagrams, and custom queries are met.

2. Complete Front-End Views:
- Implement and test all six front-end pages with Thymeleaf.

3. Integrate Spring Security for Authentication:
- Set up Spring Security for secure session and user authentication.

4. Comprehensive Unit Testing:
- Verify tests are written and passing for repositories and services.

5. Ensure Logging and Error Handling:
- Validate logging for requests/responses and transaction handling.

6. Documentation and Hosting:
- Push to GitHub if not already, and ensure the README.md is comprehensive.