A comprehensive library management system built with Node.js, Express.js, MongoDB, and React.js. This system supports individual and group borrowing, fine calculation, feedback management, and admin dashboard.
libraryManagementSystem/
├── server/ # Backend API (Node.js + Express + MongoDB)
│ ├── models/ # MongoDB models
│ ├── routes/ # API routes
│ ├── middleware/ # Authentication middleware
│ ├── utils/ # Utility functions
│ ├── server.js # Main server file
│ ├── package.json # Server dependencies
│ └── env.example # Server environment variables
├── client/ # Frontend (React + Create React App)
│ ├── public/ # Static files
│ ├── src/ # React source code
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ ├── contexts/ # React contexts
│ │ └── hooks/ # Custom hooks
│ ├── package.json # Client dependencies
│ └── env.example # Client environment variables
└── README.md # This file
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- npm or yarn
cd server
npm installcd client
npm install# Copy server environment file
cp server/env.example server/.env
# Edit server/.env with your configuration
NODE_ENV=development
PORT=5000
# MongoDB Configuration
# For local MongoDB:
# MONGODB_URI=mongodb://localhost:27017/library_management
# For MongoDB Atlas (recommended):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/library_management?retryWrites=true&w=majority
JWT_SECRET=your_jwt_secret_key_here
JWT_EXPIRE=7d
# Email configuration for notifications
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_app_password
# Admin credentials
ADMIN_EMAIL=admin@library.com
ADMIN_PASSWORD=admin123📚 Need help setting up MongoDB Atlas? Check out our detailed MongoDB Atlas Setup Guide
# Copy client environment file
cp client/env.example client/.env
# Edit client/.env with your configuration
REACT_APP_API_URL=http://localhost:5000/apicd server
npm run devcd client
npm start- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- API Health Check: http://localhost:5000/api/health
For testing purposes, you can use the following demo admin credentials:
Email: admin@library.com
Password: admin123
⚠️ Important: These are demo credentials for development/testing only. Make sure to create your own admin account and change these credentials in production environments.
If the demo admin account doesn't exist, you can create it using the API:
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "Admin User",
"email": "admin@library.com",
"password": "admin123",
"role": "admin"
}'npm start- Start the server in production modenpm run dev- Start the server in development mode with nodemon
npm start- Start the client development servernpm run build- Build the client for productionnpm test- Run client testsnpm run eject- Eject from Create React App (not recommended)
- User Authentication (JWT-based)
- Book Management (CRUD operations)
- Individual Book Borrowing
- Group Book Borrowing (3-6 members)
- Fine Calculation System
- Feedback System
- Admin Dashboard
- Email Notifications
- Each book has 3 copies available
- Real-time availability tracking
- Book search and filtering
- Genre-based categorization
- ISBN validation
- 1-month borrowing duration
- Individual and group borrowing support
- Automatic due date calculation
- Overdue book tracking
- Return condition tracking
- ₹50 fine for overdue books
- 200% of book cost + ₹50 for lost books after 1 month
- 200% of book cost for lost books within 1 month
- 10% fine for minor damage
- 50% fine for major damage
- Group fines distributed equally among members
- Groups can have 3-6 members
- Group leader management
- Leadership transfer
- Group disbanding with proper checks
- User management
- Book management
- Borrow record tracking
- Fine management
- Feedback moderation
- Dashboard analytics
- Daily overdue book checks (cron jobs)
- Email notifications for fines and overdue books
- Automatic fine calculation
- Book availability updates
- users: User information and authentication
- books: Book catalog and availability
- borrowRecords: Borrowing history and fine tracking
- groups: Group information and member management
- feedback: User feedback and ratings
POST /api/auth/register- Register new userPOST /api/auth/login- User loginGET /api/auth/me- Get current userPUT /api/auth/profile- Update user profile
GET /api/books- Get all books (with search and filters)GET /api/books/:id- Get single bookPOST /api/books- Create book (Admin only)PUT /api/books/:id- Update book (Admin only)DELETE /api/books/:id- Delete book (Admin only)
POST /api/borrow/individual- Borrow book individuallyPOST /api/borrow/group- Borrow book for groupPUT /api/borrow/return/:id- Return bookGET /api/borrow/history- Get borrow historyGET /api/borrow/current- Get current borrowings
POST /api/groups- Create groupGET /api/groups/my-group- Get user's groupPUT /api/groups/:id/add-member- Add member to groupPUT /api/groups/:id/remove-member- Remove member from group
POST /api/feedback- Submit feedbackGET /api/feedback- Get all public feedbackGET /api/feedback/my-feedback- Get user's feedback
GET /api/admin/dashboard- Get dashboard statisticsGET /api/admin/users- Get all usersGET /api/admin/borrow-records- Get all borrow recordsPUT /api/admin/feedback/:id/status- Update feedback status
- Responsive design with CSS
- Modern React components
- Form validation with Formik + Yup
- Toast notifications
- Loading states and error handling
- Login/Register pages
- Dashboard with statistics
- Book catalog with search
- Book detail page
- My Books (borrowing history)
- Groups management
- Feedback system
- User profile
- Admin dashboard
- Admin book management
- Admin user management
- Admin borrow records
- Admin feedback management
- JWT-based authentication
- Password hashing with bcrypt
- Role-based access control
- Input validation and sanitization
- CORS configuration
- Environment variable protection
- Welcome emails for new users
- Overdue book notifications
- Fine notifications with detailed breakdown
- Admin notifications for system events
- Set up MongoDB database (local or cloud)
- Configure environment variables in
server/.env - Deploy the
server/directory to your preferred platform - Ensure MongoDB connection is accessible
- Build the React app:
npm run build-client - Deploy the
client/buildfolder to your hosting platform - Update API URL in
client/.envfor production
- Deploy server to your backend platform
- Deploy client to your frontend platform
- Update client environment variables to point to production API
- User registration and login
- Book browsing and search
- Individual book borrowing
- Group creation and management
- Group book borrowing
- Book return with different conditions
- Fine calculation and payment
- Feedback submission
- Admin dashboard functionality
- Email notifications
After setting up the system, you can create an admin account using the API:
curl -X POST http://localhost:5000/api/admin/create-admin \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-d '{
"name": "Admin User",
"email": "admin@library.com",
"password": "admin123",
"phone": "1234567890",
"address": "Admin Address"
}'-
MongoDB Connection Error
- Ensure MongoDB is running
- Check connection string in
server/.env - Verify network access if using cloud MongoDB
-
Email Notifications Not Working
- Check email configuration in
server/.env - Verify SMTP credentials
- Test with a simple email service first
- Check email configuration in
-
Frontend Not Connecting to Backend
- Verify
REACT_APP_API_URLinclient/.env - Check if backend server is running
- Ensure CORS is properly configured
- Verify
-
Authentication Issues
- Check
JWT_SECRETinserver/.env - Verify token expiration settings
- Clear browser localStorage if needed
- Check
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
Happy Coding! 🎉
For any issues or questions, please check the troubleshooting section or create an issue in the repository.