This project involves the development of a CRUD Web API for simulating a library system using the Spring framework.
To run this project, follow these steps:
- Clone the repository.
- Configure the database settings in
config-server
. - Build and run the project using Maven or your IDE.
- Retrieve a list of all books.
- Get a specific book by its ID.
- Find a book by its ISBN.
- Add a new book.
- Update information about an existing book.
- Delete a book.
- Develop an additional service (LibraryService) for tracking available books.
- Upon adding a new book in the primary service, send a request (synchronous or asynchronous) containing the book ID.
- The new service stores information about:
- The book (ID).
- Time when the book was borrowed.
- Time when the book is due to be returned.
- Retrieve a list of available books.
- Modify book information.
- Spring Boot 3
- Java 17
- ORM: Spring Data JPA
- RDBMS: MySQL (database per microservice)
- Spring Cloud Config
- API Gateway
- Eureka Discovery
- Apache Kafka for user notifications on order creation
- OpenAPI Swagger
- Maven Multi-Module Project
- Spring Security for authentication
- MapStruct
- Docker for containerization and deployment
- Clone project
git clone https://github.com/artemelyashevich/library-api.git
- Start kafka (from kafka directory in your pc)
.\bin\windows\kafka-server-start.bat ..\..\config\server.propertie
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
- Start Config Server
cd .\config-server\
mvn spring-boot:run
- Start Discovery Service
cd .\discovery\
mvn spring-boot:run
- Start Gateway Service
cd .\gateway\
mvn spring-boot:run
- Start Book Service
cd .\book-service\
mvn spring-boot:run
- Start Library Service
cd .\library-service\
mvn spring-boot:run
- Start Auth Service
cd .\authentication-service\
mvn spring-boot:run
### Expext code 201 & auth token
POST http://localhost:8222/api/v1/auth/register
Content-Type: application/json
{
"email": "example@example.com",
"password": "password12345"
}
### Expext code 201 & auth token
POST http://localhost:8222/api/v1/auth/login
Content-Type: application/json
{
"email": "example@example.com",
"password": "password12345"
}
### Expext code 200 & auth token
POST http://localhost:8222/api/v1/auth/{token}
### Expect code 200 & list of books
GET http://localhost:8222/api/v1/books
### Expect code 200 & book (if exists)
GET http://localhost:8222/api/v1/books/{bookId}
### Expect code 201 & book
POST http://localhost:8222/api/v1/books
{
"title": "The Great Gatsby",
"description": "A story of the Jazz Age",
"genre": "Classic",
"author": "F. Scott Fitzgerald",
"isbn": "111-1111111111"
}
### Expect code 200 & book
PATCH http://localhost:8222/api/v1/books/{bookId}
{
"title": "The Great Gatsby",
"description": "A story of the Jazz Age",
"genre": "Classic",
"author": "F. Scott Fitzgerald",
"isbn": "111-1111111111"
}
### Expect code 204 if book exists
DELETE http://localhost:8222/api/v1/books/{bookId}
### Expect code 202
POST http://localhost:8222/api/v1/books/order
### Expect code 200 & list of orders
GET http://localhost:8222/api/v1/library/active
### Expect code 200 & list of not expired orders
GET http://localhost:8222/api/v1/library/active
### Expect code 200 & order (if exists)
GET http://localhost:8222/api/v1/library/{orderId}
### Expect code 201 & book
POST http://localhost:8222/api/v1/library
{
"bookId": "bookId-example",
"expireIn": "",
"orderIn": "",
}
### Expect code 200 & order
PATCH http://localhost:8222/api/v1/library/{orderId}
{
"bookId": "bookId-example",
"expireIn": "",
"orderIn": "",
}
### Expect code 204 if order exists
DELETE http://localhost:8222/api/v1/library/{orderId}