Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Management System (Spring Boot + Basic Authentication)

📚 Library Management System — Spring Boot

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.


🚀 Features

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

🔐 Security

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

➤ Default Admin (auto-created)

email: admin@example.com password: Admin@123


🛠 Tech Stack

Technology Version
Java 17+
Spring Boot 3.x
Spring Security Basic Auth
MySQL / H2 Supported
JPA / Hibernate ORM
Lombok Boilerplate reduction

⚙️ API Endpoints

🔹 Authentication

Method Endpoint Auth Description
POST /api/auth/register ❌ Public Register new member

🔹 Books

Method Endpoint Auth Role
GET /api/books USER / ADMIN
POST /api/books ADMIN
PUT /api/books/{id} ADMIN
DELETE /api/books/{id} ADMIN

🔹 Issue Book

Method Endpoint Auth Role
POST /api/books/{bookId}/issue/{memberId} USER / ADMIN
PUT /api/books/{issueId}/return USER / ADMIN

🔹 Members

Method Endpoint Auth Role
GET /api/members ADMIN
GET /api/members/{id} ADMIN

🧪 Postman Testing

Use Basic Auth inside Postman:


Username = email
Password = plain-text password

Example login → View books:


GET /api/books
Authorization: Basic base64(email:password)


💾 Database Setup

🔹 application.properties (MySQL)

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=true

▶️ How to Run

git clone <your-repo-url>
cd library-management
mvn clean install
mvn spring-boot:run

Server starts at:

http://localhost:8080

👤 Created By

Harsh Singh 📌 Full-Stack Java Developer


⭐ Contribute

Pull requests are welcome — feel free to fork and improve the project!


🙌 Support

If you like this project, don’t forget to ⭐ star the repo on GitHub 🚀

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages