How vaidik-410/library-management-system works
This is a library-management API: users register and authenticate, books are managed, and admins record borrowing and returns while users can view their loans. Supporting capabilities include password recovery, email notifications, admin/user management, and cleanup of unverified accounts. The graph follows the Express routes into controllers and their model/service dependencies. Some route and service links rely on SOURCE INDEX references rather than excerpts; external database and mail configuration are represented only where the shown code supports them.
Main entry points: app.js Express application · authController.js Account workflows · borrowController.js Borrow and return · userModels.js User records
Components 26
API entry
- Express application
app.js - Auth routes
routes/authRouter.js - Book routes
routes/bookRouter.js - Borrow routes
routes/borrowRouter.js - User routes
routes/user.Router.js
Identity and users
- Authentication
middlewares/authMiddleware.js - Account workflows
controllers/authController.js - User administration
controllers/userController.js - User records
models/userModels.js
Catalog and borrowing
- Book management
controllers/bookController.js - Borrow and return
controllers/borrowController.js - Book records
models/bookModels.js - Borrow records
models/borrowModels.js - Fine calculator
utils/fineCalculator.js
Persistence and services
- Database connection
database/db.js - Borrow notifications
services/notifyUsers.js - Unverified cleanup
services/removeUnverifiedAccounts.js - Verification email
utils/sendVerificationCode.js - Email templates
utils/emailTemplates.js - Email delivery
utils/sendEmial.js - Token response
utils/sendToken.js - Async error wrapper
middlewares/catchAsyncErrors.js - Error handling
middlewares/errorMiddlewares.js
Other components
- API client
- Cloudinary
- SMTP service
Connections 40
- API client → Express application: sends requests
app.js - Express application → Auth routes: mounts auth
app.js - Express application → Book routes: mounts books
app.js - Express application → Borrow routes: mounts borrowing
app.js - Express application → User routes: mounts users
app.js - Express application → Database connection: connects database
app.js - Express application → Borrow notifications: starts service
app.js - Express application → Unverified cleanup: starts cleanup
app.js - Express application → Error handling: registers errors
app.js - Auth routes → Account workflows: routes requests
routes/authRouter.js - Book routes → Authentication: checks access
routes/bookRouter.js - Book routes → Book management: routes requests
routes/bookRouter.js - Borrow routes → Authentication: checks access
routes/borrowRouter.js - Borrow routes → Borrow and return: routes requests
routes/borrowRouter.js - User routes → Authentication: checks access
routes/user.Router.js - User routes → User administration: routes requests
routes/user.Router.js - Authentication → User records: loads user
middlewares/authMiddleware.js - Account workflows → User records: reads and writes
controllers/authController.js - Account workflows → Verification email: sends verification
controllers/authController.js - Account workflows → Email delivery: sends recovery email
controllers/authController.js - Account workflows → Email templates: builds recovery email
controllers/authController.js - Account workflows → Token response: issues token response
controllers/authController.js - User administration → User records: reads and creates
controllers/userController.js - User administration → Cloudinary: uploads avatar
- Book management → Book records: manages books
controllers/bookController.js - Borrow and return → Book records: updates availability
controllers/borrowController.js - Borrow and return → User records: updates loans
controllers/borrowController.js - Borrow and return → Borrow records: records transactions
controllers/borrowController.js - Borrow and return → Fine calculator: calculates fine
controllers/borrowController.js - Borrow notifications → Borrow records: reads loans
services/notifyUsers.js - Borrow notifications → User records: reads users
services/notifyUsers.js - Borrow notifications → Email delivery: sends notifications
services/notifyUsers.js - Unverified cleanup → User records: removes accounts
services/removeUnverifiedAccounts.js - Verification email → Email templates: builds message
utils/sendVerificationCode.js - Verification email → Email delivery: delivers message
utils/sendVerificationCode.js - Email delivery → SMTP service: sends mail
- Account workflows → Async error wrapper: wraps handlers
controllers/authController.js - Borrow and return → Async error wrapper: wraps handlers
controllers/borrowController.js - Book management → Async error wrapper: wraps handlers
controllers/bookController.js - User administration → Async error wrapper: wraps handlers
controllers/userController.js