-
Notifications
You must be signed in to change notification settings - Fork 0
Enchoz/book-management-system
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
# Book Management System A RESTful web service for managing a library's book inventory and borrowing system. ## Features - CRUD operations for books - Search functionality by title or author - Book borrowing and return management - Bulk upload of books via CSV - Borrowing report generation - Pagination support - OpenAPI documentation ## Technical Stack - Java 21 - Spring Boot 3.2.0 - Spring Data JPA - H2 Database - OpenAPI (Swagger) for documentation - Maven for dependency management - JUnit 5 & Mockito for testing ## Prerequisites - JDK 21 or higher - Maven 3.8 or higher ## Running the Application 1. Clone the repository 2. Navigate to the project directory 3. Build the project: ```bash mvn clean install ``` 4. Run the application: ```bash mvn spring-boot:run ``` The application will start on `http://localhost:8080` ## API Documentation Once the application is running, you can access the OpenAPI documentation at: - Swagger UI: `http://localhost:8080/swagger-ui.html` - OpenAPI JSON: `http://localhost:8080/v3/api-docs` ## Database Console The H2 database console is available at `http://localhost:8080/h2-console` with these credentials: - JDBC URL: `jdbc:h2:mem:bookdb` - Username: `sa` - Password: `password` ## Testing Run the tests using: ```bash mvn test ``` ## API Endpoints ### Books - GET `/api/v1/books` - Get all books (paginated) - GET `/api/v1/books/{isbn}` - Get book by ISBN - POST `/api/v1/books` - Create new book - PUT `/api/v1/books/{isbn}` - Update book - DELETE `/api/v1/books/{isbn}` - Delete book - GET `/api/v1/books/search?query={query}` - Search books ### Borrowing - POST `/api/v1/books/{isbn}/borrow` - Borrow a book - POST `/api/v1/books/{isbn}/return` - Return a book - GET `/api/v1/books/borrowing-report` - Generate borrowing report ### Bulk Operations - POST `/api/v1/books/bulk-upload` - Bulk upload books via CSV ## CSV Format for Bulk Upload The CSV file should have the following headers: ```csv ISBN,title,author,publication_year,copies ``` Example: ```csv 9780132350884,Clean Code,Robert C. Martin,2008,5 9780134494166,Clean Architecture,Robert C. Martin,2017,3 9781449331818,Learning JavaScript Design Patterns,Addy Osmani,2012,4 ``` ## Error Handling The API uses standard HTTP status codes: - 200: Success - 201: Created - 204: No Content - 400: Bad Request - 404: Not Found - 500: Internal Server Error Error responses follow this format: ```json { "error": "Detailed error message" } ``` For validation errors: ```json { "fieldName": "Validation error message" } ``` ## Example API Usage ### Creating a Book ```bash curl -X POST http://localhost:8080/api/v1/books \ -H "Content-Type: application/json" \ -d '{ "isbn": "9780132350884", "title": "How Everything Works", "author": "Ozioma Ene", "publicationYear": 2024, "copiesInStock": 5 }' ``` ### Searching Books ```bash curl http://localhost:8080/api/v1/books/search?query=Clean&page=0&size=10 ``` ### Generating Borrowing Report ```bash curl "http://localhost:8080/api/v1/books/borrowing-report?startDate=2024-01-01T00:00:00&endDate=2024-12-31T23:59:59" ``` ## Configuration The application can be configured through `application.yml`. Key configuration options: - Server port - Database settings - Logging levels - Swagger settings ## Contributing 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/AmazingFeature`) 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request
About
A RESTful web service for managing a library's book inventory and borrowing system.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published