A full-stack Task Management Application featuring a scalable REST API with JWT Authentication, Role-Based Access Control (RBAC), and a modern Next.js frontend.
Repository: https://github.com/skg58/primetrade-assignment
- Architecture Overview
- Tech Stack
- Getting Started
- Backend Setup
- Frontend Setup
- API Documentation
- Project Structure
- Features
- Environment Variables
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Next.js β HTTP β Express β Query β MongoDB β
β Frontend βββββββββΊβ Backend βββββββββΊβ Database β
β (Port 3000) β REST β (Port 8000) β ODM β (Port 27017)β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β β
β TailwindCSS β JWT / bcrypt / Zod
β React Context β Helmet / CORS / Rate Limit
| Technology | Purpose |
|---|---|
| Node.js + Express.js | Server & API framework |
| TypeScript | Type safety |
| MongoDB + Mongoose | Database & ODM |
| JWT (jsonwebtoken) | Authentication tokens |
| bcrypt | Password hashing |
| Zod | Request validation |
| Helmet + CORS + Rate Limiter | API security |
| Technology | Purpose |
|---|---|
| Next.js 14 (App Router) | React framework |
| TypeScript | Type safety |
| TailwindCSS | Utility-first styling |
| Axios | HTTP client |
| React Hot Toast | Notifications |
| Lucide React | Icons |
- Node.js >= 18.x
- MongoDB >= 6.x (running locally or MongoDB Atlas)
- npm >= 9.x
git clone https://github.com/skg58/primetrade-assignment.git
cd primetrade-assignment# Navigate to backend
cd backend
# Install dependencies
npm install
# Configure environment (edit .env as needed)
# The .env file is pre-configured for local development
# Start development server
npm run devThe backend will start on http://localhost:8000
npm run build
npm start# Navigate to frontend (from project root)
cd frontend
# Install dependencies
npm install
# Start development server
npm run devThe frontend will start on http://localhost:3000
npm run build
npm startBase URL: http://localhost:8000/api/v1
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /auth/register |
Register new user | β |
| POST | /auth/login |
Login & get JWT | β |
| POST | /auth/logout |
Logout & clear cookie | β |
| GET | /auth/me |
Get current user profile | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /tasks |
Create a new task | β |
| GET | /tasks |
Get all tasks (paginated) | β |
| GET | /tasks/:id |
Get task by ID | β |
| PUT | /tasks/:id |
Update a task | β |
| DELETE | /tasks/:id |
Delete a task | β |
| Parameter | Type | Default | Options |
|---|---|---|---|
page |
number | 1 | Any positive integer |
limit |
number | 10 | 1-50 |
status |
string | β | todo, in_progress, done |
priority |
string | β | low, medium, high |
search |
string | β | Free text search |
sortBy |
string | createdAt |
createdAt, title, status, priority, dueDate |
sortOrder |
string | desc |
asc, desc |
Full OpenAPI 3.0 specification available in
backend/swagger.yaml
primetrade-assignment/
βββ backend/ # Express.js REST API
β βββ src/
β β βββ controllers/ # Route handlers
β β βββ database/ # MongoDB connection
β β βββ middleware/ # Auth, RBAC, validation, error handling
β β βββ models/ # Mongoose schemas
β β βββ routes/ # Express routers
β β βββ type/ # TypeScript interfaces
β β βββ utils/ # Helpers (ApiError, ApiResponse, etc.)
β β βββ app.ts # Express configuration
β β βββ constants.ts # App-wide constants
β β βββ index.ts # Server entry point
β βββ .env # Environment variables
β βββ package.json
β βββ swagger.yaml # API documentation
β βββ tsconfig.json
β
βββ frontend/ # Next.js Application
β βββ src/
β β βββ app/ # App Router pages
β β β βββ (auth)/ # Login & Register pages
β β β βββ dashboard/ # Protected dashboard pages
β β βββ components/ # Reusable UI components
β β β βββ layout/ # Sidebar, Header, DashboardLayout
β β β βββ tasks/ # TaskCard, TaskForm, TaskList, TaskFilters
β β β βββ ui/ # Button, Input, Modal, Badge, etc.
β β βββ context/ # React AuthContext
β β βββ lib/ # Axios instance, auth helpers
β β βββ types/ # TypeScript interfaces
β βββ .env.local
β βββ package.json
β βββ tailwind.config.ts
β
βββ README.md # This file
βββ SCALABILITY.md # Scalability architecture notes
- β
RESTful API with versioning (
/api/v1/) - β JWT Authentication (Bearer token + httpOnly cookies)
- β Role-Based Access Control (User & Admin roles)
- β Zod input validation
- β bcrypt password hashing (10 salt rounds)
- β
Standardized API responses (
ApiResponse/ApiError) - β Global error handling middleware
- β Pagination, search, filtering, and sorting
- β Rate limiting & security headers (Helmet)
- β MongoDB compound indexes for performance
- β Modern dark UI with glassmorphism effects
- β Responsive design (mobile + desktop)
- β Auth context with persistent sessions
- β Protected routes with auth gate
- β Full CRUD operations for tasks
- β Real-time search with debouncing
- β Toast notifications for API feedback
- β Animated dashboard with stat cards
- β Collapsible sidebar navigation
| Variable | Default | Description |
|---|---|---|
PORT |
8000 |
Server port |
MONGODB_URI |
mongodb://127.0.0.1:27017/primetrade_db |
MongoDB connection |
JWT_SECRET |
β | JWT signing secret |
JWT_EXPIRES_IN |
7d |
Token expiration |
CORS_ORIGIN |
http://localhost:3000 |
Allowed CORS origin |
NODE_ENV |
development |
Environment |
| Variable | Default | Description |
|---|---|---|
NEXT_PUBLIC_API_URL |
http://localhost:8000/api/v1 |
Backend API URL |
ISC
Built with β€οΈ for the PrimeTrade Backend Developer Intern Assignment.