feat: add resume analysis history tracking with database model and UI dashboard - #1606
feat: add resume analysis history tracking with database model and UI dashboard#1606TanCodeX wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughResume analysis results are persisted per authenticated user. A protected API endpoint returns recent records. The frontend adds a protected history page with loading, error, empty, summary, and expandable detail states, plus navigation from the analyzer. ChangesResume Analysis History
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ResumeAnalysisHistory
participant resumeRoutes
participant getResumeAnalysisHistory
participant MongoDB
ResumeAnalysisHistory->>resumeRoutes: GET /api/resume/analysis-history
resumeRoutes->>getResumeAnalysisHistory: Delegate authenticated request
getResumeAnalysisHistory->>MongoDB: Query 50 newest user records
MongoDB-->>getResumeAnalysisHistory: Return analysis history
getResumeAnalysisHistory-->>ResumeAnalysisHistory: Render history records
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/controllers/resumeController.js`:
- Around line 158-172: Complete the missing-keywords history contract: in
backend/controllers/resumeController.js lines 158-172, update the required AI
JSON structure used before ResumeAnalysisHistory.create so missingKeywords is
required and reliably persisted; in
frontend/src/pages/ResumeBuilder/ResumeAnalysisHistory.jsx lines 149-207, render
item.missingKeywords in the expanded analysis details.
In `@frontend/src/pages/ResumeBuilder/ResumeAnalysisHistory.jsx`:
- Around line 111-141: Update the expandable summary around toggleExpand so the
clickable div is replaced or structured as a named button that invokes
toggleExpand(item._id) via keyboard and pointer interaction. Add an accessible
label, aria-expanded reflecting expandedId === item._id, and aria-controls
referencing the associated expanded-content element; ensure the nested icon
control does not create a redundant interactive button.
🪄 Autofix
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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b0c94ff5-0c04-4eb7-b20a-1849c740ec43
📒 Files selected for processing (7)
backend/controllers/resumeController.jsbackend/models/ResumeAnalysisHistory.jsbackend/routes/resumeRoutes.jsfrontend/src/App.jsxfrontend/src/pages/ResumeBuilder/ResumeAnalysisHistory.jsxfrontend/src/pages/ResumeBuilder/ResumeAnalyzer.jsxfrontend/src/utils/apiPaths.js
|
@TanCodeX address the coderabbit suggestions |
…y of the history list UI
@KaranUnique done. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
backend/controllers/resumeController.js (2)
159-176: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winAlign persisted fields with the AI response contract.
The prompt declares an exact response shape, but it does not include
formattingIssues,actionVerbs, orsections. A compliant response therefore causes Lines 167-172 to persist fallback empty values. Add required fields to the prompt, or remove them from the history contract.🤖 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/controllers/resumeController.js` around lines 159 - 176, Align the ResumeAnalysisHistory persistence in the history creation block with the AI response contract: either add formattingIssues, actionVerbs, and sections to the prompt’s required response shape, or remove those fields from the persisted history payload and contract. Ensure the selected approach prevents compliant AI responses from being stored only as fallback empty values.
159-176: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winDo not silently acknowledge failed history writes.
When
ResumeAnalysisHistory.createfails, the controller logs the error and still returns a successful analysis response. The user then loses a history record without a retry path or notification. Return an explicit persistence failure, or return a machine-readablehistorySaved: falsevalue that the client handles.🤖 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/controllers/resumeController.js` around lines 159 - 176, Update the ResumeAnalysisHistory.create error path in the controller so failed persistence is not silently treated as success: either return an explicit persistence error response or include a machine-readable historySaved: false field that the client can handle. Preserve the successful response behavior and mark historySaved true when the record is created successfully.
🧹 Nitpick comments (1)
backend/controllers/resumeController.js (1)
284-301: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAdd a compound index for history retrieval.
ResumeAnalysisHistoryhas a single-fielduserindex but no{ user: 1, createdAt: -1 }index. Add it to support the filter, sort, and limit efficiently.🤖 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/controllers/resumeController.js` around lines 284 - 301, Add a compound index on the ResumeAnalysisHistory model for user ascending and createdAt descending, so the query in getResumeAnalysisHistory can efficiently filter, sort, and limit results. Define it alongside the model’s existing indexes.
🤖 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.
Outside diff comments:
In `@backend/controllers/resumeController.js`:
- Around line 159-176: Align the ResumeAnalysisHistory persistence in the
history creation block with the AI response contract: either add
formattingIssues, actionVerbs, and sections to the prompt’s required response
shape, or remove those fields from the persisted history payload and contract.
Ensure the selected approach prevents compliant AI responses from being stored
only as fallback empty values.
- Around line 159-176: Update the ResumeAnalysisHistory.create error path in the
controller so failed persistence is not silently treated as success: either
return an explicit persistence error response or include a machine-readable
historySaved: false field that the client can handle. Preserve the successful
response behavior and mark historySaved true when the record is created
successfully.
---
Nitpick comments:
In `@backend/controllers/resumeController.js`:
- Around line 284-301: Add a compound index on the ResumeAnalysisHistory model
for user ascending and createdAt descending, so the query in
getResumeAnalysisHistory can efficiently filter, sort, and limit results. Define
it alongside the model’s existing indexes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 32de7fd7-0b4a-4e6a-86c9-3c84f22e6276
📒 Files selected for processing (2)
backend/controllers/resumeController.jsfrontend/src/pages/ResumeBuilder/ResumeAnalysisHistory.jsx
📝 Pull Request Description
Related Issue
Closes #1531
Summary
Implemented a complete Resume Analysis History feature that allows users to revisit and manage their previous resume analysis results.
ResumeAnalysisHistoryMongoDB model to persist analysis snapshots./resume-analyzer/historyfrontend page with responsive history cards.This allows users to track their resume improvement over time and revisit previous ATS scores, missing skills, suggestions, and AI feedback.
Type of Change
How Has This Been Tested?
Describe the testing steps performed.
/resume-analyzerand completed an AI analysis.ResumeAnalysisHistoryMongoDB collection.GET /api/resume/analysis-historyreturns the authenticated user's analysis history./resume-analyzer/historyand verified previous analyses are displayed correctly.Screenshots (if applicable)
Screenshots/videos can be added to demonstrate:
Checklist
Adds persistent Resume Analysis History for authenticated users.
GET /api/resume/analysis-historywith the 50 newest records./resume-analyzer/historypage.Looks good to me. Ready to merge.