Introducing my Java-based "Online Book Shop" backend app, an efficient solution for book enthusiasts! Users experience seamless Registration and Login processes, accessing a well-organized catalog of Books sorted by Categories. Admins wield authority to effortlessly manage products and categories. Users can explore books, either via a complete list or specific parameters. The Shopping Cart feature enables easy addition, modification, and viewing of selected items. Ordering is simplified, allowing users to seamlessly transition from cart to order. Keeping users informed, order status monitoring ensures a transparent and satisfying shopping experience.
- JDK 17
- Apache Maven 3.11.0
- Spring Boot Starter Web 3.1.4
- Spring Security Test 3.1.4
- Spring Security Test 3.1.4
- Spring Boot Starter Data JPA 3.1.4
- Spring Boot Starter Validation 3.1.4
- MySQL Connector 8.x
- Hibernate Validator 8.0.1.Final
- H2 Database (for testing)
- Liquibase 4.20.0
- Tomcat 9.0.78
- jjwt-api 0.11.5
- jjwt-impl 0.11.5
- jjwt-jackson 0.11.5
- Testcontainers 1.18.0 (for Docker-based testing)
- Testcontainers MySQL
- Project Lombok 4.20.0
- Lombok MapStruct Binding 0.2.0
- Springdoc-openapi-starter-webmvc-ui 2.2.0
- Springdoc-openapi-ui 1.6.12
- JSON Web Token (JWT)
- MapStruct 1.5.5.Final
- Spring Boot Docker Compose
- Maven Checkstyle Plugin 3.3.0
- Maven Compiler Plugin 3.11.0
- Testcontainers BOM (Bill of Materials) 1.18.0
1. Authentication and Authorization
The Online Book Store is a robust Java web application adhering to fundamental principles of web
development, including REST architecture. Ensuring secure access, the application utilizes Spring
Security JWT Authentication & Authorization with a Bearer Token mechanism.
2. Models:
- Book
- Category
- User
- Role
- ShoppingCart
- CartItem
- Order
- OrderItem
3. Controller Level:
- AuthorizationController: Manages authentication and authorization.
- BookController: Handles book-related operations.
- createBook - "Create a new book", hasRole('ADMIN'),
- updateBook - "Update a book by id according to the parameters", hasRole('ADMIN'),
- delete - "Delete a book by id", hasRole('ADMIN'),
- getAll - "Get a list of all available books",
- findById - "Get a book by id if it's available",
- searchBooks - "Get a list of all books according to the parameters".
- CategoryController: Manages book categories.
- createCategory - "Create a new category", hasRole('ADMIN'),
- updateCategory - "Update a category by id according to the parameters", hasRole('ADMIN'),
- deleteCategory - "Delete a category by id", hasRole('ADMIN'),
- getAll - "Get a list of all available categories",
- findById - "Get a category by id if it's available",
- getBooksByCategoryId - "Get all books by category id if it's available".
- OrderController: Manages user orders.
- createOrder - "Add new item to the shopping card",
- getAll - "Get a list of all available user's orders",
- updateOrderStatus - "Update the status of the order by id according to the parameters", hasRole('ADMIN'),
- getAllOrderItemsByOrderId - "Get a list of all available order's items",
- getOrderItemByOrderIdAndItemId - "Get item by itemID and orderId".
- ShoppingCartController: Manages shopping cart operations.
- getShoppingCartByUserEmail - "Get user's shopping cart with all available items",
- addItemToShoppingCart - "Add new item to the shopping card",
- updateQuantityByItemId - "Update the quantity of the item in the shopping cart",
- delete - "Remove the item from user's shopping cart by id".
- UserController: Handles user-related operations.
- delete - "Delete a user by id", hasRole('ADMIN').
4. Repository Level:
Repository: Handles repositories Interfaces and Classes for all models
5. Find Book by parameters
Provides find a book by parameters: "Author", "Price" and "Title"
6. DTO Level.
Handles different DTO models for all controllers.
7. Mapper Level.
Handles Mappers for all models.
8. Security Level:
AuthenticationService: Implements user authentication.
Token Logic: Handles the creation and validation of tokens.
9. Service Level:
Service Classes: Implements business logic for all controllers.
10. Validation:
Custom Annotations: Custom validation annotations.
11. Exceptions:
CustomGlobalExceptionHandler: Handles custom exceptions globally.
12. Resources:
Data Setup: YAML files for creating tables and inserting data.
Changelog: Liquibase changelog file (db.changelog-master.yaml).
13. Configuration:
application.properties: Application-specific configurations.
14. Liquibase Configuration:
liquibase.properties: Configuration for Liquibase.
15. Testing:
Controller Tests: Unit tests for controller logic.
Service Tests: Unit tests for service classes.
Repository Tests: Unit tests for data access logic.
1. For use the application you should already have MySQL DB installed.
2. Clone the repository.
3. Use IDE to build and run an application.
4. Use Postman and/or Swagger to work with the application.
Swagger will be available by URL: http://localhost:8081/swagger-ui/index.html#/
Please feel free to check all the functionality using Swagger!
Also, you will be able to work with the application by using Postman.
You will get a few already saved users and books:
ADMIN
login: [email protected]
password: 1234
USER
login: [email protected]
password: 1234
You can try all the functionality of the application using these pre-saved users.
Add a new User:
Here is a list of the Postman request collections you can work with:
OnlineBookStorePostmanCollection.json
Here is a link to a video with a brief description of the functionality of my application:
https://www.loom.com/share/19cd5c522677448ca0b560db6cb8012f?sid=3130d735-207e-4bc8-989f-62df11577e81