Skip to content

Issah721/ILMS-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ILMS Backend - Intelligent Library Management System

A robust, production-ready RESTful API backend for the Intelligent Library Management System (ILMS), built with Node.js, Express, and MongoDB. This system manages books, users, borrowing transactions, and provides AI-powered recommendations and dashboard analytics.

🚀 Features

  • Authentication & Authorization

    • Secure JWT-based authentication
    • Role-based access control (Admin vs. Student)
    • Password hashing with bcrypt
  • Book Management

    • Complete CRUD operations
    • Advanced search (Title, Author, ISBN)
    • Filtering by genre and sorting
    • Pagination support
  • Transaction System

    • Borrow and return workflows
    • Automatic due date calculation
    • Availability tracking
    • Duplicate borrow prevention
  • AI Recommendations

    • Personalized book suggestions based on borrowing history
    • Heuristic-based matching algorithm
  • Dashboard Analytics

    • Real-time statistics for administrators
    • User and book metrics
  • Security & Reliability

    • Helmet for secure HTTP headers
    • CORS configuration
    • Rate limiting ready
    • Global error handling
    • MongoDB connection retry logic

📋 Tech Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB (Atlas or Local) with Mongoose ODM
  • Authentication: JSON Web Tokens (JWT)
  • Security: bcryptjs, helmet, cors
  • Logging: Morgan (dev mode)

🛠️ Installation & Setup

Prerequisites

  • Node.js (v18+)
  • MongoDB (Local or Atlas connection string)

Steps

  1. Clone the repository

    git clone <repository-url>
    cd ILMS-backend
  2. Install dependencies

    npm install
  3. Configure Environment Create a .env file in the root directory:

    PORT=8000
    MONGO_URI=your_mongodb_connection_string
    JWT_SECRET=your_secure_secret_key
    JWT_EXPIRES_IN=7d
    FRONTEND_URL=http://localhost:5173
    NODE_ENV=development
  4. Seed the Database (Optional) Populate the database with initial admin/student users and sample books:

    npm run seed

    Creates:

    • Admin: admin@library.com / password123
    • Student: user@library.com / password123
  5. Start the Server

    # Development (with auto-reload)
    npm run dev
    
    # Production
    npm start

📡 API Documentation

Authentication

Method Endpoint Description Access
POST /api/auth/register Register a new user Public
POST /api/auth/login Login and receive JWT Public
GET /api/auth/me Get current user profile Private

Books

Method Endpoint Description Access
GET /api/books List books (pagination, search, filter) Public
GET /api/books/:id Get book details Public
POST /api/books Create a new book Admin
PUT /api/books/:id Update a book Admin
DELETE /api/books/:id Remove a book Admin

Query Parameters: page, limit, search, genre, sortBy, order

Transactions (Borrowing)

Method Endpoint Description Access
POST /api/transactions/borrow Borrow a book Private
POST /api/transactions/return/:id Return a borrowed book Private
GET /api/transactions/my Get user's history Private
GET /api/transactions Get all transactions Admin

Recommendations

Method Endpoint Description Access
GET /api/recommendations Get personalized suggestions Private

Statistics

Method Endpoint Description Access
GET /api/stats Get system analytics Admin

System

Method Endpoint Description Access
GET /api/health Server health check Public

📁 Project Structure

src/
├── config/         # Database configuration
├── controllers/    # Request handlers (logic)
├── middleware/     # Auth, error handling, validation
├── models/         # Mongoose schemas
├── routes/         # API route definitions
├── utils/          # Helpers and seeder script
└── app.js          # Express app setup

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the ISC License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors