This RESTful API organizes management for an online bookstore. Afford customers to search for desired books, view books by sections of the bookshelf, make purchases of books by adding them to the cart, and also view the purchase history. App provide for managers the opportunity arrange books, organize bookshelf sections, look at and change receipts.
- User: Contains information about the registered user including their authentication details and personal information.
- Role: Represents the role of a user in the system, for example, admin or user.
- Book: Represents a book available in the store.
- Category: Represents a category that a book can belong to.
- ShoppingCart: Represents a user's shopping cart.
- CartItem: Represents an item in a user's shopping cart.
- Order: Represents an order placed by a user.
- OrderItem: Represents an item in a user's order.
- Shopper (User): Someone who looks at books, puts them in a basket (shopping cart), and buys them.
- Manager (Admin): Someone who arranges the books on the shelf and watches what gets bought.
- Java
- Spring Boot
- Spring Security
- Spring Data JPA
- Docker
- JWT
- Junit
- Liquibase
- Lombok
- Mapstruct
- MySql
- Swagger
- Git
- Maven
- Java 17+
- Docker
-
Clone the project from the GitHub:
$ git clone https://github.com/furthernull/book-store.git -
Go to root directory with project:
$ cd book-store -
Create and fulfill
.envfile in the root folder with project:MYSQLDB_USER=mysql_database_user MYSQLDB_PASSWORD=password MYSQLDB_ROOT_PASSWORD=sql_database_password MYSQLDB_DATABASE=book_store MYSQLDB_LOCAL_PORT=3307 MYSQLDB_DOCKER_PORT=3306 SPRING_LOCAL_PORT=8088 SPRING_DOCKER_PORT=8080 DEBUG_PORT=5005 -
Build the project you can run the command:
$ mvn clean install -
Build the image, run docker command:
$ docker-compose build -
Run container:
$ docker-compose up
For test functionalities and explore the feature via swagger.
To do this, run the app and follow this link
http://localhost:8088/api/swagger-ui/index.html.
For authenticate, use credentials: username admin@bookapp.com
and password password, (this is registered default admin user).
Also, opportunity interact through any http-client such as postman.
- Authentication controller
| HTTP-method | url | description |
|---|---|---|
| POST | localhost:8088/api/auth/login | login registered user |
| POST | localhost:8088/api/auth/registration | register new user |
- Category controller
| HTTP-method | url | description |
|---|---|---|
| POST | localhost:8088/api/categories | create category |
| GET | localhost:8088/api/categories | get all categories |
| GET | localhost:8088/api/categories/{id} | get categories by id |
| PUT | localhost:8088/api/categories/{id} | update category(admin only) |
| DEL | localhost:8088/api/categories/{id} | delete category(admin only) |
| GET | localhost:8088/api/categories/{id}/books | get books by category id |
- Book controller
| HTTP-method | url | description |
|---|---|---|
| POST | localhost:8088/api/books | create book |
| GET | localhost:8088/api/books | get all books |
| GET | localhost:8088/api/books/{id} | get book by id |
| GET | localhost:8088/api/books/search | search book |
| PUT | localhost:8088/api/books/{id} | update book |
| DEL | localhost:8088/api/books/{id} | delete book |
- Shopping cart controller
| HTTP-method | url | description |
|---|---|---|
| POST | localhost:8088/api/cart | add book |
| GET | localhost:8088/api/cart | get shopping cart |
| GET | localhost:8088/api/cart/items/{cartItemId} | update cart items |
| DEL | localhost:8088/api/cart/items/{cartItemId} | delete cart items |
- Order controller
| HTTP-method | url | description |
|---|---|---|
| POST | localhost:8088/api/orders | place order |
| GET | localhost:8088/api/orders | get order history |
| GET | localhost:8088/api/orders/{orderId}/items | get order details |
| GET | localhost:8088/api/orders/{orderId}/items/{id} | get specific item |
| PATCH | localhost:8088/api/orders/{id}/ | update order details(admin only) |
Run test, execute the comand:
$ mvn test
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.


