Library Management System (Spring Boot + Basic Authentication)
A simple and secure REST API-based Library Management System built with Spring Boot, Spring Security (Basic Authentication), JPA, and MySQL.
This project allows Admins to manage books and Members to issue/return books.
| Module | User Action | Admin Action |
|---|---|---|
| Authentication | Register, Login (Basic Auth) | Create default Admin via code |
| Members | View own books | View all members |
| Books | View book list | Add, Update, Delete |
| Book Issue | Issue + Return books | Approve / Monitor |
This project uses Spring Security Basic Authentication.
| Role | Permissions |
|---|---|
| ROLE_USER | Can view books and issue/return |
| ROLE_ADMIN | Full access to books and members |
email: admin@example.com password: Admin@123
| Technology | Version |
|---|---|
| Java | 17+ |
| Spring Boot | 3.x |
| Spring Security | Basic Auth |
| MySQL / H2 | Supported |
| JPA / Hibernate | ORM |
| Lombok | Boilerplate reduction |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register |
❌ Public | Register new member |
| Method | Endpoint | Auth | Role |
|---|---|---|---|
| GET | /api/books |
✔ | USER / ADMIN |
| POST | /api/books |
✔ | ADMIN |
| PUT | /api/books/{id} |
✔ | ADMIN |
| DELETE | /api/books/{id} |
✔ | ADMIN |
| Method | Endpoint | Auth | Role |
|---|---|---|---|
| POST | /api/books/{bookId}/issue/{memberId} |
✔ | USER / ADMIN |
| PUT | /api/books/{issueId}/return |
✔ | USER / ADMIN |
| Method | Endpoint | Auth | Role |
|---|---|---|---|
| GET | /api/members |
✔ | ADMIN |
| GET | /api/members/{id} |
✔ | ADMIN |
Use Basic Auth inside Postman:
Username = email
Password = plain-text password
Example login → View books:
GET /api/books
Authorization: Basic base64(email:password)
spring.datasource.url=jdbc:mysql://localhost:3306/library
spring.datasource.username=root
spring.datasource.password=yourpassword
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=truegit clone <your-repo-url>
cd library-management
mvn clean install
mvn spring-boot:runServer starts at:
http://localhost:8080
Harsh Singh 📌 Full-Stack Java Developer
Pull requests are welcome — feel free to fork and improve the project!
If you like this project, don’t forget to ⭐ star the repo on GitHub 🚀