Skip to content

feat: extract business logic into src/use-cases/ (Clean Architecture) - #80

Closed
arnavgoel17 wants to merge 1 commit into
pari-28:mainfrom
arnavgoel17:fix/76-extract-business-logic-use-cases
Closed

arnavgoel17 wants to merge 1 commit into
pari-28:mainfrom
arnavgoel17:fix/76-extract-business-logic-use-cases

Conversation

@arnavgoel17

Copy link
Copy Markdown
Contributor

📌 Related Issue

Fixes #76


📝 Description

Extracts core business logic from presentation layer and API routes into a new src/use-cases/ directory implementing Clean Architecture pattern.

New use-cases (framework-agnostic, fully unit-testable):

  • resume-ats.ts — email/phone/GitHub/LinkedIn validators, ATS compliance score, XP mapping for interviews & tasks
  • interview-grading.ts — parses Gemini raw evaluation text into structured score/pros/cons/reference; XP helpers
  • ai-prompts.ts — prompt builders for chat/study-plan/resume-review/interview-grade + prompt-injection blocklist + payload size guard
  • self-check.ts — minimal assertions exercising all use-cases (runs via npm test)

Refactored consumers:

  • ResumeStudio.tsx → uses computeAtsScore + imported validators
  • InterviewHub.tsx → uses parseEvaluation + xpForInterviewScore + nextCompletedToday
  • Dashboard.tsx → uses computeTaskXp + clamp
  • server.ts API routes → thin handlers delegating to buildStudyPlanPrompt, buildResumeReviewPrompt, buildInterviewGradePrompt, security middleware uses hasMaliciousContent + isPayloadTooLarge

🚀 Type of Change

  • Refactoring
  • Bug fix
  • New feature
  • Documentation update

🧪 Testing

  • npm run lint — TypeScript type-check passes
  • npm run build — Vite + esbuild production build succeeds
  • npm test — All 14 self-check assertions pass:
    • resume-ats validators (8)
    • computeAtsScore, computeInterviewXp, computeTaskXp, clamp
    • extractScore, parseEvaluation, xpForInterviewScore, nextCompletedToday
    • hasMaliciousContent, isPayloadTooLarge
    • buildStudyPlanPrompt, buildResumeReviewPrompt, buildInterviewGradePrompt

✅ Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have tested my changes locally
  • I have not introduced unrelated changes
  • This PR is linked to the appropriate issue

- New  directory with framework-agnostic pure functions:
  - : validators, ATS score, XP calc for tasks
  - : Gemini response parsing + XP mapping
  - : prompt builders + security checks
  - : minimal assertions covering all use-cases

- Refactor  to use  + validators
- Refactor  to use  + XP helpers
- Refactor  to use  +
- Refactor  API routes to delegate prompt construction to use-cases
- Update
> prepverse@0.1.0 test
> tsx src/use-cases/self-check.ts

🔎 Running use-cases self-check...

✓ resume-ats validators
✓ computeAtsScore
✓ computeInterviewXp
✓ computeTaskXp
✓ clamp
✓ extractScore
✓ parseEvaluation
✓ xpForInterviewScore
✓ nextCompletedToday
✓ hasMaliciousContent
✓ isPayloadTooLarge
✓ buildStudyPlanPrompt
✓ buildResumeReviewPrompt
✓ buildInterviewGradePrompt

🎉 All self-checks passed! to run the self-check

Fixes pari-28#76
@arnavgoel17
arnavgoel17 requested a review from pari-28 as a code owner August 27, 2026 19:42
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@arnavgoel17 is attempting to deploy a commit to the Pari's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added frontend Frontend development backend Backend development labels Aug 27, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale because it has been inactive for 30 days. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions Bot added the stale label Sep 27, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Closing this pull request due to inactivity.

@github-actions github-actions Bot closed this Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend development frontend Frontend development stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Extract Business Logic into Use Cases (Clean Architecture)

1 participant