Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Service – Authentication & Task Management

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.


Features

• 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


Tech Stack

Backend

  • Node.js
  • Express.js
  • PostgreSQL

Security

  • bcrypt for password hashing
  • JWT for authentication

Frontend

  • React

API Documentation

  • OpenAPI / Swagger

Project Structure

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


API Endpoints

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.


API Documentation

Swagger documentation is available when the server is running:

http://localhost:3000/api-docs

This includes request examples, response formats and authentication requirements.


Running the Project

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


Example Request

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.


Scalability Notes

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


Author

Riya Chandra

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages