This project implements the core asks from the assignment PDF:
- user registration and login
- password hashing and JWT authentication
- role-based access (
userandadmin) - CRUD APIs for a secondary entity (
notes) - versioned REST endpoints under
/api/v1 - input validation and structured error handling
- API documentation and a frontend UI
- Backend: Node.js built-in
httpserver - Auth:
crypto.scryptpassword hashing and HS256 token signing - Frontend: static HTML, CSS, and JavaScript
- Demo persistence: local JSON file in
data/database.json - Production-ready schema reference:
docs/schema.sql
node server.jsThen open:
http://localhost:3000/http://localhost:3000/api/v1/healthhttp://localhost:3000/api-docs
POST /api/v1/auth/registerPOST /api/v1/auth/loginGET /api/v1/auth/meGET /api/v1/admin/usersGET /api/v1/notesPOST /api/v1/notesGET /api/v1/notes/:idPATCH /api/v1/notes/:idDELETE /api/v1/notes/:id
Register:
{
"name": "Aarav Singh",
"email": "aarav@example.com",
"password": "securepass123",
"role": "admin"
}Create note:
{
"title": "API hardening",
"content": "Add rate limiting and audit logs.",
"status": "active"
}- The frontend stores the token only in browser memory for this demo.
- The assignment requested a database schema, so a PostgreSQL version is included in
docs/schema.sql. - The supplied
.sitefile was used as visual direction for the dashboard styling.