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

Full-stack REST API assignment with JWT authentication, role-based access control, task CRUD APIs, Swagger documentation, Prisma database schema, and a basic React UI.

Tech Stack

  • Backend: Node.js, Express, TypeScript, Prisma
  • Database: SQLite for local review, Prisma schema can switch to PostgreSQL by changing the datasource
  • Auth: bcrypt password hashing, JWT bearer authentication
  • Validation: Zod
  • Security: Helmet, CORS, rate limiting, request size limit
  • Docs: Swagger UI and Postman collection
  • Frontend: React + Vite

Quick Start

npm install
cp server/.env.example server/.env
npm run db:migrate
npm run db:seed
npm run dev

Open:

Seeded admin account:

  • Email: admin@primetrade.ai
  • Password: Admin@12345

API Overview

All versioned APIs are under /api/v1.

Auth

  • POST /api/v1/auth/register
  • POST /api/v1/auth/login
  • GET /api/v1/auth/me

Tasks

Requires Authorization: Bearer <token>.

  • GET /api/v1/tasks
  • POST /api/v1/tasks
  • GET /api/v1/tasks/:id
  • PATCH /api/v1/tasks/:id
  • DELETE /api/v1/tasks/:id

Role behavior:

  • USER can manage only their own tasks.
  • ADMIN can view and manage all tasks.

Example Task Payload

{
  "title": "Ship assignment",
  "description": "Complete API, UI, docs, and verification",
  "status": "todo",
  "priority": "high"
}

Allowed task status values: todo, in-progress, done.

Allowed priority values: low, medium, high.

Postman

Import docs/postman_collection.json into Postman.

The collection includes auth and task CRUD requests with a baseUrl variable set to http://localhost:4000.

Database Notes

The current Prisma datasource uses SQLite so reviewers can run the assignment without installing a database server. The local setup script creates the tables from server/prisma/init.sql, and the schema definition lives in server/prisma/schema.prisma.

For PostgreSQL production readiness:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Then set DATABASE_URL to a PostgreSQL connection string and run Prisma migrations.

Scalability Note

The codebase is organized by feature modules (auth, tasks) with shared middleware for validation, authentication, and error handling. New modules can be added under server/src/modules without changing the core app structure.

For production scale:

  • Use PostgreSQL with connection pooling.
  • Store secrets in a managed secret manager.
  • Add Redis for caching frequently read data and rate-limit state.
  • Run multiple API instances behind a load balancer.
  • Add structured logs and request tracing.
  • Move background work to a queue for long-running tasks.
  • Deploy frontend and backend separately or containerize with Docker.

Useful Scripts

npm run dev       # run API and frontend together
npm run build     # type-check and build both apps
npm run lint      # TypeScript checks
npm run db:migrate
npm run db:seed

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages