This is a backend API for a toy store web application built using Spring Boot 3, Spring Security 6, and Java 17. This API is responsible for handling all requests made to the server and returning the appropriate data to the front-end.
- Introduction
- Technologies
- Features
- Controllers and Endpoints
- API Documentation
- Installation and Usage
- Deployment to a Hosting Platform
- Contributing
- License
This web application is designed to allow users to view and purchase toys from a toy store. Users can browse through shop goods, search them flexibly, add products to a cart, make purchases, and proceeding payment with their card credentials.
This application was built using the following technologies:
- Spring Boot 3
- Spring Security 6
- Java 17
- Java ORM (JPA 3 + Hibernate 6)
- MySQL 8: A database used for development purposes
- H2: An embedded database used for testing purposes
- Maildev 2: A local mail server for development and testing environments
- GreenMail 2: A mail server designed for integration testing
- JUnit 5: A Java framework for writing unit tests
- Mockito 5: A Java framework for writing integration tests
- Swagger 3: A tool for writing API documentation
- Stripe: An online payment processing platform that provides a set of APIs and tools for businesses to accept and manage payments over the internet
- User registration
- Account activation using email letter
- Resend activation account email letter
- Send change password email letter
- Change password
- Login
- Refresh access token
- Logout
- Fetch filtered products
- Fetch filtering product categories
- Fetch product by slug
- Add the product to the cart
- Retrieve the contents of the cart for the user
- Update cart item quantity
- Delete the product from the cart
- Create order
- Retrieve all user's orders
- Fetch filtered products
- Fetch product by id
- Create product
- Update product
- Get all categories
- Create product category
- Update product category
- Delete product category
- Get order filtering options
- Fetch filtered orders
- Get order statuses
- Update order status
- Create a payment for the order
- Fulfill orders after successful payment
- POST /api/v1/auth/register - User registration
- GET /api/v1/auth/confirm - User account activation using email
- POST /api/v1/auth/resend-verification-email - Resend the account activation email letter
- POST /api/v1/auth/forgot-password - Send reset password email
- GET /api/v1/auth/reset-password - Change user password
- POST /api/v1/auth/login - Login
- POST /api/v1/auth/refresh-token - Refresh access token
- GET /api/v1/auth/logout - Logout
- GET /api/v1/products - Fetch filtered products
- GET /api/v1/products/categories - Fetch filtering product categories
- GET /api/v1/products/{productSlug} - Fetch product by slug
- POST /api/v1/cart/add-product - Add the product to the cart
- GET /api/v1/cart - Retrieve the contents of the shopping cart for the user
- PATCH /api/v1/cart - Update cart item quantity
- DELETE /api/v1/cart - Delete product from the cart
- POST /api/v1/order - Create order
- GET /api/v1/order - Retrieve all user orders
- POST /api/v1/payment/{orderId} - Create a payment for the order
- POST /api/v1/payment/webhook - Fulfill orders after successful payment
- GET /api/v1/admin/products - Fetch filtered products
- GET /api/v1/admin/products/{productId} - Fetch product by id
- POST /api/v1/admin/products/add - Create product
- PUT /api/v1/admin/products/{productId} - Update product
- GET /api/v1/admin/categories/{categoryType} - Get all categories
- POST /api/v1/admin/categories/{categoryType}/add - Create product category
- PUT /api/v1/admin/categories/{categoryType}/{categoryId} - Update product category
- DELETE /api/v1/admin/categories/{categoryType}/{categoryId} - Delete product category
- GET /api/v1/admin/orders/filtering-options - Get order filtering options
- GET /api/v1/admin/orders - Fetch filtered orders
- GET /api/v1/admin/orders/statuses - Get order statuses
- PATCH /api/v1/admin/orders/{orderId} - Update order status
To view the API documentation, you can use Swagger. Swagger provides a user-friendly interface for exploring and testing the API endpoints.
To run this application, please follow the steps below:
- Clone the repository to your local machine
- Import the project into your IDE
- Update the application.yml file with your data and settings.
- Set up a MySQL database and update the application.yml file with your database details
- Run the application using the command
mvn spring-boot:run
or by running the main method in theWorldOfToysApplication
class - Use a tool such as Postman or Swagger to make requests to the API endpoints.
- In order to locally test POST /api/v1/payment/webhook API endpoint you can use Stripe CLI.
NOTE: The application is independent of a specific relational database, so if you want to use a different database, you only need to remove the MySQL dependency in the pom.xml file and add the dependency for your database.
I have successfully deployed the World of Toys application on Render.com at the following link: World of Toys on Render. The deployment on Render.com provides a convenient way to showcase and access the application online.
-
Mail Server Restrictions:
- Due to hosting constraints, all application endpoints reliant on mail server functionality are restricted. For example, features involving email functionalities (e.g., account activation, password reset) are not work fully.
-
Listen to Stripe events Configuration:
- On the free client-ship plan on the Render.com, certain advanced features, like configuring the application to listen to Stripe events, are limited. This is because some functionalities, especially those involving continuous processing or external webhooks, might go beyond the capabilities of the free hosting plan.
The World of Toys application is accessible at World of Toys on Render. Feel free to explore the available features, keeping in mind the mentioned limitations.
Please note that for a complete experience, especially concerning email functionalities and Stripe event handling, it is advisable to run application at your local machine.
To try out user functionalities, you can use the following credentials:
{
"email": "john.doe@example.com",
"password": "P@ssword123"
}
For admin functionalities, you can use:
{
"email": "jane.smith@example.com",
"password": "P@ssword123"
}
If you would like to contribute to this project, feel free to fork the repository and submit a pull request.
This project is not licensed and is not intended for use or distribution.