This folder contains the CodeTrack backend – a Node.js/Express + MongoDB API that:
- Authenticates students and coordinators using JWT
- Tracks academic + coding profiles (LeetCode, CodeChef, HackerRank)
- Integrates the external LeetCode & CodeChef API
(https://github.com/coder-writes/leetcode-gfg-codechef-api) - Computes LC/CC/HR scores and an overall TOTAL_SCORE
- Maintains activity status (⭐ active / inactive)
- Exposes a shared leaderboard
- Generates resume PDFs automatically, with optional manual upload
- Node.js (>= 18 recommended)
- MongoDB running locally or in the cloud
- The external LeetCode & CodeChef API service:
- Clone
https://github.com/coder-writes/leetcode-gfg-codechef-api - Follow its README
- Start it on
http://localhost:3000(or updatePLATFORM_API_BASE_URL)
- Clone
From the server folder:
cd server
npm installCreate a .env file based on .env.example:
cp .env.example .env # On Windows: copy .env.example .envUpdate at least:
MONGO_URI– your MongoDB connection stringJWT_SECRET– a strong secret keyPLATFORM_API_BASE_URL– URL where the external API is running
Development (auto-reload with nodemon):
npm run devProduction-style:
npm startHealth check:
GET http://localhost:5000/api/healthYou should see:
{ "status": "ok", "message": "CodeTrack API is running" }Auth
POST /api/auth/register– Register (student or coordinator)POST /api/auth/login– Login, returns JWT with embedded role
Student (JWT, role = student)
GET /api/student/me– Get own full profilePUT /api/student/me/profile– Update academic + coding + HackerRank dataPOST /api/student/me/sync-platforms– Sync LeetCode & CodeChef via external API
(uses caching to avoid frequent calls)POST /api/student/me/certifications– Add certification (+ optional PDF/image upload)POST /api/student/me/achievements– Add achievementPOST /api/student/me/hackathons– Add hackathon (+ optional certificate upload)POST /api/student/me/projects– Add project (+ optional screenshots)GET /api/student/me/resume– Auto-generate resume PDF from verified dataPOST /api/student/me/resume/manual– Upload manual resume PDF override
Coordinator (JWT, role = coordinator)
GET /api/coordinator/dashboard– Totals, active vs inactive, averages, top performersGET /api/coordinator/students– Filterable/searchable student listGET /api/coordinator/students/:id– Full read-only student profile
Leaderboard (shared, any authenticated user)
GET /api/leaderboard– Ranked table of students
Filters:college,hostel,branch,year,name
Sort:sortBy(e.g.scores.totalScore) andsortOrder(asc/desc)
The backend calls the external service (leetcode-gfg-codechef-api) only from the server:
-
LeetCode
GET /leetcode/:username/solved→LCPS(problems solved)GET /leetcode/:username/contest→LCNC(contest count),LCR(rating)
-
CodeChef
GET /codechef/user/:username/rating→CCNC(total contests),CCR(rating)CCPS(problems solved) is not exposed by the external API and is treated as0
Scoring logic (in src/utils/scoring.js):
LC_SCORE = LCPS + (LCNC × 5) + (LCR ÷ 10)CC_SCORE = CCPS + (CCNC × 5) + (CCR ÷ 10)HR_SCORE(heuristic):problemsSolved + badges × 10 + certifications × 15TOTAL_SCORE = LC_SCORE + CC_SCORE + HR_SCORE
Scores are computed on the backend and cached on each student record.
Each student has an activityStatus field (active / inactive), derived from:
lastPlatformSyncAtlastProfileUpdateAtlastManualActivityAt(projects, certifications, achievements, hackathons, resume updates)
If the most recent of these timestamps is within ACTIVITY_ACTIVE_DAYS (default 7 days),
the student is considered active (⭐ glowing); otherwise inactive (⭐ faded).
This field is visible in:
GET /api/leaderboard- Coordinator dashboards and student lists