Skip to content

Choudhary4/competitive-programming-platform

Repository files navigation

Competitive Programming Platform

Lightweight competitive programming platform (full-stack) for creating problems, running submissions against testcases, and viewing results.

This repository contains a Next.js frontend, a separate frontend app (Vite + React) used for the in-browser code editor, and an Express-based backend (judge service, problem & submission APIs).

Repository layout (important folders)

  • backend/ — Express server, API routes, models, judge service and DB config.
    • backend/server.js — application entrypoint for the backend.
    • backend/config/database.js — DB connection configuration.
    • backend/scripts/ — scripts such as createAdmin.js and seedProblems.js.
    • backend/services/judgeService.js — code execution / judging logic.
  • frontend/ — Vite React app used for the in-browser editor and test runner (src/components/...).
  • app/ — Next.js app (likely production or main website).
  • components/ — UI components used by the Next.js app.

Prerequisites

  • Node.js (16+ recommended)
  • pnpm (preferred package manager) — https://pnpm.io/
  • A running database (see backend/config/database.js for supported DB and connection env vars)

Setup (development)

All commands below assume a PowerShell terminal on Windows. Adjust as needed for other shells.

  1. Install dependencies
# from repo root
cd d:\HireAnything\competitive-programming-platform

# install root deps (if present)
pnpm install

# install backend deps
cd backend
pnpm install

# install frontend deps
cd ..\frontend
pnpm install

# (optional) install Next.js app deps
cd ..\app
pnpm install
  1. Configure environment

Edit the DB/ENV configuration used by the backend. See backend/config/database.js and add any required environment variables (for example, DATABASE_URL, PORT, JWT_SECRET). The project may expect a .env file in backend/ — check server.js or config/database.js for specifics.

  1. Seed data / create admin (optional)

If you want example problems and an admin user, run the scripts in backend/scripts after the DB is reachable.

cd backend
node scripts/createAdmin.js
node scripts/seedProblems.js

Note: these scripts may expect environment variables (DB connection and possibly admin credentials). Inspect the script headers for usage.

Running the apps

From separate terminals:

  • Backend (Express):
cd backend
# either
node server.js
# or if package.json contains scripts
pnpm start
  • Frontend (Vite React app used for the editor):
cd frontend
pnpm dev
  • Next.js app (if used for the main site):
cd app
pnpm dev

Important files & locations

  • backend/server.js — backend entrypoint and server routes.
  • backend/routes/ — Express routes (auth.js, problems.js, submissions.js, admin.js).
  • backend/models/ — Mongoose/ORM models (User.js, Problem.js, Submission.js, TestCase.js).
  • backend/services/judgeService.js — where submissions are executed/judged.
  • frontend/src/components — React components used by the editor and UI.
  • app/ — Next.js app files (page.tsx, layout.tsx, globals.css).

Common scripts (examples)

  • Install dependencies: pnpm install
  • Start backend: node backend/server.js or pnpm --filter backend start
  • Start frontend: pnpm --filter frontend dev or cd frontend && pnpm dev
  • Seed DB: node backend/scripts/seedProblems.js

If your monorepo uses workspace/pnpm filters, you can use pnpm -w or pnpm --filter to run workspace scripts. Adjust to your setup.

Troubleshooting

  • If the backend cannot connect to the database, verify the values in backend/config/database.js and the env vars.
  • If judge executions fail, check backend/services/judgeService.js for required binaries or sandboxing requirements.

Next steps / suggestions

  • Add explicit README sections per package with exact script names after verifying package.json files.
  • Add a .env.example in backend/ documenting required env vars and formats.

If you want, I can: add a .env.example with guessed env names, or inspect backend/package.json and frontend/package.json to list exact npm scripts and then update this README with precise commands. Which would you prefer?

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •