Welcome to my Java assignment README. I've completed this assignment for Tree Digital, which involves viewing account statements. The application is built using Spring Boot 3.1.3 and provides API endpoints for retrieving account statements. Security is ensured with JWT tokens. Here are the key points:
-
Clone my repository: You can clone my repository to your local machine using IntelliJ IDEA.
-
Install the dependencies using Maven: To ensure all required dependencies are installed, navigate to the project directory and run the following command:
-
Configure MS Access database path: Make sure that the MS Access database path is configured correctly. The database is located in the
data
directory in the project root directory. Depending on your OS, the path might differ.
The project follows a structured layout, including packages for config, controllers, service, repository, exceptions, and more.
To run the application using IntelliJ IDEA, follow these steps:
-
Clone my repository: First, clone my repository to your local machine using IntelliJ IDEA.
-
In the project directory, locate the
src/main/java/sa/com/tree/account/statment/treecodingchallenge/TreeCodingChallengeApplication.java
file, which contains the main application class. -
Right-click on the
TreeCodingChallengeApplication
class and select "Run ' TreeCodingChallengeApplication.main()'." This will start the application. -
The application should now be running on
http://localhost:8080
.
The following API endpoints are available under the root path /api/v1/
:
-
/api/v1/user/login
: Obtain a JWT token for authentication. You can use the following pre-authenticated users to log in to the application for testing purposes:- Username: admin
- Password: admin
- Username: user
- Password: user
-
/api/v1/account/{account_id}/statements
: Retrieve account statements for the specified account ( replace{account_id}
with the actual account ID). Make sure you are already logged in, and the JWT token is passed in the Authorization header. Here is an already-made search URL example you can use in Postman to do a quick search: http://localhost:8080/api/v1/account/3/statements?fromDate=01.07.2000&toDate=08.08.2023&fromAmount=1&toAmount=900000000000 -
/api/v1/user/logout
: Log out and invalidate the session.
I recommend using Postman for testing these endpoints, as it provides a user-friendly interface for making API requests.
Run mvn clean test
to execute unit tests with coverage reports.
- I have used OAuth with JWT tokens to maintain the app security.
- In-memory database manages user login and session information. can be replaced with real database.
- Tokens expire after 5 minutes.
Here is the SonarQube report for the project: https://sonarcloud.io/project/overview?id=ahmedelzubair_TreeCodingChallenge
Test coverage report is available in the test_coverage_report directory.
If you have any questions or need further assistance, please feel free to reach out. Thank you for checking out my work!