Skip to content

feat: add gfg integration#10

Closed
Devx2107 wants to merge 1 commit into
sujallchaudhary:masterfrom
Devx2107:feat/gfg-integration
Closed

feat: add gfg integration#10
Devx2107 wants to merge 1 commit into
sujallchaudhary:masterfrom
Devx2107:feat/gfg-integration

Conversation

@Devx2107

Copy link
Copy Markdown
Contributor

# feat: add GeeksForGeeks platform integration

What

Adds GeeksForGeeks as a 5th platform, raising the maximum total score from 4000 to 5000.

Why

GFG is heavily used by NSUT students for placement prep — DSA practice, company-specific problem sets, and the GFG Institute Rank are all things students actively track. It was a visible gap in the leaderboard for anyone doing placement-focused practice alongside competitive programming.

Changes

New file — backend/platforms/gfg.js

Full platform module following the existing registry contract:

  • fetchStats(username) — hits GFG's internal JSON API (auth.geeksforgeeks.org/user/{username}/practice/). No scraping — GFG returns structured JSON directly, making this more reliable than the existing CodeChef integration.
  • validateUsername(username) — checks for a valid userHandle in the API response
  • calculateScore(stats) — weighted solved score (Easy×1 + Med×3 + Hard×6, max 700) + GFG practice score bonus (max 300), capped at 1000. Same shape as the LeetCode formula.
  • Tracks 8 stats: totalSolved, easySolved, mediumSolved, hardSolved, score, monthlyScore, instituteRank, streak

backend/platforms/index.js

  • Added require('./gfg') and registered it in the platforms array

backend/models/Student.js

  • Added gfg subdocument (username + 8 stats fields + lastUpdated)
  • Added scores.gfg and ranks.gfg fields
  • Existing documents unaffected — Mongoose defaults handle the missing fields gracefully until next cron run

backend/controllers/studentController.js

  • Changed PLATFORM_KEYS from a hardcoded array to getAllPlatforms().map(p => p.key) so new platforms are automatically picked up without manual edits here

backend/cron/updateData.js

  • Added gfg to PLATFORM_CONCURRENCY (4 workers) and PLATFORM_DELAY_MS (300ms)

README.md

  • Added GFG row to the Scoring System table
  • Added GFG row to the Data Update Pipeline table
  • Updated max total score reference from 4000 → 5000
  • Added gfg.js to the project structure

No new dependencies

axios already handles the JSON API calls. No scraping libraries needed.

Testing

  • Validated against real GFG profiles — fetchStats returns correct solved counts and score
  • validateUsername correctly returns false for non-existent usernames (404 from GFG API)
  • Registered a test student with a GFG username — stats fetched on registration, score calculated, leaderboard rank updated correctly
  • Cron run picks up GFG alongside existing platforms with no interference

Notes

  • GFG's API is unofficial (used by their own site) but has been stable for a long time. If it ever breaks, fetchStats returns null gracefully and the cron skips that student's GFG data without affecting other platforms.
  • instituteRank will reflect the student's college rank if they've set their institute to NSUT on their GFG profile — useful signal for placement context.
  • monthlyScore is worth surfacing in a future PR as a "This Month" leaderboard column — left out of this PR to keep scope tight.
  • GFG doesn't expose a submission calendar API, so no heatmap support — consistent with CodeChef's current behavior.

@sujallchaudhary

Copy link
Copy Markdown
Owner

is the new platform really required?

@Devx2107

Copy link
Copy Markdown
Contributor Author

is the new platform really required?

I think so its a nice little addition as quite a few begginers begin their journey from gfg . Also i think we can add atcoder as well. Instead of them getting a big sillhoute on the main page . it can be give space only when you open the profile and that too at the bottom of all of it.

@sujallchaudhary

Copy link
Copy Markdown
Owner

yes it's better to add these small platforms on profile page
instead of changing whole leaderboard.

sorry for late reply :)

@Devx2107

Copy link
Copy Markdown
Contributor Author

yes it's better to add these small platforms on profile page instead of changing whole leaderboard.

sorry for late reply :)

hmm true , its okay happens no issues

@Devx2107 Devx2107 closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants