The Book Management Service is a RESTful web service built with Spring Boot that handles all book-related operations in a library management system. It provides endpoints to manage books, including adding, updating, deleting, and searching for books in the system. This service is part of a larger Service-Oriented Architecture (SOA) for a library system and can communicate with other services like Loan Management and User Management.
- 📖 Add new books: Add new books to the library's collection.
- 🔍 Search for books: Search books by title, author, genre, or ISBN.
- ✏️ Update book information: Modify existing book details.
- 🗑️ Delete books: Remove books from the system.
- 📚 Check book availability: Find out if a book is available for loan or currently on loan.
- Java with Spring Boot to build and manage the overall application
- Maven for project management
- MySQL for storing book data and related information
- Spring Data JPA for database interactions
- Spring Web for RESTful API creation
- Lombok to reduce boilerplate code
- Jersey (JAX-RS): used to create RESTful web services and handle HTTP requests for the Book Management service
HTTP Method | Endpoint | Description |
---|---|---|
POST |
/books |
Add a new book |
GET |
/books/all |
Get a list of all books |
GET |
/books/{id} |
Get details of a specific book by ID |
GET |
/books/search/{keyword} |
Search books by title or genre |
GET |
/books/isbn/{isbn} |
Search books by ISBN |
GET |
/books/author/{author} |
Search books by author |
PUT |
/books/{id} |
Update book details |
DELETE |
/books/{id} |
Delete a book by ID |
GET |
/books/{id}/availability |
Check if a book is available for loan |
PUT |
/books/lend/{id} |
Lend a book (reduce available copies) |
PUT |
/books/return/{id} |
Return a book (increase available copies) |
The Book object is the core entity of the Book Management Service. Below are the key attributes of a book:
- id (
Long
) — Auto-generated unique identifier for each book. - title (
String
) — The title of the book. - author (
String
) — The author(s) of the book. - isbn (
String
) — International Standard Book Number (ISBN) for identifying the book. - genre (
String
) — The genre or category the book belongs to (e.g., Fiction, Science, History). - publishedYear (
int
) — The year the book was first published. - publisher (
String
) — The name of the publishing company. - description (
String
) — A brief summary or description of the book. - totalCopies (
int
) — The total number of copies available in the library. - availableCopies (
int
) — The number of copies currently available for loan.
{
"id": 1,
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"isbn": "9780743273565",
"genre": "Classic Fiction",
"publishedYear": 1925,
"publisher": "Scribner",
"description": "A novel about the American dream, wealth, and social upheaval in the 1920s.",
"totalCopies": 10,
"availableCopies": 5
}
- id: Automatically generated by the system for unique identification.
- title: The official title of the book.
- author: Name(s) of the author(s).
- isbn: Standard identifier that helps uniquely identify books worldwide.
- genre: Describes the book category or genre (e.g., Non-fiction, Science Fiction).
- publishedYear: The year the book was first published, useful for searches by publication date.
- publisher: The organization that published the book, providing additional context.
- description: A short summary to give users an idea of the book’s content.
- totalCopies: How many physical copies the library owns.
- availableCopies: How many of those copies are available for loan, updated dynamically.
- Java 17+
- Maven 3.x
- MySQL for persistent storage
-
Clone the repository:
git clone https://github.com/Yassinekrn/book_management_web_service.git cd book_management_web_service
-
Update application properties: If using H2/PostgreSQL, update the database connection in
src/main/resources/application.properties
:spring.datasource.url=jdbc:mysql://localhost:3306/library spring.datasource.username=root spring.datasource.password=yourpassword
-
Build and run the application:
mvn clean install mvn spring-boot:run
-
The service will start at
http://localhost:8080
.
You can use tools like Postman or curl to test the endpoints:
-
Add a new book:
curl -X POST http://localhost:8080/books -H "Content-Type: application/json" -d '{ "title": "The Great Gatsby", "author": "F. Scott Fitzgerald", "isbn": "9780743273565", "genre": "Classic Fiction", "publishedYear": 1925, "publisher": "Scribner", "description": "A novel about the American dream, wealth, and social upheaval in the 1920s.", "totalCopies": 10, "availableCopies": 10 }'
-
Search for a book by title:
curl "http://localhost:8080/books/search?title=The%20Great%20Gatsby"
By default, the application uses MySQL, but it can be easily configured to use PostgreSQL or H2 according to your personal needs. Just update the application.properties
file accordingly.
- Implement advanced search with filters.
- Add support for book reservations.
Feel free to fork this repository and submit pull requests. For significant changes, please open an issue first to discuss what you would like to change.