A full-stack contest platform application with admin dashboard for creating and managing coding contests, MCQ questions, and DSA problems.
contest-platform-assignment/
├── api-http/ # Backend API (Express + TypeScript + Prisma)
│ ├── src/
│ │ ├── controller/ # Request handlers
│ │ ├── service/ # Business logic
│ │ ├── repository/ # Database operations
│ │ ├── schema/ # Zod validation schemas
│ │ ├── routes/ # API routes
│ │ ├── middleware/ # Auth & error handling
│ │ └── util/ # Utility functions
│ ├── prisma/ # Database schema & migrations
│ └── package.json
│
└── web-admin/ # Frontend Admin Dashboard (React + TypeScript + Vite)
├── src/
│ ├── api/ # API client functions
│ ├── components/ # React components
│ ├── pages/ # Page components
│ ├── queries/ # React Query hooks
│ ├── schema/ # TypeScript types & Zod schemas
│ ├── lib/ # Utilities & configurations
│ └── stores/ # Zustand state management
└── package.json
- Create and manage contests (Practice & Competitive)
- Practice Contests: Require max duration (minimum 1 minute)
- Competitive Contests: Require start and end time
- Drag-and-drop question ordering
- Import existing questions or create new ones
- Real-time contest status management
- MCQ Questions: Multiple choice questions with options
- DSA Problems: Coding problems with test cases
- Question bank with search functionality
- Question creation with validation
- Max duration support (minimum 1 minute)
- Authentication (Signup, Login, OTP verification)
- Role-based access (Creator/Contestee)
- Contest attempts and submissions
- Leaderboard tracking
- Node.js (v18 or higher)
- PostgreSQL database
- pnpm (recommended) or npm
- Create a PostgreSQL database
- Copy
.env.exampleto.envinapi-http/directory (if exists) or create one with:DATABASE_URL="postgresql://user:password@localhost:5432/contest_platform" JWT_SECRET="your-secret-key" RESEND_API_KEY="your-resend-api-key" PORT=3000 ALLOWED_HOSTS="http://localhost:5173"
cd api-http
# Install dependencies
pnpm install
# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma migrate dev
# (Optional) Seed the database
pnpm run seed
# Start development server
pnpm run devThe API will run on http://localhost:3000
cd web-admin
# Install dependencies
pnpm install
# Start development server
pnpm run devThe frontend will run on http://localhost:5173
pnpm run dev- Start development server with hot reloadpnpm run build- Build for productionpnpm run start- Start production serverpnpm run seed- Seed the database with sample data
pnpm run dev- Start development serverpnpm run build- Build for productionpnpm run preview- Preview production buildpnpm run lint- Run ESLint
POST /api/auth/signup- User registrationPOST /api/auth/login- User loginPOST /api/auth/verify-otp- OTP verificationPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password
GET /api/contests- Get all contests (with pagination, search, filters)POST /api/contests- Create contest (includes question linking)GET /api/contests/:id- Get contest by IDPATCH /api/contests/:id- Update contestPOST /api/contests/:id/link/mcq- Link MCQ to contestPOST /api/contests/:id/link/dsa- Link DSA problem to contestPATCH /api/contests/:id/reorder- Reorder contest questions
GET /api/problems/mcq- Get MCQ questions (with search)POST /api/problems/mcq- Create MCQ questionGET /api/problems/dsa- Get DSA problems (with search)POST /api/problems/dsa- Create DSA problemPATCH /api/problems/mcq/:id- Update MCQ questionPATCH /api/problems/dsa/:id- Update DSA problem
- Questions are linked during contest creation in a single API call
- All question linking operations run in parallel using
Promise.all - Practice contests require
maxDurationMs(minimum 1 minute) - Competitive contests require
startTimeandendTime
- Comprehensive error boundaries for client-side errors
- Route-level error handling for React Router errors
- User-friendly error messages with development details
- Zod schemas for both frontend and backend validation
- Type-specific validation (practice vs competitive contests)
- Real-time validation feedback
- React Query for server state
- Zustand for client state (authentication)
- Optimistic updates where applicable
DATABASE_URL=postgresql://...
JWT_SECRET=your-secret-key
RESEND_API_KEY=your-resend-api-key
PORT=3000
ALLOWED_HOSTS=http://localhost:5173The frontend uses environment variables for API URL (configured in src/lib/axios.ts)
Key models:
User- User accounts with rolesContest- Contest informationContestQuestion- Links questions to contests with orderingMcqQuestion- Multiple choice questionsDsaProblem- DSA coding problemsContestAttempt- User contest attemptsMcqSubmission/DsaSubmission- User submissions
See api-http/prisma/schema.prisma for complete schema.
- The project uses TypeScript for type safety
- Prisma is used for database ORM
- React Query handles all API state management
- Tailwind CSS for styling
- Radix UI for accessible components
- React Router v7 for routing
- Error boundaries catch and display errors gracefully