|
| 1 | +📚 Online Book Store API |
| 2 | +A comprehensive backend application for managing an online bookstore, built with Java and Spring Boot. It offers full CRUD functionality for books, categories, shopping carts, and orders, along with user authentication and role-based access control. |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +🎯 Project Overview |
| 7 | +This application serves as the backend for an online book store, supporting two roles: |
| 8 | + |
| 9 | +• **Shopper (User)** |
| 10 | +- Sign up / Sign in |
| 11 | +- Browse books by category or all at once |
| 12 | +- View book details |
| 13 | +- Add/remove books to/from cart |
| 14 | +- Place orders and view order history |
| 15 | + |
| 16 | +• **Manager (Admin)** |
| 17 | +- Add, update, delete books |
| 18 | +- Manage categories |
| 19 | +- Update order status |
| 20 | + |
| 21 | +The system is structured around 8 core domain models: |
| 22 | +`User`, `Role`, `Book`, `Category`, `ShoppingCart`, `CartItem`, `Order`, `OrderItem` |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +🚀 Technologies & Tools |
| 27 | + |
| 28 | +| Tool | Description | |
| 29 | +|--------------------|----------------------------------| |
| 30 | +| Java 21 | Core language | |
| 31 | +| Spring Boot 3.4.1 | Main framework | |
| 32 | +| Spring Security | Authentication & authorization | |
| 33 | +| Spring Data JPA | Data persistence | |
| 34 | +| JWT | Token-based authentication | |
| 35 | +| MapStruct | DTO mapping | |
| 36 | +| Liquibase | DB schema management | |
| 37 | +| Hibernate Validator| Input validation | |
| 38 | +| Testcontainers | Integration tests with Docker | |
| 39 | +| MySQL / H2 | Databases (prod/test) | |
| 40 | +| Swagger | API documentation | |
| 41 | +| Lombok | Less boilerplate | |
| 42 | +| Checkstyle | Code quality | |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +🔌 API Endpoints Overview |
| 47 | + |
| 48 | +✅ **Authentication** |
| 49 | +- `POST /api/auth/register` – Register a new user |
| 50 | +- `POST /api/auth/login` – Login and receive a JWT token |
| 51 | + |
| 52 | +📚 **Book** |
| 53 | +- `GET /api/books` – List all books |
| 54 | +- `GET /api/books/{id}` – View book by ID |
| 55 | +- `POST /api/books` – Add a book (admin only) |
| 56 | +- `PUT /api/books/{id}` – Update book |
| 57 | +- `DELETE /api/books/{id}` – Delete book |
| 58 | +- `GET /api/books/search` – Search books |
| 59 | + |
| 60 | +🏷️ **Category** |
| 61 | +- `POST /api/categories` – Add a category |
| 62 | +- `GET /api/categories` – List categories |
| 63 | +- `GET /api/categories/{id}` – View category |
| 64 | +- `PUT /api/categories/{id}` – Update category |
| 65 | +- `DELETE /api/categories/{id}` – Delete category |
| 66 | +- `GET /api/categories/{id}/books` – View books in category |
| 67 | + |
| 68 | +🛒 **Shopping Cart** |
| 69 | +- `GET /api/cart` – View cart |
| 70 | +- `POST /api/cart` – Add item to cart |
| 71 | +- `PUT /api/cart/cart-items/{cartItemId}` – Update item |
| 72 | +- `DELETE /api/cart/cart-items/{cartItemId}` – Remove item |
| 73 | + |
| 74 | +📦 **Order** |
| 75 | +- `POST /api/orders` – Place an order |
| 76 | +- `GET /api/orders` – View order history |
| 77 | +- `GET /api/orders/{orderId}/items` – Items in an order |
| 78 | +- `GET /api/orders/{orderId}/items/{itemId}` – View specific item |
| 79 | +- `PATCH /api/orders/{id}` – Update order status |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +🌐 Live Demo |
| 84 | + |
| 85 | +🧪 Swagger UI after starting the application locally: |
| 86 | +http://localhost:8080/swagger-ui.html |
| 87 | + |
| 88 | +📹 YouTube Demo: |
| 89 | +https://youtu.be/K64DTGeaMEM |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +🔐 Default Users |
| 94 | + |
| 95 | +| Role | Email | Password | |
| 96 | +|-------|---------------------|---------------| |
| 97 | +| Admin | admin@example.com | adminExample | |
| 98 | +| User | user@example.com | userExample | |
| 99 | + |
| 100 | +🛠️ These accounts are automatically created on application startup via `DataInitializer`. |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +⚙️ Setup Instructions |
| 105 | + |
| 106 | +✅ **Prerequisites** |
| 107 | +- Java 17+ |
| 108 | +- Docker |
| 109 | +- Maven |
| 110 | + |
| 111 | +🧪 **Clone & Run Locally** |
| 112 | +```bash |
| 113 | +# Clone repo |
| 114 | +git clone https://github.com/dedis34/SpringBoot-BookShop.git |
| 115 | + |
| 116 | +# Package app |
| 117 | +./mvnw clean package |
| 118 | + |
| 119 | +# Run app with Docker |
| 120 | +docker compose up |
0 commit comments