CodeStream is a secure coding assessment platform built as a Turborepo monorepo. It supports teacher-created exams, MCQ and LeetCode-style coding questions, paste penalties, candidate monitoring, and C/C++/Python/Java coding attempts.
The repository includes:
apps/web: Next.js frontendapps/api: Express + Socket.IO backendapps/worker: BullMQ worker for background snapshot persistencepackages/shared: shared Postgres and Redis clientspackages/ui: shared UI components
- Node.js 18+
- TypeScript
- Turborepo
- Next.js (App Router)
- Express + Socket.IO
- PostgreSQL
- Redis + BullMQ
apps/
api/ Backend REST + socket server (port 5000)
web/ Frontend app (port 3000)
worker/ Queue worker for code snapshot saves
packages/
shared/ DB/Redis connection layer
ui/ Shared components
eslint-config/
typescript-config/
Path: /dashboard
The dashboard is the assessment control center. It shows active exams, total questions, total marks, enabled security controls, and quick actions for opening the teacher section or starting an exam.
Path: /teacher
Teachers can:
- Create exams with a title and duration.
- Add MCQ questions with selectable correct answers.
- Add coding questions with points, paste penalty, expected time complexity, expected space complexity, and test cases.
- Enable languages: C, C++, Python, and Java.
- Import LeetCode-style question metadata from a LeetCode problem URL.
- Review recent submissions with raw score, penalty, and final score.
Path: /exam/[examId]
Students can:
- Answer MCQ questions.
- Solve coding questions in C, C++, Python, or Java.
- View visible test cases and complexity expectations.
- Finish the exam and receive a penalty-adjusted score summary.
Each question has:
points: maximum marks.penalty: marks deducted if paste/copy activity is detected for that question.
Example: if a coding question is worth 10 marks and the teacher sets a paste penalty of 4, a correct answer with paste activity receives 6 marks.
Final score is calculated as:
final question score = max(0, points - paste penalty)
This deduction is applied only when the answer is otherwise correct/submitted and paste activity exists for that question.
The platform records candidate behavior during attempts:
- Paste/copy detection with warning on every paste.
- Typing-speed spike detection.
- Tab-switch detection through page visibility changes.
- Fullscreen-exit detection.
- Security event log saved with each attempt.
The backend also includes baseline protections:
- Request rate limiting.
- Security headers.
- JSON body size limit.
- JSON-only enforcement for mutating routes.
- Restricted CORS through
CORS_ORIGIN. - Disabled Express
x-powered-byfingerprinting.
These controls reduce abuse and accidental overload, but production deployments should still use infrastructure-level DoS protection such as a CDN/WAF, reverse-proxy rate limits, container resource limits, database connection limits, and centralized logging.
- Node.js
>=18 - npm (workspace root uses
npm@11.6.1) - Docker (recommended for local Postgres + Redis)
- Install dependencies:
npm install- Start infrastructure:
npm run infra:upThis starts:
- Redis at
localhost:6379 - Postgres at
localhost:5432
- Configure environment variables.
At minimum, backend/services require:
PORT=5000
FPORT=3000
JWT_SECRET=your-jwt-secret
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_CALLBACK_URL=http://localhost:5000/auth/google/callback
DB_URL=postgresql://postgres:postgres@localhost:5432/codestream
REDIS_URL=redis://localhost:6379
CORS_ORIGIN=http://localhost:3000
API_RATE_LIMIT_PER_MINUTE=120- Start all apps in dev mode:
npm run devFrom repo root:
npm run dev: run all dev tasks through Turboreponpm run infra:up: start Redis and Postgres for local devnpm run infra:down: stop the Docker Compose stacknpm run build: build all packages/appsnpm run lint: lint all packages/appsnpm run check-types: run type checks across workspacenpm run format: run Prettier over ts/tsx/md files
Target a specific app using Turbo filters:
npx turbo run dev --filter=web
npx turbo run dev --filter=api
npx turbo run dev --filter=worker- User authenticates with Google via backend
/auth/google. - Backend redirects to frontend with JWT query token.
- Frontend includes JWT in
Authorization: Bearer <token>for protected REST calls. - Teachers create exams and questions through
/teacher. - Students attempt exams through
/exam/[examId]. - Paste, tab-switch, fullscreen, and typing-speed events are tracked during the attempt.
- Submitted attempts include raw score, penalty score, final score, answers, and security events.
Legacy collaboration room APIs and sockets are still present in the backend, but the main user flow now focuses on secured assessments.
- REST and socket details:
docs.md - SQL schema reference:
apps/api/table.md
- Authentication is required for
/roomand/examsREST endpoints. - LeetCode import depends on public LeetCode GraphQL availability. Hidden judge tests are not publicly available; teachers should add or review hidden tests manually.