A modern, full-stack web application for managing library operations digitally. Built with React, Express.js, MongoDB, and TypeScript.
- Multi-role Authentication: Students, Librarians, and Admins
- Secure JWT Authentication: Password hashing with bcrypt
- Role-based Access Control: Different permissions for each user type
- Search & Filter: Find books by title, author, ISBN, or genre
- Borrowing System: Easy book reservations with due dates
- Librarian Tools: Add, edit, and delete books
- Availability Tracking: Real-time availability status
- Popularity Tracking: Books ranked by borrowing frequency
- Smart Recommendations: Discover trending books
- Borrowing History: Track personal and all borrowing records
- Responsive Design: Works on all devices
- Beautiful Interface: Gradient designs and smooth animations
- Intuitive Navigation: Clean, professional layout
- React 19 - Modern React with hooks
- TypeScript - Type-safe development
- Vite - Fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- React Router - Client-side routing
- Axios - HTTP client for API calls
- Heroicons - Beautiful SVG icons
- Express.js - Node.js web framework
- TypeScript - Type-safe server code
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - JSON Web Token authentication
- bcryptjs - Password hashing
- pnpm - Fast package manager
- ESLint - Code linting
- Prettier - Code formatting
Before running this application, make sure you have:
- Node.js (v18 or higher)
- MongoDB (local or cloud instance)
- pnpm (recommended) or npm
git clone <repository-url>
cd library-management-system
pnpm install
pnpm run build # Build both frontend and backend
pnpm run seed # Add sample books (optional)
pnpm start # Start the serverVisit: http://localhost:5000
git clone <repository-url>
cd library-management-systemcd backend
pnpm installcd ../frontend
pnpm installCreate backend/.env file:
MONGO_DB_URI=mongodb://localhost:27017/library-management
# OR for MongoDB Atlas:
# MONGO_DB_URI=mongodb+srv://username:password@cluster.mongodb.net/library-management
JWT_SECRET=your_super_secure_jwt_secret_here
PORT=5000- Local MongoDB: Install and start MongoDB locally
- MongoDB Atlas: Create a free cluster and get connection string
Add sample books to get started:
cd backend
pnpm run seed# Build frontend and start backend (serves both API and frontend)
cd backend
pnpm build
pnpm startApp runs on: http://localhost:5000
If you need hot-reloading during development:
# Terminal 1: Backend API only
cd backend
pnpm dev
# Terminal 2: Frontend dev server
cd frontend
pnpm dev- Browse and search books
- Borrow available books
- View borrowing history
- See book recommendations
- All student permissions
- Add new books to collection
- Edit existing book information
- Delete books from system
- View all borrowing records
- Process book returns
- All librarian permissions
- Manage user accounts (create/edit/delete)
- System administration
- User role management
- Register/Login: Create an account or sign in
- Browse Books: Use search and filters to find books
- Borrow Books: Click "Borrow Book" on available titles
- Manage Library (Librarians/Admins): Use management tools
- Track History: View your borrowing records
library-management-system/
βββ backend/ # Express.js API server
β βββ src/
β β βββ middleware/ # Authentication middleware
β β βββ models/ # MongoDB schemas
β β βββ routes/ # API endpoints
β β βββ server.ts # Main server file
β βββ package.json
β βββ tsconfig.json
β βββ seed.js # Database seeding script
βββ frontend/ # React application
β βββ src/
β β βββ pages/ # React components/pages
β β βββ App.tsx # Main app component
β β βββ main.tsx # App entry point
β βββ package.json
β βββ tailwind.config.js # Tailwind configuration
β βββ vite.config.ts # Vite configuration
βββ README.md # This file
βββ plan.md # Project planning document
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current user info
GET /api/books- Get all books (with search/filter)GET /api/books/:id- Get book by IDPOST /api/books- Create new book (librarian/admin)PUT /api/books/:id- Update book (librarian/admin)DELETE /api/books/:id- Delete book (librarian/admin)GET /api/books/recommendations- Get recommended books
POST /api/borrowings/borrow- Borrow a bookPOST /api/borrowings/return/:id- Return a book (librarian/admin)GET /api/borrowings/my- Get user's borrowing historyGET /api/borrowings- Get all borrowings (librarian/admin)
GET /api/users- Get all usersPOST /api/users- Create userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
- Create Users: Register with different roles
- Add Books: Use librarian account to add books
- Borrow Books: Test borrowing functionality
- Search/Filter: Test search and genre filtering
- Admin Panel: Test user management features
The seed script provides 12 sample books across various genres:
- Harry Potter (Fantasy)
- 1984 (Dystopian)
- The Great Gatsby (Fiction)
- Pride and Prejudice (Romance)
- And more...
This project is configured for easy deployment on Vercel with automatic pnpm support:
-
Install Vercel CLI:
npm install -g vercel # OR pnpm add -g vercel -
Deploy:
pnpm run deploy # OR vercel --prodNote: Vercel automatically handles pnpm installation and the full build process.
-
Set Environment Variables in Vercel:
MONGO_DB_URI=your_mongodb_connection_string JWT_SECRET=your_secure_jwt_secret NODE_ENV=production
-
Seed Database (Optional): After deployment, you can seed the database by calling:
POST https://your-app-url.vercel.app/api/seed
cd backend
pnpm build
pnpm startcd frontend
pnpm build
# Deploy the 'dist' folder to your hosting serviceNODE_ENV=production
MONGO_DB_URI=your_production_mongodb_uri
JWT_SECRET=your_secure_production_jwt_secret- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Backend won't start:
- Check MongoDB connection
- Verify environment variables
- Ensure port 5000 is available
Frontend build fails:
- Run
pnpm installin frontend directory - Check Node.js version (should be v18+)
Authentication issues:
- Clear browser localStorage
- Check JWT_SECRET in .env
Database connection:
- Ensure MongoDB is running
- Verify connection string in .env
For support, please open an issue in the GitHub repository or contact the development team.
Built with β€οΈ for modern library management