Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Library Management System (Backend)

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.


🚀 Features

🔐 Authentication & Authorization

  • User Registration
  • User Login
  • Password Hashing using bcryptjs
  • JWT Authentication
  • Role-Based Authorization (Admin/User)

📚 Book Management

  • 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

📖 Library Management

  • Borrow Book
  • Return Book
  • View Borrow History
  • Prevent Duplicate Borrowing
  • Automatically Update Available Copies

✅ Validation & Error Handling

  • Required Field Validation
  • Duplicate Email Validation
  • Duplicate ISBN Validation
  • Proper Error Handling
  • Appropriate HTTP Status Codes

🛠️ Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • JWT (JSON Web Token)
  • bcryptjs
  • dotenv
  • Thunder Client

📂 Project Structure

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

⚙️ Installation

1. Clone the Repository

git clone <repository-url>

2. Navigate to the Project Folder

cd Library-Management-System

3. Install Dependencies

npm install

4. Configure Environment Variables

Create a .env file in the project root.

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key

5. Start the Development Server

npm run dev

Server will start at:

http://localhost:5000

📌 API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Login user

Books

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

🔐 Authentication

Protected routes require a valid JWT token.

Authorization: Bearer <your_jwt_token>

📖 Book Schema

{
  "title": "The Alchemist",
  "author": "Paulo Coelho",
  "category": "Fiction",
  "isbn": "9780061122415",
  "totalCopies": 10,
  "availableCopies": 10
}

👤 User Schema

{
  "username": "sana",
  "email": "sana@example.com",
  "password": "********",
  "role": "user",
  "borrowedBooks": [
    {
      "book": "Book ID",
      "borrowDate": "2026-07-17",
      "dueDate": "2026-07-24",
      "returned": false
    }
  ]
}

📊 HTTP Status Codes

Status Code Description
200 Success
201 Created
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error

🧪 API Testing

All API endpoints were tested using Thunder Client.


🔮 Future Enhancements

  • Pagination
  • Sorting and Filtering
  • Dashboard Statistics
  • Fine Management
  • Due Date Notifications
  • Email Notifications
  • React Frontend
  • Project Deployment

👩‍💻 Author

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages