Data Models and Schemas
Relevant source files
The following files were used as context for generating this wiki page:
The data models and schemas are the backbone of the Resume Matcher application, providing a structured and consistent way to handle data across the backend, frontend, and AI services. These models, primarily defined using Pydantic, ensure data integrity, facilitate serialization/deserialization, and serve as a clear contract for API endpoints and LLM interactions. They are crucial for features like resume parsing, dynamic section management, and AI-powered content generation.
The core of the system is the ResumeData model, which represents a complete, structured resume. This model is designed to be flexible, supporting both default sections and user-defined custom sections, allowing for a high degree of personalization.
Core Resume Schema: ResumeData
The ResumeData model is the central data structure for representing a resume within the application. It is composed of several sub-models for default sections and includes a flexible system for handling custom sections.
Sources: apps/backend/app/schemas/models.py:186-199
ResumeData Class Diagram
This diagram illustrates the composition of the ResumeData model, showing its relationship with standard and custom section models.
Default Section Models
The ResumeData model includes several default fields for common resume sections.
| Model | Description | File Reference |
|---|---|---|
PersonalInfo | Contains contact and identifying information. | apps/backend/app/schemas/models.py:19-28 |
Experience | Represents a single entry in the work experience section. | apps/backend/app/schemas/models.py:31-38 |
Education | Represents a single entry in the education section. | apps/backend/app/schemas/models.py:41-48 |
Project | Represents a single entry for personal projects. | apps/backend/app/schemas/models.py:51-57 |
AdditionalInfo | A container for lists of skills, languages, certifications, and awards. | apps/backend/app/schemas/models.py:60-66 |
Backward Compatibility
To support older resume data that may not have the dynamic section fields, the normalize_resume_data function is used. This function performs a lazy migration by adding default sectionMeta and an empty customSections dictionary if they are missing. It crucially uses copy.deepcopy() to prevent a shared mutable reference bug across different resumes.
# apps/backend/app/schemas/models.py:165-176
def normalize_resume_data(data: dict[str, Any]) -> dict[str, Any]:
"""Ensure resume data has section metadata (migration helper).
This function is used for lazy migration of existing resumes
that don't have sectionMeta or customSections fields.
"""
if not data.get("sectionMeta"):
# Use deepcopy to avoid shared mutable reference bug
# Without this, all resumes would share the same list reference
data["sectionMeta"] = copy.deepcopy(DEFAULT_SECTION_META)
if "customSections" not in data:
data["customSections"] = {}
return data
Sources: apps/backend/app/schemas/models.py:165-176, REPORT.md:21-26
Dynamic Section System
A key feature of the data model is its support for dynamic, user-configurable resume sections. This is managed through the sectionMeta and customSections fields in the ResumeData model.
Sources: AGENTS.md, apps/backend/app/schemas/models.py:70-163
Section Types
Sections are categorized by SectionType, which determines their structure and content.
SectionType Enum | Description |
|---|---|
PERSONAL_INFO | A special type for the header, which is always first. |
TEXT | A single block of text, like a summary or objective. |
ITEM_LIST | An array of items, each with fields like title, subtitle, years, and description. Used for experience, projects, etc. |
STRING_LIST | A simple array of strings, used for skills, languages, or hobbies. |
Sources: apps/backend/app/schemas/models.py:9-16, AGENTS.md
SectionMeta Model
The sectionMeta field in ResumeData is a list of SectionMeta objects. Each object defines the properties and state of a section, such as its display name, visibility, and order.
| Field | Type | Description |
|---|---|---|
id | str | A unique identifier for the section (e.g., "summary", "custom_1"). |
key | str | The key used to access the section's data in ResumeData or customSections. |
displayName | str | The user-visible name of the section. |
sectionType | SectionType | The type of the section, from the enum. |
isDefault | bool | True for built-in sections, False for user-created ones. |
isVisible | bool | Controls whether the section is shown in the generated PDF. |
order | int | The display order of the section. |
Sources: apps/backend/app/schemas/models.py:70-79
CustomSection Model
The customSections field is a dictionary where keys are section keys (e.g., "publications") and values are CustomSection objects. This model acts as a container for the data of a custom section, with different fields used depending on the sectionType.
| Field | Type | Used for SectionType |
|---|---|---|
sectionType | SectionType | All |
items | list[CustomSectionItem] | ITEM_LIST |
strings | list[str] | STRING_LIST |
text | str | TEXT |
Sources: apps/backend/app/schemas/models.py:92-98
Relationship Diagram
This diagram shows how ResumeData uses SectionMeta to manage the order and visibility of both default and custom sections, and CustomSection to store the data for non-default sections.
LLM Schema Definition
To ensure the LLM generates resume data in the correct JSON format, a schema example is provided within the prompt. The RESUME_SCHEMA_EXAMPLE string in templates.py serves as this guide.
Sources: apps/backend/app/prompts/templates.py:17-100
Resume Parsing Flow
The following diagram shows how a raw resume document is converted into the structured ResumeData JSON object.
The RESUME_SCHEMA_EXAMPLE provides a concrete example for the LLM, detailing the expected structure for all default and custom sections.
// apps/backend/app/prompts/templates.py:17-100
{
"personalInfo": {
"name": "John Doe",
"title": "Software Engineer",
...
},
"summary": "Experienced software engineer with 5+ years...",
"workExperience": [ ... ],
"education": [ ... ],
"personalProjects": [ ... ],
"additional": { ... },
"customSections": {
"publications": {
"sectionType": "itemList",
"items": [ ... ]
},
"volunteer_work": {
"sectionType": "text",
"text": "Description of volunteer activities..."
}
}
}
API Schemas
Pydantic models are used extensively in the API layer (apps/backend/app/routers/) to define request bodies and response payloads, ensuring type safety and automatic validation.
Request Models
| Model | Endpoint | Description |
|---|---|---|
ImproveResumeRequest | POST /resumes/improve | Contains resume_id and job_id to tailor a resume. |
UpdateCoverLetterRequest | PATCH /resumes/{id}/cover-letter | Contains new content for the cover letter. |
LLMConfigRequest | PUT /config/llm | Used to update LLM provider, model, and API key. |
LanguageConfigRequest | PUT /config/language | Sets UI and content generation languages. |
Sources: apps/backend/app/schemas/models.py:236-241, 287-290, 303-311, 321-325
Response Models
| Model | Endpoint | Description |
|---|---|---|
ResumeUploadResponse | POST /resumes/upload | Confirms upload and returns resume_id. |
ResumeFetchResponse | GET /resumes | Contains the full ResumeData object and associated metadata. |
ResumeListResponse | GET /resumes/list | Returns a list of ResumeSummary objects. |
ImproveResumeResponse | POST /resumes/improve | Returns the new tailored resume_id, a preview, and improvement suggestions. |
LLMConfigResponse | GET /config/llm | Returns the current LLM configuration with a masked API key. |
Sources: apps/backend/app/schemas/models.py:208-213, 226-231, 244-248, 258-274, 314-320
Enrichment Schemas
The resume enrichment feature uses its own set of schemas to manage the multi-step AI workflow. These are defined in the prompts within apps/backend/app/prompts/enrichment.py.
Enrichment Workflow
This sequence diagram shows the flow of data and the schemas used when a user enhances their resume.
Analysis and Enhancement Models
The prompts in enrichment.py define the expected JSON output format for the analysis and enhancement steps.
- Analysis Output: The
ANALYZE_RESUME_PROMPTexpects a JSON object containingitems_to_enrich, a list ofquestionsto ask the user, and ananalysis_summary. This structure helps the frontend build the enrichment wizard. - Enhancement Output: The
ENHANCE_DESCRIPTION_PROMPTexpects a simple JSON object with anadditional_bulletsarray, containing the new, AI-generated bullet points to be added to the resume.