Resume Parsing
Relevant source files
The following files were used as context for generating this wiki page:
Resume Parsing is the core process that transforms an uploaded resume file (PDF or DOCX) into structured JSON data. This is achieved through a two-step process: first, the document is converted into plain text (Markdown), and second, a Large Language Model (LLM) is prompted to parse this text into a predefined JSON schema. The resulting structured data is fundamental for all subsequent features, including the Resume Builder, resume tailoring, and PDF generation.
Sources: README.md:29-34, apps/backend/app/routers/resumes.py:68-75, apps/backend/app/services/parser.py
Parsing Workflow
The parsing process begins when a user uploads a resume file via the frontend. The backend receives the file, validates it, converts it to text, and then uses an LLM to generate structured JSON data, which is finally stored in the database.
The following diagram illustrates the sequence of events during the resume upload and parsing workflow.
Core Components
API Endpoint: Resume Upload
The entire parsing process is initiated by a single API endpoint.
| Property | Description |
|---|---|
| Endpoint | POST /resumes/upload |
| Description | Uploads a resume file (PDF, DOC, DOCX), converts it to Markdown, and parses it into structured JSON using an LLM. |
| Request Body | multipart/form-data with a file field containing the resume. |
| File Validation | - Content-Type: application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document. - Max Size: 4MB. |
| Success Response | 200 OK with ResumeUploadResponse containing the resume_id. |
| Error Responses | - 400 Bad Request: Invalid file type or empty file. - 413 Payload Too Large: File exceeds 4MB. - 422 Unprocessable Entity: Document parsing fails. |
Sources: apps/backend/app/routers/resumes.py:50-66
The internal logic of the upload_resume endpoint handles validation, document conversion, and the two-phase database write.
Document to Text Conversion
The first step in the backend is converting the binary file (PDF/DOCX) into plain text. The parse_document function is responsible for this task. The output is Markdown-formatted text, which serves as the input for the LLM.
Sources: apps/backend/app/routers/resumes.py:91-98, apps/backend/app/services/parser.py
LLM-based JSON Parsing
The core of the parsing logic resides in the parse_resume_to_json function, which leverages an LLM. This is guided by a carefully crafted prompt that instructs the model to convert the unstructured resume text into a specific JSON format.
Sources: apps/backend/app/routers/resumes.py:108-115, apps/backend/app/services/parser.py
The LLM Prompt
The system uses the PARSE_RESUME_PROMPT to instruct the LLM. This prompt contains several key elements:
- A clear directive to output only the JSON object.
- An example of the desired output format (
RESUME_SCHEMA_EXAMPLE). - A definition of types for custom sections (
text,itemList,stringList). - A set of explicit rules for data normalization and formatting.
Sources: apps/backend/app/prompts/templates.py:84-110
Target JSON Schema
To ensure consistent output, the LLM is provided with an example schema. This schema defines the structure for personal information, summary, work experience, education, and other standard and custom sections.
{
"personalInfo": {
"name": "John Doe",
"title": "Software Engineer",
"email": "john@example.com",
"phone": "+1-555-0100",
"location": "San Francisco, CA",
"website": "https://johndoe.dev",
"linkedin": "linkedin.com/in/johndoe",
"github": "github.com/johndoe"
},
"summary": "Experienced software engineer with 5+ years...",
"workExperience": [
{
"id": 1,
"title": "Senior Software Engineer",
"company": "Tech Corp",
"location": "San Francisco, CA",
"years": "2020 - Present",
"description": [
"Led development of microservices architecture",
"Improved system performance by 40%"
]
}
],
"education": [
{
"id": 1,
"institution": "University of California",
"degree": "B.S. Computer Science",
"years": "2014 - 2018",
"description": "Graduated with honors"
}
],
"personalProjects": [
// ...
],
"additional": {
"technicalSkills": ["Python", "JavaScript", "AWS", "Docker"],
"languages": ["English (Native)", "Spanish (Conversational)"],
// ...
},
"customSections": {
"publications": {
"sectionType": "itemList",
"items": [
// ...
]
}
}
}
Sources: apps/backend/app/prompts/templates.py:16-82
Parsing Rules
The prompt enforces a strict set of rules to normalize the data extracted from the resume.
| Rule | Description |
|---|---|
| Missing Fields | Use "" for missing text, [] for missing arrays, and null for optional fields. |
| IDs | Number all list item IDs starting from 1. |
| Years | Format date ranges as "YYYY - YYYY" or "YYYY - Present". |
| Custom Sections | Use snake_case for keys (e.g., volunteer_work) and preserve the original section name. |
| Date Normalization | Convert formats like "Jan 2020" to "2020", "Current" to "Present", and infer ambiguous dates. |
| Concurrent Roles | Preserve overlapping date ranges for concurrent roles; do not merge them. |
Sources: apps/backend/app/prompts/templates.py:93-102
Data Storage and Processing Status
To handle the asynchronous nature of LLM processing, the system uses a status field in the database.
- When a resume is first uploaded and converted to text, it is saved with a
processing_statusof"processing". - If the subsequent LLM call to parse the text into JSON succeeds, the status is updated to
"ready", and theprocessed_datafield is populated. - If the LLM call fails, the status is updated to
"failed", andprocessed_dataremains empty.
This allows the frontend to track the parsing progress and handle cases where LLM processing might fail without losing the original text content.
Sources: apps/backend/app/routers/resumes.py:100-121
Error Handling
The parsing workflow includes robust error handling at multiple stages:
- File Validation: The
upload_resumeendpoint immediately rejects files that do not match the allowed MIME types (pdf,doc,docx) or exceed the 4MB size limit. - Document Conversion Failure: If the
parse_documentfunction fails to convert the file to text, anHTTPExceptionwith status code422 Unprocessable Entityis raised. - LLM Parsing Failure: If
parse_resume_to_jsonfails (e.g., due to an invalid API key or LLM error), the exception is caught. The resume's status is set to"failed", but the raw text content is preserved in the database. This prevents data loss and allows for potential reprocessing.
Sources: apps/backend/app/routers/resumes.py:81-88, 93-98, 112-116
Conclusion
The resume parsing system in Resume-Matcher is a critical feature that intelligently converts unstructured resume documents into structured, machine-readable JSON. By combining document-to-text conversion with sophisticated LLM prompting, it creates a reliable data foundation. This structured data is essential for the application's advanced features, such as AI-driven resume tailoring, dynamic content editing in the builder, and customizable PDF exports. The use of processing statuses and robust error handling ensures a resilient and user-friendly experience.