π§© Library Management System API
π First Impression
Welcome to the Library Management System API! This backend is secure, modular, and role-based with logging and request approval workflows. Itβs designed for admins, librarians, and students to manage books, authors, and borrowing seamlessly.
π Tech Stack
Node.js & Express β Server & API
PostgreSQL β Relational Database
JWT & bcryptjs β Authentication & Password Security
uuid β Unique Identifiers
dotenv β Environment Configuration
π Features & Roles Admin
Add, edit, delete books directly
Approve/reject librarian requests
Access action logs
Librarian
Request to add or delete books
Actions logged for accountability
Student
Borrow and return books
View borrowed books
Requests logged for admin approval
Extra Features
π Role-based access control
π Audit logging for all critical actions
π± Clean folder structure for easy maintenance
π§± Setup & Installation 1οΈβ£ Clone the Repository git clone https://github.com/abdirabi11/Pern-Library-Management-System.git cd library-management-system
2οΈβ£ Install dependencies npm install
3οΈβ£ Set up environment variables
Create .env:
DB_USER=your_db_user DB_PASSWORD=your_db_password DB_HOST=localhost DB_NAME=your_db_name DB_PORT=5432 JWT_SECRET=your_jwt_secret NODE_ENV=development
4οΈβ£ Run the server npm run dev
5οΈβ£ Test endpoints
Use Postman or Insomnia. Protected routes require Bearer token.
π API Overview Auth π Method Endpoint Roles Description POST /signup all Register new user POST /login all Login user POST /logout all Logout user GET /me authenticated Get current user info Books π Method Endpoint Roles Description GET /get-book all List all books GET /get-book/:uuid all Get book by UUID POST /add-book admin Add a book PUT /edit-book/:uuid admin Edit a book DELETE /remove-book/:uuid admin Delete a book Librarian Requests π Method Endpoint Roles Description POST /request-add librarian Request to add a book POST /request-delete/:uuid librarian Request to delete a book Student Borrowing π Method Endpoint Roles Description POST /borrow-book/:uuid student Borrow a book POST /return-book/:uuid student Return a borrowed book GET /borrowed-book student View borrowed books ποΈ Folder Structure ββ controllers/ β ββ admin.controller.js β ββ auth.controller.js β ββ book.controller.js β ββ librarian.controller.js β ββ student.controller.js ββ middleware/ β ββ authorizeRoles.js β ββ protectedRoute.js ββ routes/ β ββ authRoutes.js β ββ bookRoutes.js ββ utils/ β ββ validators.js ββ config/ β ββ db.js ββ server.js
π Action Logging
All critical actions are recorded in actions_log with:
Action type
Performer (UUID + Name)
Entity affected
Timestamp.
π§βπ» Author
π€ Abdirabi Yusuf Adan Junior Full-Stack Developer | Focused on MERN & PostgreSQL π GitHub
πΌ Passionate about building scalable and secure backend systems.
π License
This project is licensed under the MIT License β feel free to use and modify it.