A comprehensive RESTful API for library management, providing robust functionality for book cataloging, user management, loan tracking, and library administration.
- Book Management: Add, update, delete, and search books with comprehensive metadata
- Author Management: Track authors and their bibliographies
- Publisher Management: Organize books by publishers
- Category Management: Categorize books for easy browsing and filtering
- Loan System: Track borrowing with automated due date calculations and returns
- User Score System: Dynamic scoring based on loan history
- Role-Based Access Control: Admin, staff, and member user types
- JWT Authentication: Secure API access with token-based authentication
- Dynamic Borrowing Rules: Customized borrowing limits based on user score
- Java 17
- Spring Boot 3.x
- Spring Security with JWT Authentication
- Spring Data JPA & Hibernate
- PostgreSQL Database
- Maven
- RESTful API Design
- DTO Pattern & Custom Mappers
- Global Exception Handling
- Lombok
- JDK 17+
- Maven 3.6+
- PostgreSQL 12+
-
Clone the repository
git clone https://github.com/ffozdemir/LibraryManagement.git cd LibraryManagement -
Configure database
spring.datasource.url=jdbc:postgresql://localhost:5432/librarydb spring.datasource.username=postgres spring.datasource.password=yourpassword spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.format_sql=true
-
Build the project
mvn clean install
-
Run the application
mvn spring-boot:run
POST /auth/login- User loginPOST /auth/register- Register new user
GET /user/users- List all users (Admin)GET /user/users/{id}- Get user by IDPUT /user/users/{id}- Update userDELETE /user/users/{id}- Delete userPOST /user/users- Create new userGET /user/user- Get current user informationGET /user/user/loans- Get loans for current user
GET /book/books- List all booksGET /book/books/{id}- Get book by IDPOST /book/books- Create new bookPUT /book/books/{id}- Update bookDELETE /book/books/{id}- Delete book
GET /author/authors- List all authorsGET /author/authors/{id}- Get author by IDPOST /author/authors- Add new authorPUT /author/authors/{id}- Update authorDELETE /author/authors/{id}- Delete author
GET /publisher/publishers- List all publishersGET /publisher/publishers/{id}- Get publisher by IDPOST /publisher/publishers- Add new publisherPUT /publisher/publishers/{id}- Update publisherDELETE /publisher/publishers/{id}- Delete publisher
GET /category/categories- List all categoriesGET /category/categories/{id}- Get category by IDPOST /category/categories- Add new categoryPUT /category/categories/{id}- Update categoryDELETE /category/categories/{id}- Delete category
GET /loan/loans- List all loansGET /loan/loans/{id}- Get loan detailsPOST /loan/loans- Create new loanPUT /loan/loans/{id}- Update loan (return book)GET /loan/loans/user/{id}- Get loans by user IDGET /loan/loans/book/{id}- Get loans by book IDGET /loan/loans/auth/{id}- Get authenticated user's loans
GET /report/report- Get general reportGET /report/report/most-popular-books- Get most borrowed booksGET /report/report/most-borrowers- Get most active borrowersGET /report/report/unreturned-books- Get currently unreturned booksGET /report/report/expired-books- Get overdue books
- ADMIN: Full system access, user management, reports
- STAFF: Book and loan management, limited user operations
- MEMBER: Book browsing, own loan management
User score determines borrowing privileges:
- Score < -1: 1 book for 3 days
- Score < 0: 2 books for 6 days
- Score < 1: 3 books for 10 days
- Score < 2: 4 books for 15 days
- Score >= 2: 5 books for 20 days
├── src/main/java/com/ffozdemir/librarymanagement
│ ├── config # Configuration classes
│ │ ├── OpenAPIConfig.java # Swagger configuration
│ │ └── WebSecurityConfig.java
│ ├── controller # REST controllers
│ │ ├── business # Book, Author, etc. controllers
│ │ └── user # User-related controllers
│ ├── entity # Entity classes
│ │ ├── abstracts # Base entity classes
│ │ ├── concretes # Concrete entity implementations
│ │ └── enums # Enumeration types
│ ├── exception # Exception handling
│ │ ├── GlobalExceptionHandler.java
│ │ └── custom exceptions
│ ├── payload # DTOs and mappers
│ │ ├── mappers # Entity-DTO conversion
│ │ ├── messages # Error messages
│ │ ├── request # Request DTOs
│ │ └── response # Response DTOs
│ ├── repository # Data repositories
│ │ ├── business # Business entities repositories
│ │ └── user # User-related repositories
│ ├── security # JWT and security config
│ ├── service # Business logic
│ │ ├── business # Book, Author services
│ │ ├── helper # Helper services
│ │ └── user # User-related services
│ └── LibrarymanagementApplication.java
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
For questions or feedback, please contact fetullahfurkanozdemir@gmail.com