Contents
Features
- JWT-based auth: register, login, change password, forgot/reset password via emailed OTP
- Admin vs. regular user roles
- Book catalog: browse, search, view details, create/edit (with cover image upload), delete
- Author catalog: browse, search, view details (with their books), create/edit, delete
- Profile page (edit name, change password)
- Admin page: list users, deactivate a user
Tech Stack
- Backend: Node.js, Express 5, MongoDB/Mongoose, JWT, bcrypt, Multer (file
uploads), Nodemailer (OTP emails), Babel (for ESM
import/exportsyntax) - Frontend: Plain HTML, CSS, and JavaScript — no build tooling. Each page is
a standalone
.htmlfile paired with its ownjs/*.jsfile, plus sharedjs/api.js(fetch wrapper + session helpers) andjs/nav.js(navbar)
Project Structure
.
├── index.js # Express app entry point
├── configs/ # Nodemailer config
├── controllers/ # Route handlers (users, books, authors)
├── middleware/ # JWT auth, role guard, file upload
├── models/ # Mongoose schemas
├── routers/ # Express routers
├── cron/ # Scheduled cleanup of soft-deleted users/books
├── uploads/ # Uploaded book cover images (created locally, not committed)
└── frontend/
├── css/style.css # Single shared stylesheet
├── js/ # api.js, nav.js, + one file per page
└── *.html # One page per screen
Getting Started
Prerequisites
- Node.js
- A running MongoDB instance (local
mongod, or a MongoDB Atlas URI)
Backend Setup
npm install
Create a .env file in the repo root: