Skip to content

blaxezcode/Library-Management

Repository files navigation

Library Management System

A comprehensive web-based library management system built with Node.js, Express.js, and MySQL. This system provides complete functionality for managing books, users, borrowing operations, and real-time notifications.

πŸš€ Features

Core Functionality

  • User Management: Support for students, faculty, and admin roles
  • Book Catalog: Complete book management with categories, ISBN, and metadata
  • Borrowing System: Track book loans with due dates and return management
  • Real-time Notifications: Socket.IO powered notifications for users
  • Image Management: Book cover uploads with automatic thumbnail generation
  • Library Cards: Unique library card number generation with multiple formats
  • Admin Dashboard: Comprehensive admin interface for system management

User Roles

  • Students: Browse books, borrow/return books, view personal history
  • Faculty: Enhanced borrowing privileges and extended loan periods
  • Admin: Full system access, user management, book management, statistics

Technical Features

  • Authentication: Secure password hashing with bcryptjs
  • Database: MySQL with connection pooling and optimized queries
  • File Upload: Multer-based image processing with Sharp optimization
  • Real-time: Socket.IO for live notifications and updates
  • Responsive Design: Mobile-friendly interface

πŸ› οΈ Technology Stack

  • Backend: Node.js, Express.js
  • Database: MySQL
  • Authentication: bcryptjs
  • Real-time: Socket.IO
  • File Processing: Multer, Sharp
  • Frontend: HTML5, CSS3, JavaScript (Vanilla)
  • Utilities: UUID generation, image processing

πŸ“‹ Prerequisites

Before running this application, make sure you have:

  • Node.js (v14 or higher)
  • MySQL (v8.0 or higher)
  • npm or yarn package manager

πŸ”§ Installation

  1. Clone the repository

    git clone https://github.com/yourusername/library-management-system.git
    cd library-management-system
  2. Install dependencies

    npm install
  3. Database Setup

    • Create a MySQL database named library_management
    • Update database credentials in db.js:
      const pool = mysql.createPool({
        host: "localhost",
        user: "your_mysql_username",
        password: "your_mysql_password",
        database: "library_management",
        // ... other options
      });
  4. Start the application

    npm start
    # or for development
    npm run dev
  5. Access the application

    • Main application: http://localhost:3001
    • Admin panel: http://localhost:3001/admin

πŸ‘€ Default Admin Account

The system automatically creates an admin user during initialization:

  • Email: admin@library.com
  • Password: admin123

Additional Admin Account

A custom admin account has been seeded:

  • Email: santoshAdmin@gmail.com
  • Password: Santosh.12
  • Library Card: LIB-1592-4966-2

πŸ“ Project Structure

library-management/
β”œβ”€β”€ public/                 # Static files and frontend
β”‚   β”œβ”€β”€ admin/             # Admin dashboard
β”‚   β”œβ”€β”€ css/               # Stylesheets
β”‚   β”œβ”€β”€ images/            # Static images
β”‚   β”œβ”€β”€ js/                # Frontend JavaScript
β”‚   └── uploads/           # User uploaded files
β”œβ”€β”€ services/              # Business logic services
β”‚   β”œβ”€β”€ imageService/      # Image processing
β”‚   └── notificationService.js
β”œβ”€β”€ utils/                  # Utility functions
β”‚   β”œβ”€β”€ idGenerator.js     # Library card generation
β”‚   └── imageUtils/        # Image utilities
β”œβ”€β”€ db.js                  # Database configuration
β”œβ”€β”€ routes.js              # API routes
β”œβ”€β”€ server.js              # Main server file
└── package.json           # Dependencies

πŸ”Œ API Endpoints

Authentication

  • POST /api/login - User login
  • POST /api/register - User registration

Books

  • GET /api/books - Get all books
  • GET /api/books/:id - Get specific book
  • POST /api/books - Add new book (Admin)
  • PUT /api/books/:id - Update book (Admin)
  • DELETE /api/books/:id - Delete book (Admin)

Users

  • GET /api/users - Get all users (Admin)
  • DELETE /api/users/:id - Delete user (Admin)
  • GET /api/users/:id/profile - Get user profile

Borrowing

  • POST /api/borrow - Borrow a book
  • POST /api/return/:id - Return a book
  • GET /api/borrows - Get all borrows (Admin)
  • GET /api/borrows/user/:userId - Get user's borrows

Statistics

  • GET /api/stats - Get system statistics (Admin)

Notifications

  • GET /api/notifications/:userId - Get user notifications
  • PUT /api/notifications/:id/read - Mark notification as read

🎨 Features in Detail

Book Management

  • Add books with complete metadata (title, author, ISBN, category, etc.)
  • Upload and manage book cover images
  • Automatic image optimization and thumbnail generation
  • Category-based organization
  • Search functionality across all book fields

User Management

  • Role-based access control (Student, Faculty, Admin)
  • Unique library card number generation
  • Contact information management
  • Notification preferences configuration

Borrowing System

  • Track book availability status
  • Due date management
  • Return processing
  • Borrowing history
  • Overdue notifications

Real-time Features

  • Live notifications for book borrows/returns
  • Admin broadcast messages
  • Real-time system updates
  • Socket.IO integration

πŸ”’ Security Features

  • Password hashing with bcryptjs
  • Role-based authentication
  • Input validation and sanitization
  • SQL injection prevention
  • File upload security

πŸš€ Deployment

Environment Variables

Create a .env file for production:

NODE_ENV=production
PORT=3001
DB_HOST=your_database_host
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_NAME=library_management

Production Considerations

  • Use environment variables for sensitive data
  • Set up proper MySQL user permissions
  • Configure reverse proxy (nginx)
  • Enable HTTPS
  • Set up database backups
  • Monitor application logs

🀝 Contributing

  1. Fork the repository
  2. Create a 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 - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Santosh

πŸ™ Acknowledgments

  • Express.js community for the excellent framework
  • MySQL team for the robust database system
  • Socket.IO for real-time functionality
  • All contributors and testers

Note: This is a complete library management system suitable for educational institutions, public libraries, or any organization requiring book lending management.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors