This project is the backend service for an e-commerce application, providing robust user authentication, product management, and order processing functionalities. It leverages technologies like Spring Boot, PostgreSQL, Redis, RabbitMQ and to ensure high performance and scalability. Key features include user registration and login, product CRUD operations, shopping cart management, and integration with payment gateways.
- Java 21
- PostgreSQL 15
- RabbitMQ 3.13
- Redis
- Minio
To run application you need to fulfill all requirements from above. In the root of the project there is a docker
folder with given structure:
docker/
|__ docker-compose.yml
|__ rabbitmq/
|__ definitions.json
|__ rabbitmq.conf
In docker-compose.yml
there is a script for downloading required images and setting containers for local development
out of the box.
Positioned in project directory correctly change directory to docker
with cd docker
and run following commands:
docker compose up -d
This will set up postgres, rabbitmq, redis and minio containers for local development.
At this moment application has two application properties files.
Default one application.properties
and properties for development environment application-dev.properties
. For
running application in development environment and using properties from default and development file use
command from project root directory:
./gradlew bootRun --args='--spring.profiles.active=dev'
All logs will be written to logs/nuvolo.log
and when reaching size of 10MB they will be archived.
There is Postman collection provided http/nuvolo.postman_collection.json
. Import it using Postman
or go
checkout published API documentation on https://documenter.getpostman.com/view/27880902/2sA3QzZ82L.
POST > > /api/v1/auth/register
Description: Registration of new user. Endpoint is not protected and it is publicly available.
POST > /api/v1/auth/sign-in
Description: Sign in. Endpoint is not protected and it is publicly available.
POST > /api/v1/auth/verify/{token}
Description: Verification of user with token over email. Endpoint is not protected and it is publicly available.
POST > /api/v1/auth/request-password-reset
Description: User request forgotten password reset. As a result email with password reset link is sent over email service.
POST > /api/v1/auth/reset-password
Description: User request password reset.
GET > /api/v1/admin/users
Description: Get list of all users.
POST > /api/v1/admin/discount
Description: Admin request for discount creation.
GET > /api/v1/admin/discount
Description: Get all discounts.
POST > /api/v1/admin/category
Description: Admin request for category creation.
POST > /api/v1/admin/product
Description: Admin request to add product. Attach multipart/form-data with valid images and needed data
from ProductRequestDto
DELETE > /api/v1/admin/product/{id}
Description: Admin request to delete product with given ID.
GET > /api/v1/product
Description: Request for all products. Paging is implemented and default values are 0 and 10.
@RequestParam(defaultValue = "0") int page
@RequestParam(defaultValue = "10") int size
GET > /api/v1/product/{id}
Description: Request for specific product with ID.
GET > /api/v1/category
Database is set up using Flyway schemas. If some schemas are changed or models can not be validated application will not be able to run.
Table Name | Description |
---|---|
nuvolo_user | Stores information about users. |
verification | Stores verification tokens for user accounts. |
role | Stores user roles. |
address | Stores user addresses. |
user_role | Associates users with their roles. |
category | Stores product categories. |
discount | Stores discounts for products. |
type | Stores product type. |
product_inventory | Stores information about products stocks. |
product | Stores information products. |
order_details | Stores order details and association with user. |
order_item | Stores information about ordered products. |
review | Stores data about product reviews. |
forgotten_password | Stores data about forgotten passwords reset requests. |
product_image | Stores data about product images. |
Redis is used for storing shopping sessions for users. It is using generated session ID as key which is provided in HTTP
request if session already exists and returns object of ShoppingSession
instance.
@Data
public class ShoppingSession {
private Long userId;
private BigDecimal total;
private LocalDateTime createdAt;
private List<CartItem> cartItems;
}
@Data
public class CartItem {
private Long productId;
private Integer quantity;
}
Minio is high performance object storage system used in project for storing product images. Images are stored with UUID and extension. User can access product images over image URL provided by backend in HTTP response.
Code is covered utilizing JUnit5 and MockitoFramework along with SonarLint for clean code. Coverage is handled using JaCoCo plugin.
For any additional contact you can find information on my personal website https://begjosip.github.io/.