Skip to content

Dima23-ops5/LitMarket

Repository files navigation

BookWorld Logo

LitMarket


Introduction Introduction


What inspired me to create this project?

The primary inspiration for this project was my desire to build a robust backend system that interacts seamlessly with APIs. I envisioned creating a fully functional online bookstore, a platform that would provide users with an easy-to-navigate interface for browsing, purchasing, and managing books. This project allows me to delve deeper into backend development, honing my skills in API integration, data management, and scalability. By working on this, I aim to create a service that could be expanded upon in the future and potentially serve as a foundation for other API-driven applications.

What problems does my project resolve?

This web application addresses several key issues related to the selection and purchase of books online. It provides a seamless platform where users can easily browse through various book categories, search for specific titles, and make purchases in a user-friendly and efficient manner. The application simplifies the shopping experience by organizing books into relevant categories, allowing users to quickly find what they are looking for.

Moreover, it resolves common challenges such as the difficulty of managing large inventories, offering a well-structured interface that supports both users and administrators in handling data efficiently. The integration of secure payment methods ensures that transactions are safe, further enhancing the overall customer experience. This project also paves the way for scalability, allowing for future expansion to include features such as personalized recommendations, user reviews, and enhanced filtering options.


What can do roles USERS and ADMINISTRATORS?

Role: USER

  • Can register an account.
  • Can search for books based on various criteria (e.g., title, author, ISBN).
  • Can add books to the shopping cart.
  • Can edit their shopping cart (e.g., remove books).
  • Can update the quantity of books in the shopping cart.

Role: ADMINISTRATOR

  • Has the ability to add, update, and delete books in the system.
  • Can manage book categories, including adding, removing, and modifying them.
  • Has the authority to set and modify book prices.


Functionality of controllers Functionality of controllers


Authentication Management Authentication Management

HTTP Request Endpoint Description
POST /auth/registr Register a new user
POST /auth/login Login an existing user

Book Management Book Management

HTTP Request Endpoint Description
GET /books Get a list of all available books
GET /books/{id} Get one book by its ID
POST /books Create book and save to database
PUT /books/{id} Update one book by its ID
DELETE /books/{id} Delete one book from database by its ID
GET /books/search Search book by specific criteria

Categories Management Categories Management

HTTP Request Endpoint Description
POST /categories Create category and save to database
GET /categories Get all available categories
GET /categories/{id} Get one category by its ID
PUT /categories/{id} Update one category by its ID
DELETE /categories/{id} Delete one category from database by its ID
GET /categories/{id}/books Get list of book by categories by the its ID

Order Management Order Management

HTTP Request Endpoint Description
POST /orders Create order and save to database
GET /orders Get all orders made by the user
PATCH /orders/{id} Update order status by its ID
GET /orders/{orderId}/items Get all order items by order ID
GET /orders/{orderId}/items/{itemId} Get information about the order item by order ID and item ID

ShoppingCart Management ShoppingCart Management

HTTP Request Endpoint Description
GET /cart Get users shopping cart
POST /cart Create and add items to shopping cart
PUT /cart/items/{cartItemId} Update quantity by items ID
DELETE /cart/items/{cartItemId} Delete items from shopping cart by items ID

Database structure Database structure


database structure

Getting started project Getting started project


Steps

  1. Prerequisites Docker and Docker Compose on your machine.
  2. Clone the Repository
     git clone https://github.com/Dima23-ops5/StringBootIntro.git
  3. Navigate to the project directory
     cd StringBootIntro
  4. Configure Environment Variables:
  • Create a .env file in the project directory to store your database credentials. This file should contain the necessary environment variables, such as DB_HOST, DB_USER, and DB_PASSWORD.
  • Update the application.properties file located in the src/main/resources directory with your specific database connection details and any other necessary configurations.
  1. Set Up the Environment:

    Ensure Docker and Docker Compose are installed on your system. You can configure environment variables directly in the docker-compose.yml file.

  2. Build and Run the Application:

    docker-compose build
    docker-compose up
  3. Access the Application:

    The application will be available at http://localhost:8080/.


API Documentation


To explore and test the API endpoints, you can use Swagger. Swagger provides interactive API documentation that allows you to test endpoints directly from the browser.


Testing in Postman


  • Postman collection

Book Store.postman_collection.json

  • Short instruction how to use postman collection

You can view the instructional video via this link : https://www.loom.com/share/5989d84459324ed7a4badabb21d7babc?sid=e8b4b142-7767-4cf0-88c7-c3e6ee3140bb

Challanges & Sollution Challenges & Solutions


  1. Controller Testing and User Authentication

One of the most difficult tasks was writing unit tests for the controllers, particularly when dealing with user authentication in the Shopping Cart controller tests. The issue was related to properly authenticating users during the tests. The solution involved ensuring that all required entities were correctly added to the test database and applying the @WithUserDetails annotation on the test class to simulate a logged-in user.

  1. Creating the .jar File and Docker Integration Another significant challenge was correctly generating the .jar file for the project. This issue was compounded by problems with Docker integration. The solution was to update the IntelliJ IDEA settings to specify the correct path to the main class, as well as fixing issues in the pom.xml file. These adjustments ensured that the .jar file was correctly built and integrated with Docker without further issues.

By addressing these challenges with the appropriate solutions, I was able to successfully overcome the obstacles and move forward with the project.


Contacts


For any questions or suggestions, feel free to reach out:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors