Skip to content

Latest commit

Β 

History

History
319 lines (254 loc) Β· 7.91 KB

File metadata and controls

319 lines (254 loc) Β· 7.91 KB

Library Management System - Setup Guide

πŸš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or cloud instance)
  • npm or yarn

1. Environment Setup

Backend Environment

# Copy the example environment file
cp env.example .env

# Edit .env with your configuration
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://localhost:27017/library_management
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

Frontend Environment

# Navigate to client directory
cd client

# Copy the example environment file
cp env.example .env

# Edit .env with your configuration
VITE_API_URL=http://localhost:5000/api

2. Install Dependencies

Backend Dependencies

# From project root
npm install

Frontend Dependencies

# From client directory
cd client
npm install

3. Start the Application

Start Backend Server

# From project root
npm run dev
# or
npm start

Start Frontend Development Server

# From client directory
cd client
npm run dev

4. Access the Application

πŸ“‹ Features Implemented

βœ… Core Features

  • 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

βœ… Book Management

  • Each book has 3 copies available
  • Real-time availability tracking
  • Book search and filtering
  • Genre-based categorization
  • ISBN validation

βœ… Borrowing System

  • 1-month borrowing duration
  • Individual and group borrowing support
  • Automatic due date calculation
  • Overdue book tracking
  • Return condition tracking

βœ… Fine System

  • β‚Ή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

βœ… Group Management

  • Groups can have 3-6 members
  • Group leader management
  • Leadership transfer
  • Group disbanding with proper checks

βœ… Admin Features

  • User management
  • Book management
  • Borrow record tracking
  • Fine management
  • Feedback moderation
  • Dashboard analytics

βœ… Automated Features

  • Daily overdue book checks (cron jobs)
  • Email notifications for fines and overdue books
  • Automatic fine calculation
  • Book availability updates

πŸ—„οΈ Database Schema

Collections

  • 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

πŸ”§ API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • GET /api/auth/me - Get current user
  • PUT /api/auth/profile - Update user profile

Books

  • GET /api/books - Get all books (with search and filters)
  • GET /api/books/:id - Get single book
  • POST /api/books - Create book (Admin only)
  • PUT /api/books/:id - Update book (Admin only)
  • DELETE /api/books/:id - Delete book (Admin only)

Borrowing

  • POST /api/borrow/individual - Borrow book individually
  • POST /api/borrow/group - Borrow book for group
  • PUT /api/borrow/return/:id - Return book
  • GET /api/borrow/history - Get borrow history
  • GET /api/borrow/current - Get current borrowings

Groups

  • POST /api/groups - Create group
  • GET /api/groups/my-group - Get user's group
  • PUT /api/groups/:id/add-member - Add member to group
  • PUT /api/groups/:id/remove-member - Remove member from group

Feedback

  • POST /api/feedback - Submit feedback
  • GET /api/feedback - Get all public feedback
  • GET /api/feedback/my-feedback - Get user's feedback

Admin

  • GET /api/admin/dashboard - Get dashboard statistics
  • GET /api/admin/users - Get all users
  • GET /api/admin/borrow-records - Get all borrow records
  • PUT /api/admin/feedback/:id/status - Update feedback status

🎨 Frontend Features

βœ… User Interface

  • Responsive design with Tailwind CSS
  • Modern React components
  • Form validation with Formik + Yup
  • Toast notifications
  • Loading states and error handling

βœ… Pages Implemented

  • 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

πŸ” Security Features

  • JWT-based authentication
  • Password hashing with bcrypt
  • Role-based access control
  • Input validation and sanitization
  • CORS configuration
  • Environment variable protection

πŸ“§ Email Notifications

  • Welcome emails for new users
  • Overdue book notifications
  • Fine notifications with detailed breakdown
  • Admin notifications for system events

πŸš€ Deployment

Backend Deployment

  1. Set up MongoDB database (local or cloud)
  2. Configure environment variables
  3. Deploy to your preferred platform (Heroku, AWS, etc.)
  4. Ensure MongoDB connection is accessible

Frontend Deployment

  1. Build the React app: npm run build
  2. Deploy the dist folder to your hosting platform
  3. Update API URL in environment variables

πŸ§ͺ Testing

Manual Testing Checklist

  • 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

πŸ“ Default Admin Account

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"
  }'

πŸ†˜ Troubleshooting

Common Issues

  1. MongoDB Connection Error

    • Ensure MongoDB is running
    • Check connection string in .env file
    • Verify network access if using cloud MongoDB
  2. Email Notifications Not Working

    • Check email configuration in .env
    • Verify SMTP credentials
    • Test with a simple email service first
  3. Frontend Not Connecting to Backend

    • Verify VITE_API_URL in client/.env
    • Check if backend server is running
    • Ensure CORS is properly configured
  4. Authentication Issues

    • Check JWT_SECRET in .env
    • Verify token expiration settings
    • Clear browser localStorage if needed

πŸ“š Additional Resources

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

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.