feat: implement AI-powered resume scoring#4387
Conversation
|
CodeAnt AI is reviewing your PR. |
|
@Gurkaran18 is attempting to deploy a commit to the Anurag Mishra's projects Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
📝 WalkthroughWalkthroughThe resume scoring endpoint now validates input and uses an AI provider to generate structured scores and feedback. The frontend sends resume content to this endpoint and renders dynamic section results, overall score, loading states, and errors. ChangesAI Resume Scoring Feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Dashboard
participant Analyzer as ResumeSectionStrengthAnalyzer
participant ResumeAPI as resumeApi.score
participant ResumeRoute as /api/resumes/score
participant ScoreService as scoreResumeText
participant AIProvider
Dashboard->>Analyzer: pass resumes[0]
Analyzer->>ResumeAPI: score(resumeText, jobRole)
ResumeAPI->>ResumeRoute: POST scoring request
ResumeRoute->>ScoreService: scoreResumeText(...)
ScoreService->>AIProvider: generateContent(prompt)
AIProvider-->>ScoreService: structured feedback
ScoreService-->>ResumeRoute: scoreData
ResumeRoute-->>ResumeAPI: scoring response
ResumeAPI-->>Analyzer: sections and overallScore
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
backend/src/services/resumeService.js (1)
42-72: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy liftSection-to-score mapping is semantically mismatched.
The deterministic breakdown scores are mapped to sections in a way that doesn't align semantically:
summaryusesbreakdown.formatting(a formatting metric, not summary-specific)projectsusesbreakdown.keywordMatch(keyword match measures role keyword coverage, not project quality)educationis hardcoded to80with no deterministic basisThis means the per-section scores don't accurately reflect each section's quality, potentially misleading users. Consider either computing section-specific scores in
computeATSScoreor clearly documenting why these proxies are used.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/src/services/resumeService.js` around lines 42 - 72, The per-section score mapping in resumeService.js is semantically off because scoreData is assigning proxy metrics to unrelated sections. Update the mapping in the scoreData builder so each section in sections (summary, skills, experience, education, projects) uses a score that actually reflects that section, ideally by adding section-specific values in computeATSScore or by deriving them from matching deterministicScoring breakdown fields; if proxies must remain, document that explicitly in the scoreData construction. Ensure the unique symbols scoreData, deterministicScoring.breakdown, and computeATSScore are used to keep the implementation aligned and easy to locate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/routes/resume.js`:
- Around line 579-599: The `/score` endpoint in `router.post` is missing the
same authentication guard used by the other resume routes. Update the
`router.post('/score', ...)` handler in the resume routes to include
`verifyToken` before `asyncHandler`, matching the existing middleware pattern in
this file. Keep the current `scoreResumeText` and `getDefaultProvider` logic
unchanged, but ensure only authenticated requests can reach `scoreResumeText` by
applying `verifyToken` to this route.
In `@backend/src/services/resumeService.js`:
- Line 19: Add a defensive guard in resumeService’s content generation flow
before calling provider.generateContent(prompt) so missing or invalid provider
values do not throw a raw TypeError. In the resumeService function that invokes
provider.generateContent, verify provider exists and that generateContent is a
function, then throw an ApiError with a clear message such as the AI provider
being unavailable; keep the existing call path unchanged for valid providers.
- Line 35: The JSON parse error log in resumeService currently includes the raw
AI response text, which can leak echoed resume PII into server logs. Update the
error handling around the resume score parsing flow to stop logging the full
text value in the console.error call, and keep only the parse error plus a
minimal safe context message in resumeService so the failure is still
diagnosable without exposing AI output.
In `@frontend/src/components/ResumeSectionStrengthAnalyzer.jsx`:
- Around line 11-39: The `useEffect` in `ResumeSectionStrengthAnalyzer` needs
cleanup to avoid calling `setSections`, `setOverallScore`, `setLoading`, or
`setError` after unmount while `resumeApi.score()` is still pending. Add an
abort/mounted guard inside `fetchScore` and return a cleanup function from the
effect so state updates are skipped if the component unmounts. Also handle the
success path where `res.data.sections` is missing by setting an error (instead
of silently doing nothing) and make sure `setLoading(false)` still runs safely
in all paths.
---
Nitpick comments:
In `@backend/src/services/resumeService.js`:
- Around line 42-72: The per-section score mapping in resumeService.js is
semantically off because scoreData is assigning proxy metrics to unrelated
sections. Update the mapping in the scoreData builder so each section in
sections (summary, skills, experience, education, projects) uses a score that
actually reflects that section, ideally by adding section-specific values in
computeATSScore or by deriving them from matching deterministicScoring breakdown
fields; if proxies must remain, document that explicitly in the scoreData
construction. Ensure the unique symbols scoreData,
deterministicScoring.breakdown, and computeATSScore are used to keep the
implementation aligned and easy to locate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f490bd44-bfe5-4f00-910f-75c5a4bae1b3
📒 Files selected for processing (5)
backend/src/routes/resume.jsbackend/src/services/resumeService.jsfrontend/src/components/ResumeSectionStrengthAnalyzer.jsxfrontend/src/pages/Dashboard.jsxfrontend/src/services/api.js
|
CodeAnt AI finished reviewing your PR. |
|
CodeAnt AI is running Incremental review |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI Incremental review completed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/routes/resume.js`:
- Line 580: Add the existing verifyToken middleware to the router.post('/score',
...) middleware chain before extractAIProvider, preserving the current handler
and AI provider extraction behavior while requiring authentication for score
requests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5c0c90f1-0b4d-4942-8402-22535da92487
📒 Files selected for processing (3)
backend/src/routes/resume.jsbackend/src/services/resumeService.jsfrontend/src/components/ResumeSectionStrengthAnalyzer.jsx
🚧 Files skipped from review as they are similar to previous changes (2)
- backend/src/services/resumeService.js
- frontend/src/components/ResumeSectionStrengthAnalyzer.jsx
Code Review — PR #4387 (AI-powered resume scoring)Checked out the branch and reviewed the full diff + supporting code ( 🔴 CriticalNone — no security leaks, no injection, no crashes on the happy path.
|
User description
Description
Implemented AI-powered resume scoring to replace the previously hardcoded
/scoreendpoint.resumeService.jsin the backend to handle AI generation and strict JSON parsing./api/resumes/scoreroute to fetch dynamic scores.ResumeSectionStrengthAnalyzer.jsxon the frontend to fetch and render the real AI analysis, complete with loading, empty, and error states.Dashboard.jsxto pass the user's latest resume into the analyzer.Type of Change
Related Issue
Fixes #4365
Testing
Screenshots (MANDATORY for UI/UX changes)
Checklist
Summary by CodeRabbit
CodeAnt-AI Description
Show live AI resume section analysis with an overall score
What Changed
Impact
✅ More accurate resume feedback✅ Clearer scoring for uploaded resumes✅ Fewer blank or misleading analyzer results💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.