A web-based Library Management System built with a Node.js RESTful backend and a modern frontend. This system manages books, users, borrowing, returning, fines, and roles following real-world library rules.
This project was built to:
- Apply backend engineering fundamentals
- Model real-world library workflows
- Enforce business rules securely
- Provide a complete API-ready system usable by a frontend
-
Admin
- Manage librarians
- Assign roles & user status
-
Librarian
- Manage books & categories
- Process borrowing & returning
-
Member (Student)
- View books
- Borrow & return books (via librarian)
- Node.js
- Express.js
- PostgreSQL
- JWT (Access + Refresh tokens)
- bcrypt
- CORS
- dotenv
- Web-based UI
- Connected via REST API
- Runs locally
- JWT-based authentication
- httpOnly cookies for access tokens
- Role-based access control (RBAC)
- Protected routes
- Environment variables for secrets
- Login / Logout
- Role assignment
- Account suspension
- Add / update / delete books
- Categories
- Availability tracking
- Borrow limit enforcement
- Due date calculation
- Prevent duplicate borrowing
- Status tracking
- Late return fines
- Fine accumulation
- Borrow blocking when limit exceeded
- RESTful endpoints
- Meaningful HTTP status codes
- JSON-based responses
- No business logic in routes
- Centralized validation & error handling
temp/backend/Library Management System Backend/app/
├── src/
├── .env
├── database.js
└── server.js
- Node.js (v18+ recommended)
- PostgreSQL
- npm
git clone <repo-url>
cd <your-project-name>Do install dependencies for the frontend and backend by:
Frontend:
/Library-Management-SystemBackend:
/temp/backend/Library Management System Backendnpm installCreate a .env file in the project root (Check the project structure stated above):
PORT=3000
DATABASE_URL=postgresql://user:password@localhost:5432/lms
JWT_SECRET=your_jwt_secretIf you follow DATABASE_DDL.txt, then DATABASE_URL must be filled like this :
DATABASE_URL = postgresql://lms_admin:1234567@localhost:5432/lms_dbThe JWT_SECRET can be gained randomly by:
node -e "console.log(require('crypto').randomBytes(128).toString('hex'))"- Create the database and name it as lms_db
- Make the user in the database with:
CREATE USER lms_admin WITH PASSWORD '1234567' - Import the lms_db.sql to the database
- Database structure will be ready to use with first admin account created
- The admin account's email and password can be checked in acc.txt
Make sure you are in the folder :
/temp/backend/Library Management System Backend/appnode server.jsIf the loading, takes too long :
Press Ctrl + c to stop the server. Re-run it again by:
node server.jsServer runs on:
http://localhost:3000
Make sure you are in the folder :
/Library-Management-Systemnpm run devFrontend runs on:
http://localhost:5173
Backend allows frontend access:
origin: "http://localhost:5173",
credentials: trueFrontend requests must include:
credentials: "include"-
Use Postman to test APIs
-
Validate:
- Role restrictions
- Borrow limits
- Fine logic
- Status enforcement
- Backend is fully completed
- Frontend consumes backend APIs directly
- No mock data
- Suitable for real-world extension