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.
- 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
- 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
- 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
- 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
Before running this application, make sure you have:
- Node.js (v14 or higher)
- MySQL (v8.0 or higher)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/yourusername/library-management-system.git cd library-management-system -
Install dependencies
npm install
-
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 });
- Create a MySQL database named
-
Start the application
npm start # or for development npm run dev -
Access the application
- Main application:
http://localhost:3001 - Admin panel:
http://localhost:3001/admin
- Main application:
The system automatically creates an admin user during initialization:
- Email:
admin@library.com - Password:
admin123
A custom admin account has been seeded:
- Email:
santoshAdmin@gmail.com - Password:
Santosh.12 - Library Card:
LIB-1592-4966-2
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
POST /api/login- User loginPOST /api/register- User registration
GET /api/books- Get all booksGET /api/books/:id- Get specific bookPOST /api/books- Add new book (Admin)PUT /api/books/:id- Update book (Admin)DELETE /api/books/:id- Delete book (Admin)
GET /api/users- Get all users (Admin)DELETE /api/users/:id- Delete user (Admin)GET /api/users/:id/profile- Get user profile
POST /api/borrow- Borrow a bookPOST /api/return/:id- Return a bookGET /api/borrows- Get all borrows (Admin)GET /api/borrows/user/:userId- Get user's borrows
GET /api/stats- Get system statistics (Admin)
GET /api/notifications/:userId- Get user notificationsPUT /api/notifications/:id/read- Mark notification as read
- 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
- Role-based access control (Student, Faculty, Admin)
- Unique library card number generation
- Contact information management
- Notification preferences configuration
- Track book availability status
- Due date management
- Return processing
- Borrowing history
- Overdue notifications
- Live notifications for book borrows/returns
- Admin broadcast messages
- Real-time system updates
- Socket.IO integration
- Password hashing with bcryptjs
- Role-based authentication
- Input validation and sanitization
- SQL injection prevention
- File upload security
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- 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
Santosh
- Email: santoshAdmin@gmail.com
- GitHub: @yourusername
- 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.