Skip to content

Sarthak-Developer-Coder/Primetrade.ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PrimeTrade — Frontend Developer Intern Assignment

Scalable full-stack web app with authentication + protected dashboard.

Repository: https://github.com/Sarthak-Developer-Coder/Primetrade.ai

Tech Stack

  • Frontend: Next.js (App Router) + TypeScript + TailwindCSS
  • Backend: Node.js + Express + TypeScript
  • Auth: JWT stored in httpOnly cookie
  • DB: SQLite via Prisma ORM
  • Validation: Zod (server) + React Hook Form + Zod (client)

Core Features Covered

  • Authentication: register / login / logout (JWT)
  • Protected routes: dashboard requires login
  • Profile: fetch + update
  • Sample entity: Tasks CRUD
  • Dashboard: profile + CRUD UI + search + status filter
  • Security: password hashing (bcrypt), JWT validation middleware, centralized error handling

Project Structure

  • frontend/ — Next.js app
  • backend/ — Express API + Prisma
  • docs/ — Postman collection

Setup (Local)

Prerequisites

  • Node.js 18+ (recommended)
  • npm 9+

1) Install dependencies

From repo root:

npm install

2) Configure backend env

Copy:

copy backend\.env.example backend\.env

Update backend/.env if needed:

  • DATABASE_URL defaults to SQLite file backend/dev.db
  • JWT_SECRET should be a long random string

3) Initialize database

npm run db:push

4) Run dev servers

npm run dev
  • Frontend: http://localhost:3000
  • Backend: http://localhost:4000

Note: Frontend proxies /api/* to backend during dev (see frontend/next.config.ts).


Scripts

From repo root:

  • npm run dev — run backend + frontend
  • npm run dev:backend — backend only
  • npm run dev:frontend — frontend only
  • npm run db:push — Prisma DB sync
  • npm run db:studio — Prisma Studio
  • npm run build — build backend + frontend

API Overview

Base URL (direct): http://localhost:4000

Auth uses an httpOnly cookie named token.

Health

  • GET /health

Auth

  • POST /api/auth/register
    • body: { "email": string, "password": string, "name"?: string }
  • POST /api/auth/login
    • body: { "email": string, "password": string }
  • POST /api/auth/logout

Profile

  • GET /api/me (auth required)
  • PUT /api/me (auth required)
    • body: { "name"?: string | null }

Tasks (Sample Entity)

  • GET /api/tasks (auth required)
    • query: q?, status? (TODO|IN_PROGRESS|DONE), page?, limit?
  • POST /api/tasks (auth required)
    • body: { "title": string, "description"?: string, "status"?: "TODO"|"IN_PROGRESS"|"DONE" }
  • GET /api/tasks/:id (auth required)
  • PUT /api/tasks/:id (auth required)
  • DELETE /api/tasks/:id (auth required)

Validation errors return 400 with details.


Postman

Import the collection:

  • docs/primetrade-assignment.postman_collection.json

Recommended flow:

  1. Register
  2. Login
  3. Get Me
  4. Create Task
  5. List Tasks (search/filter)
  6. Update Task
  7. Logout

Notes on Scaling to Production

High-level steps to scale this architecture:

  • Auth & Security

    • Serve everything behind HTTPS and set cookie secure: true
    • Consider refresh tokens + rotation, session invalidation, and logout-all
    • Add CSRF protection if using cookies across different origins
    • Add rate limiting, helmet, request size limits, audit logging
  • Backend scalability

    • Move from SQLite to Postgres (same Prisma models)
    • Use connection pooling, migrations, and separate read replicas if needed
    • Add structured logging + tracing (OpenTelemetry)
    • Containerize and run behind a load balancer
  • Frontend scalability

    • Use a data layer like React Query/SWR for caching + retries
    • Add typed API client generation (OpenAPI) to prevent contract drift
    • Split dashboard into smaller components and introduce feature modules
  • Deployment

    • Single domain recommended (frontend + backend behind reverse proxy) for clean cookie auth
    • CI: lint + typecheck + build + integration tests

Submission Checklist

  • Run npm run dev and verify login + dashboard CRUD works
  • Ensure backend/.env is not committed (it is gitignored)
  • Include the GitHub repo link + this README + Postman collection

How to Apply (per assignment)

Email your resume + GitHub repo link + any requested logs to:

Subject:

  • Frontend Developer Task

If they ask for logs, you can attach:

  • A screenshot or copy-paste of npm run build output
  • A screenshot of successful UI flow (register → dashboard → CRUD)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors