Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Primetrade.ai Backend Developer Intern Assignment

Project: Secure Notes API

This project implements a scalable REST API with authentication, role-based access control, CRUD operations, API versioning, validation, Swagger documentation, and a basic React frontend UI.

Tech Stack

Backend

  • Java 17
  • Spring Boot 3
  • Spring Security
  • JWT Authentication
  • BCrypt Password Hashing
  • Spring Data JPA
  • MySQL
  • Swagger/OpenAPI

Frontend

  • React.js
  • Vite
  • Fetch API
  • LocalStorage JWT handling

Features Implemented

Backend

  • User registration API
  • User login API
  • Password hashing using BCrypt
  • JWT based authentication
  • Role based access: USER and ADMIN
  • CRUD APIs for Notes entity
  • API versioning using /api/v1
  • Global exception handling
  • Request validation
  • Swagger API documentation
  • MySQL database schema using JPA

Frontend

  • Register and login UI
  • Protected dashboard after login
  • Create, read, update, delete notes
  • Admin-only stats endpoint test
  • Success and error messages from API

API Endpoints

Auth

Method Endpoint Access
POST /api/v1/auth/register Public
POST /api/v1/auth/login Public

Notes

Method Endpoint Access
GET /api/v1/notes USER/ADMIN
POST /api/v1/notes USER/ADMIN
PUT /api/v1/notes/{id} Owner/Admin
DELETE /api/v1/notes/{id} Owner/Admin

Admin

Method Endpoint Access
GET /api/v1/admin/stats ADMIN only

How to Run Backend

  1. Create MySQL database or let Spring Boot create it automatically:
CREATE DATABASE primetrade_notes;
  1. Update database username/password in:
backend/src/main/resources/application.properties

Default config:

spring.datasource.username=root
spring.datasource.password=root
  1. Run backend:
cd backend
mvn spring-boot:run

Backend will run on:

http://localhost:8080

Swagger UI:

http://localhost:8080/swagger-ui.html

How to Run Frontend

cd frontend
npm install
npm run dev

Frontend will run on:

http://localhost:5173

Example Register Request

{
  "name": "Omkar Chavan",
  "email": "[email protected]",
  "password": "123456",
  "role": "USER"
}

For admin account:

{
  "name": "Admin",
  "email": "[email protected]",
  "password": "123456",
  "role": "ADMIN"
}

Scalability Note

The project follows a modular layered architecture with Controller, Service, Repository, DTO, Entity, Security, and Exception packages. This makes it easy to add new modules such as Tasks, Products, Payments, or Reports without affecting existing code.

For production scalability, the system can be improved by adding Redis caching for frequently accessed data, Docker deployment, centralized logging, rate limiting, API Gateway, load balancing, and database indexing. If traffic increases, the backend can be split into microservices such as Auth Service, Notes Service, and Admin Service.

Security Practices Used

  • Passwords are stored using BCrypt hashing.
  • JWT is used for stateless authentication.
  • Protected APIs require Bearer token.
  • Admin APIs are restricted using role-based access.
  • Request body validation is implemented.
  • Global exception handling prevents raw server errors from being exposed.

Deployment Suggestion

  • Backend: Deploy on Render/Railway with MySQL database.
  • Frontend: Deploy on Vercel/Netlify.
  • Add deployed backend URL in frontend environment variable:
VITE_API_BASE_URL=https://your-backend-url.com/api/v1

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages