Introducing the Bookstore API - Your Online Bookshop! This project is designed to offer a robust online bookstore API powered by Spring Boot. It covers various aspects including user management, book catalog management, shopping cart functionality, order processing, and more. Dive in to discover its features, functionalities, and setup instructions.
- Technologies Used
- Key Functionalities
- Video Presentation
- SQL Database Diagram
- Setup Instructions
- Rising to Challenges
- Contact
- Java: Programming language used as the foundation for the project.
- Spring Boot: Framework for building robust Java applications.
- Spring Security: Provides authentication and authorization capabilities.
- JWT: (JSON Web Token) Standard for securely transmitting information between parties as a JSON object.
- Spring Data JPA: Simplifies the data access layer by abstracting away the boilerplate code.
- Mapstruct: Used for mapping between DTOs and entities.
- Lombok: Library for reducing boilerplate code in Java classes.
- Maven: Build automation tool used for managing dependencies and building the project.
- Liquibase: Manages database schema changes over time.
- Jackson: Provides JSON serialization and deserialization capabilities in Java.
- Swagger: Generates interactive API documentation.
- MySQL: Database for storing application data.
- Docker: For containerizing the application.
- JUnit 5: Framework for unit testing.
- Mockito: Framework for mocking objects in tests.
Feel free to explore the Bookstore API yourself using my Postman collection. If you have any questions or encounter any issues, don't hesitate to reach out. Happy testing!
Below, you'll find detailed explanations for each endpoint in the Postman collection, helping you navigate and understand the functionalities of the Bookstore API more effectively.
π© - publicly available
π¨ - for logged-in users
π₯ - for administrators
- π©
POST: /api/auth/registration
- User Registration: New customers can register with their email, password, and personal details. - π©
POST: /api/auth/login
- User Authentication: Secure login mechanism for registered users.
- π¨
GET: /api/books
- Retrieve Book Catalog: Users can browse the catalog of available books. - π¨
GET: /api/books/{id}
- View Book Details: Users can also check information about each book individually. - π¨
GET: /api/books/search
- Search Books: Users can search for books based on various parameters. - π₯
POST: /api/books
- Add New Book: Admin users can add new books to the catalog. - π₯
PUT: /api/books/{id}
- Update Book Details: Admin users can update existing book details. - π₯
DELETE: /api/books/{id}
- Delete Book: Admin users can remove books from the catalog.
- π¨
GET: /api/categories
- Retrieve Categories: Users can view the list of available categories. - π¨
GET: /api/categories/{id}
- View Category: Users can also check information about each category individually. - π¨
GET: /api/categories/{id}/books
- Get Books by Category: Users can retrieve all books belonging to a specific category. - π₯
POST: /api/categories
- Create Category: Admin users can create new categories for books. - π₯
PUT: /api/categories/{id}
- Update Category: Admin users can update category details. - π₯
DELETE: /api/categories/{id}
- Delete Category: Admin users can delete categories.
- π¨
GET: /api/cart
- View Cart: Users can view the contents of their shopping cart. - π¨
POST: /api/cart
- Add to Cart: Users can add books to their shopping cart. - π¨
PUT: /api/cart/cart-items/{id}
- Update Cart: Users can update the quantity of a specific item in their cart. - π¨
DELETE: /api/cart/cart-items/{id}
- Remove from Cart: Users can remove a specific item from their cart.
- π¨
GET: /api/orders
- View Orders History: Users can view all their orders history. - π¨
GET: /api/orders/{id}/items
- View Order Items: Users can view all items included in a specific order. - π¨
GET: /api/orders/{orderId}/items/{itemId}
- View Specific Order Item: Users can check details of a particular item within an order. - π¨
POST: /api/orders
- Place Order: Users can place orders for the books in their cart. - π₯
PATCH: /api/orders/{id}
- Update Order Status: Admin users can update the status of orders.
For a visual demonstration of how the Bookstore API works and its various functionalities, you can watch the video presentation available here. In this presentation, I walk through the key features of the application, demonstrate its usage with examples, and provide insights into the development process.
Below is a simplified representation of the database schema used in the Bookstore API:
This diagram illustrates the relationships between different entities in the database, including tables for users, books, categories, shopping carts, orders, and more.
Ensure you have Docker and JDK installed
In this project I've used Docker Desktop 4.28.0 (139021)
and Oracle OpenJDK version 20.0.2
- Clone the repository to your local machine.
- Verify you have Docker Engine running.
- Navigate to the project directory.
- Run
./mvnw clean package
to create a .jar file. - In the .env file you should provide necessary DB and Docker variables, here is an example:
MYSQLDB_USER=root
MYSQLDB_ROOT_PASSWORD=1234
MYSQLDB_DATABASE=test
MYSQLDB_LOCAL_PORT=3307
MYSQLDB_DOCKER_PORT=3306
SPRING_LOCAL_PORT=8080
SPRING_DOCKER_PORT=8080
DEBUG_PORT=5005
- Run
docker compose up -d --build
to start the application and MySQL database. - Feel free to test my application using Postman/Swagger.
Postman: Keep in mind that you have to pass Authorization (Bearer Token) that you receive when logging in.
Do you want to test admin features? Here are credentials of sample admin:{ "email": "[email protected]", "password": "1234" }
- To stop and remove containers use
docker compose down
.
Since this is my first relatively comprehensive project, I encountered a few difficulties while working on it. Some of which I was able to deal with fairly quickly, but some of which were able to keep me up at night, solving the most difficult problems was what satisfied me the most. The issues I encountered allowed me to develop the ability to effectively search for solutions, whether using the information in the available documentation, the reliable Stack Overflow or sites like Baeldung. Thanks to the knowledge I gained, I know that the future obstacles in my path I will be able to overcome more and more efficiently.
Thank you for taking the time to explore my Bookstore API!
π§ Want to get in touch? Please, feel free to send me an email at [email protected]