# bh-official/careercraftt architecture

> Architecture diagram of the GitHub repository bh-official/careercraftt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bh-official/careercraftt
- Repository: https://github.com/bh-official/careercraftt

## Overview

CareerCraft is an authenticated, AI-assisted job-application workspace. Candidates provide a resume and job description, review match scores and requirement gaps, then generate tailored application and career-preparation material; sessions and application activity support follow-up. The graph separates analysis, generated guidance, and application tracking, with database and AI service layers. Some UI-to-route wiring and dashboard retrieval paths were not shown, so those links are left out or marked unverified rather than inferred.

Main entry points: [`src/components/AnalysisPage.jsx`](https://github.com/bh-official/careercraftt/blob/main/src/components/AnalysisPage.jsx) (Analysis page), [`src/lib/db.js`](https://github.com/bh-official/careercraftt/blob/main/src/lib/db.js) (PostgreSQL), [`src/context/AnalysisContext.jsx`](https://github.com/bh-official/careercraftt/blob/main/src/context/AnalysisContext.jsx) (Analysis state), [`src/app/api/analyze/route.js`](https://github.com/bh-official/careercraftt/blob/main/src/app/api/analyze/route.js) (Match analysis API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Analysis workflow"]
  node_analysis_page["Analysis page<br/>[AnalysisPage.jsx]"]
  node_analysis_state["Analysis state"]
  node_file_uploader["Resume and job inputs<br/>[FileUploader.jsx]"]
  node_upload_route["Upload endpoint<br/>[route.js]"]
  node_analyze_route["Match analysis API<br/>[route.js]"]
  node_results_route["Analysis results API<br/>[route.js]"]
  node_score_card["Match scores<br/>[ScoreCard.jsx]"]
  node_gap_list["Requirement gaps<br/>[GapList.jsx]"]
end

subgraph group_guidance["Generated guidance"]
  node_cover_route["Cover letter API<br/>[route.js]"]
  node_cover_letters_route["Cover letter records<br/>[route.js]"]
  node_cover_editor["Cover letter editor"]
  node_optimization_route["Optimization API<br/>[route.js]"]
  node_optimization_tips["Optimization guidance"]
  node_interview_route["Interview API<br/>[route.js]"]
  node_interview_prep["Interview preparation<br/>[InterviewPrep.jsx]"]
  node_career_route["Career API<br/>[route.js]"]
  node_career_development["Career development"]
end

subgraph group_tracking["Applications and history"]
  node_dashboard["Application dashboard<br/>[page.js]"]
  node_applications_section["Applications list"]
  node_history_section["Activity history"]
  node_applications_route["Applications API<br/>[route.js]"]
  node_session_route["Session API<br/>[route.js]"]
  node_sessions_route["Sessions API<br/>[route.js]"]
  node_events_route["Application events API<br/>[route.js]"]
  node_event_writer["Event recording"]
end

subgraph group_services["Data and integrations"]
  node_file_processing["File parsing<br/>[fileProcessing.js]"]
  node_ai_service["AI generation<br/>[aiService.js]"]
  node_openrouter["OpenRouter"]
  node_auth["Clerk authentication"]
  node_user_record["User provisioning"]
  node_database[("PostgreSQL<br/>[db.js]")]
end

node_candidate(("Candidate"))

node_candidate -->|"provides inputs"| node_analysis_page
node_analysis_page -->|"renders"| node_file_uploader
node_analysis_page -->|"uses state"| node_analysis_state
node_analysis_page -->|"renders"| node_score_card
node_analysis_page -->|"renders"| node_gap_list
node_analysis_state -.->|"requests analysis"| node_analyze_route
node_analyze_route -->|"runs analysis"| node_ai_service
node_analyze_route -->|"ensures user"| node_user_record
node_analyze_route -->|"reads and writes"| node_database
node_analyze_route -->|"records activity"| node_event_writer
node_ai_service -->|"calls model API"| node_openrouter
node_candidate -.->|"uploads files"| node_upload_route
node_upload_route -->|"parses files"| node_file_processing
node_analysis_state -.->|"requests letter"| node_cover_route
node_analysis_state -.->|"requests tips"| node_optimization_route
node_analysis_state -.->|"requests prep"| node_interview_route
node_analysis_state -.->|"requests guidance"| node_career_route
node_cover_route -->|"generates letter"| node_ai_service
node_optimization_route -->|"generates tips"| node_ai_service
node_interview_route -->|"generates prep"| node_ai_service
node_career_route -->|"generates guidance"| node_ai_service
node_analysis_page -->|"renders"| node_cover_editor
node_analysis_page -->|"renders"| node_optimization_tips
node_analysis_page -->|"renders"| node_interview_prep
node_analysis_page -->|"renders"| node_career_development
node_candidate -->|"tracks applications"| node_dashboard
node_dashboard -->|"renders"| node_applications_section
node_dashboard -->|"renders"| node_history_section
node_applications_route -->|"reads and writes"| node_database
node_session_route -->|"reads and writes"| node_database
node_sessions_route -->|"queries sessions"| node_database
node_events_route -->|"queries events"| node_database
node_applications_route -->|"records changes"| node_event_writer
node_session_route -->|"records changes"| node_event_writer
node_event_writer -->|"writes events"| node_database
node_applications_route -->|"checks identity"| node_auth
node_session_route -->|"checks identity"| node_auth
node_analyze_route -->|"checks identity"| node_auth
node_user_record -->|"queries records"| node_database
node_results_route -->|"reads and writes"| node_database
node_cover_route -.->|"persists letters"| node_database
node_cover_letters_route -->|"queries letters"| node_database

click node_analysis_page "https://github.com/bh-official/careercraftt/blob/main/src/components/AnalysisPage.jsx"
click node_analysis_state "https://github.com/bh-official/careercraftt/blob/main/src/context/AnalysisContext.jsx"
click node_file_uploader "https://github.com/bh-official/careercraftt/blob/main/src/components/FileUploader.jsx"
click node_upload_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/upload/route.js"
click node_file_processing "https://github.com/bh-official/careercraftt/blob/main/src/lib/fileProcessing.js"
click node_analyze_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/analyze/route.js"
click node_ai_service "https://github.com/bh-official/careercraftt/blob/main/src/lib/aiService.js"
click node_results_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/analysis-results/route.js"
click node_score_card "https://github.com/bh-official/careercraftt/blob/main/src/components/ScoreCard.jsx"
click node_gap_list "https://github.com/bh-official/careercraftt/blob/main/src/components/GapList.jsx"
click node_cover_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/cover-letter/route.js"
click node_cover_letters_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/cover-letters/route.js"
click node_cover_editor "https://github.com/bh-official/careercraftt/blob/main/src/components/CoverLetterEditor.jsx"
click node_optimization_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/optimization/route.js"
click node_optimization_tips "https://github.com/bh-official/careercraftt/blob/main/src/components/OptimizationTips.jsx"
click node_interview_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/interview/route.js"
click node_interview_prep "https://github.com/bh-official/careercraftt/blob/main/src/components/InterviewPrep.jsx"
click node_career_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/career/route.js"
click node_career_development "https://github.com/bh-official/careercraftt/blob/main/src/components/CareerDevelopment.jsx"
click node_dashboard "https://github.com/bh-official/careercraftt/blob/main/src/app/dashboard/page.js"
click node_applications_section "https://github.com/bh-official/careercraftt/blob/main/src/components/dashboard/ApplicationsSection.jsx"
click node_history_section "https://github.com/bh-official/careercraftt/blob/main/src/components/dashboard/ApplicationsHistorySection.jsx"
click node_applications_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/applications/route.js"
click node_session_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/session/route.js"
click node_sessions_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/sessions/route.js"
click node_events_route "https://github.com/bh-official/careercraftt/blob/main/src/app/api/application-events/route.js"
click node_event_writer "https://github.com/bh-official/careercraftt/blob/main/src/lib/applicationEvents.js"
click node_user_record "https://github.com/bh-official/careercraftt/blob/main/src/lib/ensureUserRecord.js"
click node_database "https://github.com/bh-official/careercraftt/blob/main/src/lib/db.js"

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_analysis_page,node_analysis_state,node_file_uploader,node_upload_route,node_analyze_route,node_results_route,node_score_card,node_gap_list toneBlue
class node_cover_route,node_cover_letters_route,node_cover_editor,node_optimization_route,node_optimization_tips,node_interview_route,node_interview_prep,node_career_route,node_career_development toneAmber
class node_dashboard,node_applications_section,node_history_section,node_applications_route,node_session_route,node_sessions_route,node_events_route,node_event_writer toneMint
class node_file_processing,node_ai_service,node_openrouter,node_auth,node_user_record,node_database toneRose
class node_candidate toneIndigo
```

## Components

### Analysis workflow

- [Analysis page](https://github.com/bh-official/careercraftt/blob/main/src/components/AnalysisPage.jsx): `src/components/AnalysisPage.jsx`
- [Analysis state](https://github.com/bh-official/careercraftt/blob/main/src/context/AnalysisContext.jsx): `src/context/AnalysisContext.jsx`
- [Resume and job inputs](https://github.com/bh-official/careercraftt/blob/main/src/components/FileUploader.jsx): `src/components/FileUploader.jsx`
- [Upload endpoint](https://github.com/bh-official/careercraftt/blob/main/src/app/api/upload/route.js): `src/app/api/upload/route.js`
- [Match analysis API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/analyze/route.js): `src/app/api/analyze/route.js`
- [Analysis results API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/analysis-results/route.js): `src/app/api/analysis-results/route.js`
- [Match scores](https://github.com/bh-official/careercraftt/blob/main/src/components/ScoreCard.jsx): `src/components/ScoreCard.jsx`
- [Requirement gaps](https://github.com/bh-official/careercraftt/blob/main/src/components/GapList.jsx): `src/components/GapList.jsx`

### Generated guidance

- [Cover letter API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/cover-letter/route.js): `src/app/api/cover-letter/route.js`
- [Cover letter records](https://github.com/bh-official/careercraftt/blob/main/src/app/api/cover-letters/route.js): `src/app/api/cover-letters/route.js`
- [Cover letter editor](https://github.com/bh-official/careercraftt/blob/main/src/components/CoverLetterEditor.jsx): `src/components/CoverLetterEditor.jsx`
- [Optimization API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/optimization/route.js): `src/app/api/optimization/route.js`
- [Optimization guidance](https://github.com/bh-official/careercraftt/blob/main/src/components/OptimizationTips.jsx): `src/components/OptimizationTips.jsx`
- [Interview API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/interview/route.js): `src/app/api/interview/route.js`
- [Interview preparation](https://github.com/bh-official/careercraftt/blob/main/src/components/InterviewPrep.jsx): `src/components/InterviewPrep.jsx`
- [Career API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/career/route.js): `src/app/api/career/route.js`
- [Career development](https://github.com/bh-official/careercraftt/blob/main/src/components/CareerDevelopment.jsx): `src/components/CareerDevelopment.jsx`

### Applications and history

- [Application dashboard](https://github.com/bh-official/careercraftt/blob/main/src/app/dashboard/page.js): `src/app/dashboard/page.js`
- [Applications list](https://github.com/bh-official/careercraftt/blob/main/src/components/dashboard/ApplicationsSection.jsx): `src/components/dashboard/ApplicationsSection.jsx`
- [Activity history](https://github.com/bh-official/careercraftt/blob/main/src/components/dashboard/ApplicationsHistorySection.jsx): `src/components/dashboard/ApplicationsHistorySection.jsx`
- [Applications API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/applications/route.js): `src/app/api/applications/route.js`
- [Session API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/session/route.js): `src/app/api/session/route.js`
- [Sessions API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/sessions/route.js): `src/app/api/sessions/route.js`
- [Application events API](https://github.com/bh-official/careercraftt/blob/main/src/app/api/application-events/route.js): `src/app/api/application-events/route.js`
- [Event recording](https://github.com/bh-official/careercraftt/blob/main/src/lib/applicationEvents.js): `src/lib/applicationEvents.js`

### Data and integrations

- [File parsing](https://github.com/bh-official/careercraftt/blob/main/src/lib/fileProcessing.js): `src/lib/fileProcessing.js`
- [AI generation](https://github.com/bh-official/careercraftt/blob/main/src/lib/aiService.js): `src/lib/aiService.js`
- **OpenRouter**
- **Clerk authentication**
- [User provisioning](https://github.com/bh-official/careercraftt/blob/main/src/lib/ensureUserRecord.js): `src/lib/ensureUserRecord.js`
- [PostgreSQL](https://github.com/bh-official/careercraftt/blob/main/src/lib/db.js): `src/lib/db.js`

### Other components

- **Candidate**

## Connections

- Candidate → Analysis page: provides inputs
- Analysis page → Resume and job inputs: renders (evidence: `src/components/AnalysisPage.jsx`)
- Analysis page → Analysis state: uses state (evidence: `src/components/AnalysisPage.jsx`)
- Analysis page → Match scores: renders (evidence: `src/components/AnalysisPage.jsx`)
- Analysis page → Requirement gaps: renders (evidence: `src/components/AnalysisPage.jsx`)
- Analysis state → Match analysis API: requests analysis
- Match analysis API → AI generation: runs analysis (evidence: `src/app/api/analyze/route.js`)
- Match analysis API → User provisioning: ensures user (evidence: `src/app/api/analyze/route.js`)
- Match analysis API → PostgreSQL: reads and writes (evidence: `src/app/api/analyze/route.js`)
- Match analysis API → Event recording: records activity (evidence: `src/app/api/analyze/route.js`)
- AI generation → OpenRouter: calls model API (evidence: `src/lib/aiService.js`)
- Candidate → Upload endpoint: uploads files
- Upload endpoint → File parsing: parses files (evidence: `src/app/api/upload/route.js`)
- Analysis state → Cover letter API: requests letter
- Analysis state → Optimization API: requests tips
- Analysis state → Interview API: requests prep
- Analysis state → Career API: requests guidance
- Cover letter API → AI generation: generates letter (evidence: `src/app/api/cover-letter/route.js`)
- Optimization API → AI generation: generates tips (evidence: `src/app/api/optimization/route.js`)
- Interview API → AI generation: generates prep (evidence: `src/app/api/interview/route.js`)
- Career API → AI generation: generates guidance (evidence: `src/app/api/career/route.js`)
- Analysis page → Cover letter editor: renders (evidence: `src/components/AnalysisPage.jsx`)
- Analysis page → Optimization guidance: renders (evidence: `src/components/AnalysisPage.jsx`)
- Analysis page → Interview preparation: renders (evidence: `src/components/AnalysisPage.jsx`)
- Analysis page → Career development: renders (evidence: `src/components/AnalysisPage.jsx`)
- Candidate → Application dashboard: tracks applications
- Application dashboard → Applications list: renders (evidence: `src/app/dashboard/page.js`)
- Application dashboard → Activity history: renders (evidence: `src/app/dashboard/page.js`)
- Applications API → PostgreSQL: reads and writes (evidence: `src/app/api/applications/route.js`)
- Session API → PostgreSQL: reads and writes (evidence: `src/app/api/session/route.js`)
- Sessions API → PostgreSQL: queries sessions (evidence: `src/app/api/sessions/route.js`)
- Application events API → PostgreSQL: queries events (evidence: `src/app/api/application-events/route.js`)
- Applications API → Event recording: records changes (evidence: `src/app/api/applications/route.js`)
- Session API → Event recording: records changes (evidence: `src/app/api/session/route.js`)
- Event recording → PostgreSQL: writes events (evidence: `src/lib/applicationEvents.js`)
- Applications API → Clerk authentication: checks identity (evidence: `src/app/api/applications/route.js`)
- Session API → Clerk authentication: checks identity (evidence: `src/app/api/session/route.js`)
- Match analysis API → Clerk authentication: checks identity (evidence: `src/app/api/analyze/route.js`)
- User provisioning → PostgreSQL: queries records (evidence: `src/lib/ensureUserRecord.js`)
- Analysis results API → PostgreSQL: reads and writes (evidence: `src/app/api/analysis-results/route.js`)
- Cover letter API → PostgreSQL: persists letters (evidence: `src/app/api/cover-letter/route.js`)
- Cover letter records → PostgreSQL: queries letters (evidence: `src/app/api/cover-letters/route.js`)
