The goal was to design a simple but secure backend system with authentication, role-based access control and CRUD APIs.
The application allows users to register, log in and manage tasks.
Authentication is implemented using JWT tokens and passwords are stored securely using hashing.
A small frontend interface is also included to demonstrate how the APIs can be used.
• User registration and login
• JWT based authentication
• Role based access (admin / user)
• Task CRUD APIs
• PostgreSQL database
• Input validation
• Structured error handling
• OpenAPI / Swagger documentation
• Basic React UI for interacting with APIs
Backend
- Node.js
- Express.js
- PostgreSQL
Security
- bcrypt for password hashing
- JWT for authentication
Frontend
- React
API Documentation
- OpenAPI / Swagger
The backend follows a layered structure where each part has a clear responsibility.
controllers → handle HTTP requests and responses
services → contain business logic
routes → define API routes
middlewares → authentication and validation
config → environment configuration and database setup
Auth APIs
POST /api/v1/auth/register
POST /api/v1/auth/login
Task APIs
POST /api/v1/tasks
GET /api/v1/tasks
GET /api/v1/tasks/:id
PUT /api/v1/tasks/:id
DELETE /api/v1/tasks/:id
Some endpoints require authentication using a JWT token.
Swagger documentation is available when the server is running:
http://localhost:3000/api-docs
This includes request examples, response formats and authentication requirements.
Install dependencies
npm install
Create a .env file
PORT=3000
DATABASE_URL=your_database_url
JWT_SECRET=your_secret
JWT_EXPIRES_IN=1d
Run the server
npm run dev
Login
POST /api/v1/auth/login
Body
{ "email": "user@example.com", "password": "Password123" }
The response will include a JWT token which must be used in protected APIs.
The backend is structured in a modular way so that new modules can be added easily.
Some improvements that could be added for production systems:
• Redis caching for frequently accessed data
• Docker based deployment
• Horizontal scaling using load balancers
• Splitting services into microservices if the system grows
Riya Chandra