Writing the Book-market project was my task. In it, we can register as a user, view a list of books, sort them, or search by categories. We can also add a book to the cart ****and create an order.
For developing the Book-market, I used the following technologies:
Spring Boot 3.4.2
Spring Web 3.4.2
Spring Security 3.4.2
Spring Data JPA 3.4.2
Swagger 2.8.4
Mapstruct 1.6.0.Beta1
Liquibase 4.27.0
MySQL 9.2.0
H2 Default
Spring Tests 3.4.2
Docker 1.20.4 (mysql, junit-jupiter)
Functional
User capabilities:
- Register and log in.
- View all books, sort them by category, or search by title/author/isbn.
- Add books to the cart, update or remove them.
- Create an order and track its status.
Admin capabilities:
- Create, update, or delete book categories and books.
- Soft deletion is enabled, allowing you to restore deleted items if needed.
Book-market`s endpoints:
Auth (/auth):
GET: /registration - Register a new user
GET: /login - Retrieve a token for Bearer authentication
Book (/books):
GET: / - Retrieve a list of books
POST: / - Add a new book (ADMIN only)
PUT: /{id} - Update a book by ID (ADMIN only)
DELETE: /{id} - Soft delete a book (ADMIN only)
GET: /search - Search for books using parameters
Categories (/categories):
GET: / - Retrieve a paginated list of categories
POST: / - Create a new category (ADMIN only)
PUT: /{id} - Update a category by ID (ADMIN only)
GET: /{id} - Retrieve a category by ID
DELETE: /{id} - Soft delete a category (ADMIN only)
GET: /{id}/books - Retrieve books by category
Cart (/cart):
GET: / - Retrieve the authenticated user's cart
POST: / - Add an item to the cart
PUT: /item/{cartItemId} - Update the quantity of an item in the cart
DELETE: /item/{cartItemId} - Soft delete an item from the cart
Orders (/orders):
GET: / - Retrieve a paginated list of user orders
GET: /{id}/items - Retrieve items in a user's order
GET: /{id}/items/{orderId} - Retrieve a specific item from an order
POST: / - Create a new order
PATCH: /{id} - Update order status (ADMIN only)
Running Book-market:
Docker:
-
Install Docker Desktop (if not installed).
-
Configure the .env file with your settings.
-
Open the terminal and run the following commands:
docker-compose build # Build the images
docker-compose up # Start the project
docker-compose down # Stop the project
-
After starting the web server, download book-store.postman_collection.json(in README_FILES).
-
Import it into Postman to test the functionality.
Running Locally
-
Open application.properties.
-
Set the required database properties:
- Database URL
- Username
- Password
-
Press "run"
Briefly, I was interested while writing the book store project. I learned a lot about Spring, project structure, and potential problems I might encounter. The hardest part was implementing authentication logic and the filter chain. And here you can see the result: Link to video
