A RESTful backend application built using Node.js, Express.js, MongoDB, and Mongoose following the MVC Architecture. The system provides secure user authentication, role-based authorization, complete book management, borrowing and returning functionality, borrowing history, search features, and automatic book availability management.
- User Registration
- User Login
- Password Hashing using bcryptjs
- JWT Authentication
- Role-Based Authorization (Admin/User)
- Add Book (Admin)
- Update Book (Admin)
- Delete Book (Admin)
- View All Books
- View Single Book
- Search Books by Title, Author, or Category
- View Available Books
- View Unavailable Books
- Borrow Book
- Return Book
- View Borrow History
- Prevent Duplicate Borrowing
- Automatically Update Available Copies
- Required Field Validation
- Duplicate Email Validation
- Duplicate ISBN Validation
- Proper Error Handling
- Appropriate HTTP Status Codes
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT (JSON Web Token)
- bcryptjs
- dotenv
- Thunder Client
Library-Management-System/
│
├── config/
│ └── db.js
│
├── controllers/
│ ├── authController.js
│ └── bookController.js
│
├── middleware/
│ ├── authMiddleware.js
│ └── adminMiddleware.js
│
├── models/
│ ├── User.js
│ └── Book.js
│
├── routes/
│ ├── authRoute.js
│ └── bookRoute.js
│
├── .env
├── .gitignore
├── package.json
├── package-lock.json
├── server.js
└── README.md
git clone <repository-url>cd Library-Management-Systemnpm installCreate a .env file in the project root.
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_keynpm run devServer will start at:
http://localhost:5000
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register a new user |
| POST | /api/auth/login |
Login user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/book/add |
Add Book (Admin) |
| GET | /api/book/getall |
Get All Books |
| GET | /api/book/get/:id |
Get Single Book |
| PUT | /api/book/update/:id |
Update Book (Admin) |
| DELETE | /api/book/delete/:id |
Delete Book (Admin) |
| GET | /api/book/search?keyword=value |
Search Books |
| GET | /api/book/available |
Get Available Books |
| GET | /api/book/unavailable |
Get Unavailable Books |
| POST | /api/book/:id/borrow |
Borrow Book |
| POST | /api/book/:id/return |
Return Book |
| GET | /api/book/getmybooks |
View Borrow History |
Protected routes require a valid JWT token.
Authorization: Bearer <your_jwt_token>{
"title": "The Alchemist",
"author": "Paulo Coelho",
"category": "Fiction",
"isbn": "9780061122415",
"totalCopies": 10,
"availableCopies": 10
}{
"username": "sana",
"email": "sana@example.com",
"password": "********",
"role": "user",
"borrowedBooks": [
{
"book": "Book ID",
"borrowDate": "2026-07-17",
"dueDate": "2026-07-24",
"returned": false
}
]
}| Status Code | Description |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 500 | Internal Server Error |
All API endpoints were tested using Thunder Client.
- Pagination
- Sorting and Filtering
- Dashboard Statistics
- Fine Management
- Due Date Notifications
- Email Notifications
- React Frontend
- Project Deployment
Sana Kolhapure
Backend Developer | Node.js | Express.js | MongoDB | REST APIs
This version is cleaner, follows common GitHub README formatting, fixes grammar, and looks more professional for recruiters and portfolio reviewers.