Resume Enhancement Flow
Relevant source files
The following files were used as context for generating this wiki page:
The Resume Enhancement Flow is a core feature of the GUC Resume Enhancer application. It enables users to apply AI-powered improvements to their uploaded resumes. The process involves selecting an enhancement type, invoking a backend service that communicates with an external Large Language Model (LLM) provider (like OpenAI, Anthropic, or Google Gemini), and then displaying the original and enhanced resume content side-by-side for comparison.
This flow is initiated after a user uploads a resume, which is parsed and stored. The user then interacts with the enhancement interface to trigger the AI processing. The system is designed to be modular, allowing different AI providers and enhancement types to be configured.
System Architecture
The enhancement process spans from the user interface to the backend API, interacting with the database and external AI services. The user selects an enhancement type and initiates the process, which triggers an API call. The backend then orchestrates the enhancement by fetching the necessary data, calling the configured AI provider, and storing the result.
The following diagram illustrates the high-level data flow.
Frontend: Enhancement Interface
The user-facing part of the flow is managed by the EnhanceInterface React component. This component is responsible for displaying enhancement options, handling user input, triggering the enhancement process, and rendering the results.
Sources: enhance/[id]/_components/enhance-interface.tsx
Component Overview
The interface presents the user with:
- A list of available enhancement types.
- A button to initiate the enhancement.
- A preview area to compare the original resume with the AI-enhanced version.
- A history of past enhancements for the current resume.
- A button to download the enhanced resume as a PDF.
An alert is displayed if the user has not configured any API keys, prompting them to do so.
Sources: enhance/[id]/_components/enhance-interface.tsx:71-80, 305-313, 492-516
State Management
The component uses React's useState hook to manage its internal state, including:
selectedEnhancement: The enhancement type chosen by the user.isEnhancing: A boolean flag to indicate if an enhancement is in progress.progress: A number from 0-100 to show enhancement progress.currentEnhancement: The enhancement object currently being viewed.previewMode: Controls the view ('original', 'enhanced', 'side-by-side').
Sources: enhance/[id]/_components/enhance-interface.tsx:135-142
Enhancement Trigger (handleEnhance)
When the user clicks the "Enhance Resume" button, the handleEnhance function is executed. This function performs the following actions:
- Validates that an enhancement type is selected and API keys are configured.
- Sets
isEnhancingtotrueand resets progress. - Sends a
POSTrequest to the/api/enhance-resume/[resume.id]endpoint with the selectedenhancementType. - The front-end is designed to handle a streaming response, but the current implementation reloads the page upon completion to display the new enhancement.
- If the request fails, an error toast is displayed.
Sources: enhance/[id]/_components/enhance-interface.tsx:219-281
Result Display
The enhanced content, which is Markdown text returned by the AI, is sanitized to prevent XSS attacks using DOMPurify and then rendered as HTML using the marked library. The cleanAndRenderMarkdown helper function is responsible for this process.
Sources: enhance/[id]/_components/enhance-interface.tsx:112-125, 481-486
Backend: API Endpoint
The core backend logic resides in a single API route that handles the AI enhancement requests.
POST /api/enhance-resume/{id}
This endpoint orchestrates the resume enhancement process. It is a dynamic route with a 5-minute maximum duration to accommodate potentially long-running AI tasks.
| Parameter | Type | Location | Description |
|---|---|---|---|
id | string | URL Path | The ID of the Resume to be enhanced. |
enhancementType | string | Body | The type of enhancement to perform. Must be one of the allowed types. |
Sources: api/enhance-resume/[id]/route.ts:8, 179-183
Backend Processing Flow
The following diagram details the logic within the API endpoint.
Sources: api/enhance-resume/[id]/route.ts
AI Provider Integration
The system is designed to work with multiple AI providers. The selection of the provider is determined by the user's active API key.
Sources: api/enhance-resume/[id]/route.ts:241-256
Provider Abstraction
Helper functions (enhanceWithOpenAI, enhanceWithAnthropic, enhanceWithGemini) abstract the specifics of calling each provider's API. Each function takes the API key, model, original resume content, and enhancement type, and returns the enhanced text.
Sources: api/enhance-resume/[id]/route.ts:11-170
Enhancement Prompts
Each enhancement type corresponds to a specific prompt sent to the AI. The system prompt instructs the AI to act as a "professional resume writer specializing in trade and technical resumes" and to format the output in Markdown.
Example prompt for skills_certifications:
Enhance the following resume by highlighting trade skills, licenses, and certifications. Make them prominent and well-formatted:
[original resume content]
Sources: api/enhance-resume/[id]/route.ts:13-16, 42-45, 76-79, 110-113
Supported Enhancement Types
The available enhancement types are hardcoded in the EnhanceInterface component.
| Value | Label | Description |
|---|---|---|
skills_certifications | Skills & Certifications | Highlight trade skills, licenses, and certifications |
project_experience | Project Experience | Showcase completed work and technical expertise |
client_quality | Client Success & Quality | Emphasize customer satisfaction and quality work |
Sources: enhance/[id]/_components/enhance-interface.tsx:71-89, api/enhance-resume/[id]/route.ts:174-177
Data Models
The enhancement flow relies on two primary data models defined in schema.prisma: Resume and ResumeEnhancement. The Resume model stores the original uploaded file's content, while ResumeEnhancement stores the result of each AI enhancement run.
This ER diagram shows the relationship between users, resumes, and their enhancements.
Sources: schema.prisma
ResumeEnhancement Table
This table stores the output of each enhancement job.
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier for the enhancement. |
resumeId | String | Foreign key linking to the Resume table. |
enhancementType | String | The type of enhancement performed (e.g., skills_certifications). |
enhancedContent | String | The AI-generated resume content, stored as text (Markdown). |
llmProvider | String | The AI provider used (e.g., openai, anthropic, gemini). |
status | String | The status of the job (processing, completed, error). |
enhancementNotes | String? | Stores error messages if the enhancement fails. |
createdAt | DateTime | Timestamp of when the enhancement was created. |
updatedAt | DateTime | Timestamp of the last update. |
Sources: schema.prisma:108-120
Overall Sequence Flow
This sequence diagram shows the complete interaction from the user's click to the final UI update.
Conclusion
The Resume Enhancement Flow is a well-defined, asynchronous process that serves as the application's main value proposition. It effectively decouples the frontend interface from the backend AI processing logic. The use of a centralized API endpoint to orchestrate interactions between the database and external AI services provides a robust and maintainable architecture. The data model, with distinct Resume and ResumeEnhancement tables, allows for a clear history of all enhancement activities for a given resume.