# hieulefsdev-fs/ptich_cv_ai architecture

> Architecture diagram of the GitHub repository hieulefsdev-fs/ptich_cv_ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hieulefsdev-fs/ptich_cv_ai
- Repository: https://github.com/hieulefsdev-fs/ptich_cv_ai

## Overview

AI Career Coach is a web application that turns a CV and target role into an ATS-oriented report, skill-gap action plan, learning links, job listings, and (for Plus) a generated CV. The main workflow runs from the protected analysis page through the backend analysis service, AI and enrichment integrations, persisted report, and report/history views. Separate branches cover OTP/JWT identity, Plus payments, and administration. Relationships for unsampled subsystems are included only where the README documents them; source excerpts do not expose every internal call.

Main entry points: [`backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java) (Analysis orchestration), [`frontend/src/api/client.ts`](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/api/client.ts) (API client), [`frontend/src/App.tsx`](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/App.tsx) (Routes and shell), [`frontend/src/pages/ReportDetailPage.tsx`](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/ReportDetailPage.tsx) (Report detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User application"]
  node_app["Routes and shell<br/>[App.tsx]"]
  node_dashboard["Analyze CV<br/>[DashboardPage.tsx]"]
  node_report["Report detail"]
  node_history["History and compare<br/>[HistoryPage.tsx]"]
  node_generatedcv["Generated CV view"]
  node_api["API client<br/>[client.ts]"]
  node_authui["Authentication state<br/>[AuthContext.tsx]"]
end

subgraph group_identity["Identity and security"]
  node_authcontroller["Auth endpoints"]
  node_authservice["OTP and JWT flows<br/>[AuthService.java]"]
  node_userrepo["User records"]
  node_email["Email delivery<br/>[EmailService.java]"]
end

subgraph group_analysis["CV analysis"]
  node_analysiscontroller["Analysis endpoints"]
  node_analysisservice["Analysis orchestration"]
  node_extractor["CV text extraction"]
  node_gemini["AI analysis<br/>[GeminiService.java]"]
  node_youtube["Learning video lookup"]
  node_jobs["Job listing lookup"]
  node_analysisrepo["Analysis records"]
end

subgraph group_account["Accounts and operations"]
  node_paymentui["Pricing and return<br/>[PricingPage.tsx]"]
  node_paymentcontroller["Payment endpoints"]
  node_vnpayservice["VNPay integration<br/>[VnpayService.java]"]
  node_admin["Admin console<br/>[AdminPage.tsx]"]
  node_adminservice["Admin operations<br/>[AdminService.java]"]
  node_admincontroller["Admin endpoints"]
end

node_user(("User"))
node_postgres[("PostgreSQL")]
node_geminiapi{{"Gemini API"}}
node_youtubeapi{{"YouTube Data API"}}
node_jsearch{{"JSearch API"}}
node_vnpay{{"VNPay"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_report
node_app -->|"routes to"| node_history
node_dashboard -->|"submits analysis"| node_api
node_api -->|"calls API"| node_analysiscontroller
node_analysiscontroller -->|"delegates"| node_analysisservice
node_analysisservice -->|"extracts text"| node_extractor
node_analysisservice -->|"requests analysis"| node_gemini
node_gemini -->|"sends CV"| node_geminiapi
node_analysisservice -->|"adds video links"| node_youtube
node_youtube -->|"searches videos"| node_youtubeapi
node_analysisservice -->|"adds job listings"| node_jobs
node_jobs -->|"searches jobs"| node_jsearch
node_analysisservice -->|"reads and saves"| node_analysisrepo
node_analysisrepo -->|"persists records"| node_postgres
node_analysisservice -->|"notifies quota"| node_email
node_analysisservice -->|"returns report"| node_report
node_report -->|"renders Plus CV"| node_generatedcv
node_report -->|"loads report"| node_api
node_history -->|"loads history"| node_api
node_user -->|"authenticates"| node_authui
node_authui -->|"requests auth"| node_api
node_api -->|"calls auth API"| node_authcontroller
node_authcontroller -->|"delegates"| node_authservice
node_authservice -->|"reads and writes"| node_userrepo
node_authservice -->|"sends OTP"| node_email
node_userrepo -->|"persists users"| node_postgres
node_user -->|"upgrades plan"| node_paymentui
node_paymentui -->|"creates payment"| node_api
node_api -->|"calls payment API"| node_paymentcontroller
node_paymentcontroller -->|"delegates"| node_vnpayservice
node_vnpayservice -->|"creates payment URL"| node_vnpay
node_user -->|"administers service"| node_admin
node_admin -->|"requests operations"| node_admincontroller
node_admincontroller -.->|"delegates"| node_adminservice

click node_app "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/DashboardPage.tsx"
click node_report "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/ReportDetailPage.tsx"
click node_history "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/HistoryPage.tsx"
click node_generatedcv "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/components/GeneratedCVView.tsx"
click node_api "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/api/client.ts"
click node_authui "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_authcontroller "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/AuthController.java"
click node_authservice "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/AuthService.java"
click node_userrepo "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/repository/UserRepository.java"
click node_email "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/EmailService.java"
click node_analysiscontroller "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/AnalysisController.java"
click node_analysisservice "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java"
click node_extractor "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/CvTextExtractorService.java"
click node_gemini "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/GeminiService.java"
click node_youtube "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/YoutubeSearchService.java"
click node_jobs "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/JobSearchService.java"
click node_analysisrepo "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/repository/CvAnalysisRepository.java"
click node_paymentui "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/PricingPage.tsx"
click node_paymentcontroller "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/PaymentController.java"
click node_vnpayservice "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/VnpayService.java"
click node_admin "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/AdminPage.tsx"
click node_adminservice "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/AdminService.java"
click node_admincontroller "https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/AdminController.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_dashboard,node_report,node_history,node_generatedcv,node_api,node_authui,node_user toneBlue
class node_authcontroller,node_authservice,node_userrepo,node_email,node_postgres toneAmber
class node_analysiscontroller,node_analysisservice,node_extractor,node_gemini,node_youtube,node_jobs,node_analysisrepo,node_geminiapi,node_youtubeapi,node_jsearch toneMint
class node_paymentui,node_paymentcontroller,node_vnpayservice,node_admin,node_adminservice,node_admincontroller toneRose
class node_vnpay toneIndigo
```

## Components

### User application

- [Routes and shell](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Analyze CV](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [Report detail](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/ReportDetailPage.tsx): `frontend/src/pages/ReportDetailPage.tsx`
- [History and compare](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/HistoryPage.tsx): `frontend/src/pages/HistoryPage.tsx`
- [Generated CV view](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/components/GeneratedCVView.tsx): `frontend/src/components/GeneratedCVView.tsx`
- [API client](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Authentication state](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`

### Identity and security

- [Auth endpoints](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/AuthController.java): `backend/src/main/java/com/cvai/backend/controller/AuthController.java`
- [OTP and JWT flows](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/AuthService.java): `backend/src/main/java/com/cvai/backend/service/AuthService.java`
- [User records](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/repository/UserRepository.java): `backend/src/main/java/com/cvai/backend/repository/UserRepository.java`
- [Email delivery](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/EmailService.java): `backend/src/main/java/com/cvai/backend/service/EmailService.java`

### CV analysis

- [Analysis endpoints](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/AnalysisController.java): `backend/src/main/java/com/cvai/backend/controller/AnalysisController.java`
- [Analysis orchestration](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java): `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`
- [CV text extraction](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/CvTextExtractorService.java): `backend/src/main/java/com/cvai/backend/service/CvTextExtractorService.java`
- [AI analysis](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/GeminiService.java): `backend/src/main/java/com/cvai/backend/service/GeminiService.java`
- [Learning video lookup](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/YoutubeSearchService.java): `backend/src/main/java/com/cvai/backend/service/YoutubeSearchService.java`
- [Job listing lookup](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/JobSearchService.java): `backend/src/main/java/com/cvai/backend/service/JobSearchService.java`
- [Analysis records](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/repository/CvAnalysisRepository.java): `backend/src/main/java/com/cvai/backend/repository/CvAnalysisRepository.java`

### Accounts and operations

- [Pricing and return](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/PricingPage.tsx): `frontend/src/pages/PricingPage.tsx`
- [Payment endpoints](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/PaymentController.java): `backend/src/main/java/com/cvai/backend/controller/PaymentController.java`
- [VNPay integration](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/VnpayService.java): `backend/src/main/java/com/cvai/backend/service/VnpayService.java`
- [Admin console](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/frontend/src/pages/AdminPage.tsx): `frontend/src/pages/AdminPage.tsx`
- [Admin operations](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/service/AdminService.java): `backend/src/main/java/com/cvai/backend/service/AdminService.java`
- [Admin endpoints](https://github.com/hieulefsdev-fs/ptich_cv_ai/blob/main/backend/src/main/java/com/cvai/backend/controller/AdminController.java): `backend/src/main/java/com/cvai/backend/controller/AdminController.java`

### Other components

- **User**
- **PostgreSQL**
- **Gemini API**
- **YouTube Data API**
- **JSearch API**
- **VNPay**

## Connections

- User → Routes and shell: uses (evidence: `README.md`)
- Routes and shell → Analyze CV: routes to (evidence: `frontend/src/App.tsx`)
- Routes and shell → Report detail: routes to (evidence: `frontend/src/App.tsx`)
- Routes and shell → History and compare: routes to (evidence: `frontend/src/App.tsx`)
- Analyze CV → API client: submits analysis (evidence: `README.md`)
- API client → Analysis endpoints: calls API (evidence: `README.md`)
- Analysis endpoints → Analysis orchestration: delegates (evidence: `backend/src/main/java/com/cvai/backend/controller/AnalysisController.java`)
- Analysis orchestration → CV text extraction: extracts text (evidence: `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`)
- Analysis orchestration → AI analysis: requests analysis (evidence: `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`)
- AI analysis → Gemini API: sends CV (evidence: `README.md`)
- Analysis orchestration → Learning video lookup: adds video links (evidence: `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`)
- Learning video lookup → YouTube Data API: searches videos (evidence: `README.md`)
- Analysis orchestration → Job listing lookup: adds job listings (evidence: `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`)
- Job listing lookup → JSearch API: searches jobs (evidence: `backend/src/main/java/com/cvai/backend/service/JobSearchService.java`)
- Analysis orchestration → Analysis records: reads and saves (evidence: `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`)
- Analysis records → PostgreSQL: persists records (evidence: `README.md`)
- Analysis orchestration → Email delivery: notifies quota (evidence: `backend/src/main/java/com/cvai/backend/service/CvAnalysisService.java`)
- Analysis orchestration → Report detail: returns report (evidence: `README.md`)
- Report detail → Generated CV view: renders Plus CV (evidence: `frontend/src/pages/ReportDetailPage.tsx`)
- Report detail → API client: loads report (evidence: `frontend/src/pages/ReportDetailPage.tsx`)
- History and compare → API client: loads history (evidence: `README.md`)
- User → Authentication state: authenticates (evidence: `README.md`)
- Authentication state → API client: requests auth (evidence: `frontend/src/contexts/AuthContext.tsx`)
- API client → Auth endpoints: calls auth API (evidence: `README.md`)
- Auth endpoints → OTP and JWT flows: delegates (evidence: `backend/src/main/java/com/cvai/backend/controller/AuthController.java`)
- OTP and JWT flows → User records: reads and writes (evidence: `backend/src/main/java/com/cvai/backend/service/AuthService.java`)
- OTP and JWT flows → Email delivery: sends OTP (evidence: `backend/src/main/java/com/cvai/backend/service/AuthService.java`)
- User records → PostgreSQL: persists users (evidence: `README.md`)
- User → Pricing and return: upgrades plan (evidence: `README.md`)
- Pricing and return → API client: creates payment
- API client → Payment endpoints: calls payment API (evidence: `README.md`)
- Payment endpoints → VNPay integration: delegates (evidence: `backend/src/main/java/com/cvai/backend/controller/PaymentController.java`)
- VNPay integration → VNPay: creates payment URL (evidence: `README.md`)
- User → Admin console: administers service (evidence: `README.md`)
- Admin console → Admin endpoints: requests operations (evidence: `README.md`)
- Admin endpoints → Admin operations: delegates
