An Online Bookstore Application built with Spring Boot, featuring user authentication, book management, shopping cart functionality, order processing, and administrative capabilities with a RESTful API architecture.
- User Authentication/Authorization: User registration/login system using Spring Security with JWT tokens for authentication and role-based authorization (USER/ADMIN roles)
- Book Catalog: Comprehensive Book catalog for browsing books with advanced filtering and pagination
- Shopping Cart: Shopping cart system allowing users to add/remove books, update quantities and proceed to checkout
- Order Processing: Complete ordering system including order placement, status tracking, and order history
- User Favorites: Users are able to favorite and browse their preferred books
- Admin Panel: Administrative capabilities for ADMINs to manage books, carts, orders, and user accounts with role-based access control
- RESTful API: Comprehensive REST endpoints with OpenAPI/Swagger documentation
- Framework: Spring Boot 3.x with Spring MVC architecture
- Security: Spring Security with JWT-based authentication and authorization
- Data Layer:
- Spring Data JPA
- Dockerized PostgreSQL database
- Flyway for database migrations
- Testcontainers for integration testing
- Build System: Maven wrapper
- Testing: JUnit 5, Mockito, Testcontainers
- Documentation: OpenAPI 3.0 specification with Swagger UI integration
- Code Quality:
- Lombok and MapStruct for boilerplate reduction and mapping
- JavaDoc for code documentation
- Checkstyle for static code analysis
- Spotless for code formatting
- Java: Java JDK 21
- Docker Desktop: Docker Desktop installed and running
git clone https://github.com/Vag-Soft/BookStore.git
cd bookstore # Ensure Docker Desktop is running
docker compose up -d
# Run ```docker compose down``` to close and delete
# the main database instance, useful for testing ./mvnw spring-boot:run
# Or run the main class directly in your IDE:
# src/main/java/com/vagsoft/bookstore/BookStoreApplication.java # Git Bash already has OpenSSL installed
cd src/main/resources
openssl genpkey -algorithm RSA -out app.key -outform PEM- Send HTTP requests at
http://localhost:8080 - Check the API docs with Swagger UI at
http://localhost:8080/swagger-ui/index.html - Use the default credentials to log in:
- Username:
admin - Password:
admin
- Username:
- Checkout to the testing branch before running the application for testing purposes.
- Run all unit and integration tests with:
./mvnw test # Or run tests directly in your IDE
- The database will be populated with some initial data the first time the application is executed (look at this file).
- The unit and integration tests use another DB instance that is set up automatically and temporarily when the tests are run.
- Run
docker compose downto close and delete the main database instance
POST /auth/register- User registrationPOST /auth/login- User authentication
GET /books- Browse books with pagination and filteringGET /books/{id}- Get specific book detailsPOST /books- Add a new book (Admin only)PUT /books/{id}- Update a book (Admin only)DELETE /books/{id}- Delete a book (Admin only)
GET /users/me- Get logged-in user profilePUT /users/me- Update logged-in user profileDELETE /users/me- Delete logged-in user accountGET /users- Get users with pagination and filtering (Admin only)GET /users/{id}- Get user by ID (Admin only)PUT /users/{id}- Update user by ID (Admin only)DELETE /users/{id}- Delete user by ID (Admin only)
GET /users/me/favourites- Get logged-in user's favouritesPOST /users/me/favourites- Add favourite for logged-in userDELETE /users/me/favourites/{bookID}- Delete favourite for logged-in userGET /users/{userID}/favourites- Get favourites for a specific user (Admin only)POST /users/{userID}/favourites- Add favourite for a specific user (Admin only)DELETE /users/{userID}/favourites/{bookID}- Delete favourite for a specific user (Admin only)
GET /carts/me- Get logged-in user's cartGET /carts- Get all carts with pagination (Admin only)GET /carts/{userID}- Get a specific cart by user ID (Admin only)
GET /carts/me/items- Get logged-in user's cart itemsPOST /carts/me/items- Add cart item for logged-in userGET /carts/me/items/{bookID}- Get specific cart item for logged-in userPUT /carts/me/items/{bookID}- Update cart item for logged-in userDELETE /carts/me/items/{bookID}- Delete cart item for logged-in userGET /carts/{userID}/items- Get all cart items for a specific user (Admin only)GET /carts/{userID}/items/{bookID}- Get specific cart item for a user (Admin only)PUT /carts/{userID}/items/{bookID}- Update cart item for a specific user (Admin only)DELETE /carts/{userID}/items/{bookID}- Delete cart item for a specific user (Admin only)
GET /orders/me- Get logged-in user's orders with filtering (amount range, status) and paginationPOST /orders/me- Place a new order for logged-in userGET /orders/me/{orderID}- Get specific order for logged-in userGET /orders- Get all orders with filtering (userID, amount range, status) and pagination (Admin only)GET /orders/{orderID}- Get specific order by ID (Admin only)PUT /orders/{orderID}- Update order by ID (Admin only)
GET /orders/me/{orderID}/items- Get order items for logged-in user's specific orderGET /orders/me/{orderID}/items/{bookID}- Get specific order item for logged-in user's orderGET /orders/{orderID}/items- Get all order items for a specific order (Admin only)GET /orders/{orderID}/items/{bookID}- Get specific order item by order ID and book ID (Admin only)
For more details on the API endpoints, refer to the API docs http://localhost:8080/swagger-ui/index.html.
