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.
- 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
npm install
cp server/.env.example server/.env
npm run db:migrate
npm run db:seed
npm run devOpen:
- Frontend: http://localhost:5173
- API health: http://localhost:4000/health
- Swagger docs: http://localhost:4000/api-docs
- OpenAPI JSON: http://localhost:4000/api/v1/docs.json
Seeded admin account:
- Email:
admin@primetrade.ai - Password:
Admin@12345
All versioned APIs are under /api/v1.
POST /api/v1/auth/registerPOST /api/v1/auth/loginGET /api/v1/auth/me
Requires Authorization: Bearer <token>.
GET /api/v1/tasksPOST /api/v1/tasksGET /api/v1/tasks/:idPATCH /api/v1/tasks/:idDELETE /api/v1/tasks/:id
Role behavior:
USERcan manage only their own tasks.ADMINcan view and manage all tasks.
{
"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.
Import docs/postman_collection.json into Postman.
The collection includes auth and task CRUD requests with a baseUrl variable set to http://localhost:4000.
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.
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.
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