Data Flow
Relevant source files
The following files were used as context for generating this wiki page:
The data flow in Resume Matcher is centered around the transformation of user-provided documents into a structured, editable, and renderable JSON format. This process begins with parsing an uploaded resume, proceeds through an optional AI-powered tailoring stage, and culminates in the generation of a customized PDF.
The core of this system is the ResumeData Pydantic model, which serves as the canonical structure for all resume information. Data flows from the frontend Next.js application to the backend FastAPI server, where it is processed by services that interact with an LLM and a TinyDB database.
Initial Resume Upload and Parsing
This flow describes how an unstructured resume document (PDF/DOCX) is converted into a structured JSON object and stored in the database. The process involves document conversion, LLM-based parsing, and database persistence.
The following diagram illustrates the sequence of events during the initial resume upload.
Key Steps
- File Upload: The user uploads a resume file. The frontend does not perform any processing.
- API Request: The frontend sends a
POSTrequest to the/api/v1/resumes/uploadendpoint.
Sources: apps/backend/app/routers/resumes.py:49-52 - Validation & Parsing: The backend validates the file's content type and size. It then calls the
parse_documentservice to convert the file into Markdown text.
Sources: apps/backend/app/routers/resumes.py:54-75 - Initial Storage: The raw Markdown content is immediately saved to the database with a
processingstatus.
Sources: apps/backend/app/routers/resumes.py:82-89 - JSON Parsing: The
parse_resume_to_jsonservice is invoked. This service uses an LLM, guided by thePARSE_RESUME_PROMPT, to convert the Markdown into a structured JSON object. The prompt includes a schema example (RESUME_SCHEMA_EXAMPLE) to ensure the LLM's output format is correct.
Sources: apps/backend/app/services/parser.py:22-31, apps/backend/app/prompts/templates.py:106-131 - Final Storage: The resulting JSON
processed_datais added to the resume's database record, and the status is updated toready. If LLM parsing fails, the status is set tofailed.
Sources: apps/backend/app/routers/resumes.py:92-104
Resume Tailoring Flow
Once a master resume exists, it can be tailored for a specific job description. This flow involves two main API calls orchestrated by the frontend: uploading the job description and then triggering the improvement process.
The sequence diagram below shows the interaction between the frontend, backend, and LLM to produce a tailored resume.
Key Steps
- Job Description Upload: From the
/tailorpage, the frontend first callsuploadJobDescriptionswhich hits thePOST /jobs/uploadendpoint to store the job description and get ajob_id.
Sources: apps/frontend/app/(default)/tailor/page.tsx:48-50, apps/frontend/lib/api/resume.ts:81-90 - Improvement Request: The frontend then immediately calls
improveResume, which sends aPOSTrequest to/resumes/improvewith the masterresume_idand the newjob_id.
Sources: apps/frontend/app/(default)/tailor/page.tsx:53-54, apps/frontend/lib/api/resume.ts:92-120 - AI-Powered Tailoring: The backend fetches the necessary data and uses the
improve_resumeservice. This service calls the LLM with theIMPROVE_RESUME_PROMPT, providing the original resume, job description, and extracted keywords. The LLM is instructed to rephrase content and highlight relevant experience without inventing new information.
Sources: apps/backend/app/routers/resumes.py:241-253, apps/backend/app/prompts/templates.py:133-162 - Store New Resume: The AI-generated
ResumeDataJSON is stored as a new resume in the database. This new record includes aparent_idfield that links it back to the original master resume.
Sources: apps/backend/app/routers/resumes.py:291-302 - Response and Redirect: The backend returns the complete tailored resume data. The frontend stores this in a context and redirects the user to the resume builder page (
/resumes/[id]) with the ID of the newly created tailored resume.
Sources: apps/frontend/app/(default)/tailor/page.tsx:57-65
Core Data Structure: ResumeData
The ResumeData Pydantic model is the standardized schema for all structured resume information in the application. It is defined in the backend and its structure is mirrored in the frontend TypeScript interfaces. This model is what gets stored as processed_data in the database and is the primary object manipulated by the resume builder and PDF generator.
Sources: apps/backend/app/schemas/models.py:183-196, apps/frontend/lib/api/resume.ts:5-49
The diagram below shows the composition of the ResumeData model.
Data Normalization
For backward compatibility with older resume records that may not have the sectionMeta or customSections fields, a normalize_resume_data function is used. When a resume is fetched, this function checks for the presence of sectionMeta and adds a default structure from DEFAULT_SECTION_META if it's missing. It uses copy.deepcopy() to prevent a mutable shared state bug across different resumes.
Sources: apps/backend/app/schemas/models.py:171-180, apps/backend/app/routers/resumes.py:149-150
PDF Generation Flow
The application generates PDFs by using a headless browser (Playwright) to "print" a dedicated frontend page. This approach allows the PDF to be styled with CSS and rendered using React components, ensuring consistency with the on-screen preview.
This flowchart outlines the steps from a user's download request to receiving the PDF file.
Key Steps
- URL Construction: When the user clicks download, the frontend API client (
downloadResumePdf) constructs a URL pointing to the print page (/print/resumes/[id]). This URL is appended with numerous query parameters representing the user's chosen template settings (e.g.,template,pageSize, margins, fonts).
Sources: apps/frontend/lib/api/resume.ts:182-206 - Backend Request: The client makes a
GETrequest to the/resumes/{resume_id}/pdfendpoint, passing along all the template settings as query parameters.
Sources: apps/backend/app/routers/resumes.py:381-411 - Headless Rendering: The backend's
render_resume_pdffunction launches a headless Chromium instance via Playwright. It instructs the browser to navigate to the frontend print URL that was constructed in step 1.
Sources: apps/backend/app/routers/resumes.py:412-421, apps/backend/app/pdf.py - Frontend Rendering: The Next.js print page (
/print/resumes/[id]/page.tsx) receives the request. It fetches the specified resume'sResumeDatafrom the backend, parses the template settings from the URL, and renders the appropriate React resume component (ResumeSingleColumnorResumeTwoColumn) with the styles applied.
Sources: apps/frontend/app/print/resumes/[id]/page.tsx:83-172 - PDF Capture: Once the page is fully rendered in the headless browser, Playwright's
page.pdf()function captures the output as a PDF, applying the specified page size and margins.
Sources: apps/backend/app/routers/resumes.py:434-436, apps/backend/app/pdf.py - File Download: The backend sends the generated PDF bytes back to the user's browser with a
Content-Dispositionheader, triggering a file download.
Sources: apps/backend/app/routers/resumes.py:438-441
Conclusion
The data flow of Resume Matcher is a well-defined pipeline that transforms unstructured data into a highly structured and versatile JSON format. The ResumeData model is the linchpin of the architecture, providing a consistent schema that decouples the initial parsing logic from the final rendering and AI-driven enhancement features. This separation allows for complex operations like resume tailoring and customizable PDF generation to be performed reliably on a standardized data object.