How kayesferdous/cvalchemix works
1. What this repo is
CVAlchemix is a command-line pipeline that turns a LinkedIn job posting plus a user’s base CV into a tailored PDF CV. The architecture is a linear workflow: CLI input → config/session checks → LinkedIn scraping → Gemini rewrite → LaTeX render → PDF output.
2. Entry points and command surface
The user-facing entrypoint appears to be src/cvalchemix/cli/main.py, with main.py at the repo root acting as a packaging or convenience launcher. The CLI exposes the repository’s core operations: configure, login, generate, show-config, and delete. This makes the app primarily an orchestration layer around the pipeline rather than a long-running service.
3. Configuration boundary
Configuration lives under src/cvalchemix/config/ and is split into several concerns:
- settings.py for runtime/environment-driven settings like API key, output directory, headless browser mode, and retries.
- config.py for persisted local user config.
- constants.py and ui.py for shared values and terminal interaction.
- logging.py for app-wide logging setup.
The README indicates config is stored locally in the user’s config directory, with .env also supported as an input source. This is the main boundary between transient CLI runs and persistent user state.
4. Persistent login/session handling
The login flow is a separate subsystem from generation. login_helper.py and the LinkedIn-specific tool code likely open a Playwright browser with a persistent profile so the user can authenticate once and reuse that session later. The persisted browser profile is a critical architectural boundary because the scraper depends on authenticated or session-stable access to LinkedIn job pages.
5. LinkedIn scraping subsystem
src/cvalchemix/tools/linkedin_scraper.py is the ingestion layer. It uses Playwright to open the job URL and extract the job title, company, location, and full description. The README notes it currently supports only one LinkedIn URL pattern, which means the scraper is tightly coupled to a specific page shape and CSS selectors. This is the system’s most brittle external dependency.
6. LLM rewrite subsystem
src/cvalchemix/llm/ contains the abstraction for language-model access:
- base.py defines the provider interface.
- gemini.py implements Google Gemini.
The rewrite step takes the scraped job data plus the user’s base CV and produces structured CV content. The repo currently treats Gemini as the only provider, so the model layer is a single-provider adapter rather than a pluggable multi-vendor system.
7. Structured CV representation
src/cvalchemix/models/ defines the data contracts that sit between the LLM and the renderer. cv_schema.py and schemas.py imply a structured CVData-style model, and exceptions.py contains domain-specific errors. This is an important architectural boundary: the LLM output is not passed directly to rendering; it is normalized into a schema first, which protects the rest of the pipeline from free-form text.
8. Prompting layer
src/cvalchemix/prompts/cv_rewrite_prompt.py contains the prompt used to convert the base CV and job description into the structured schema. This sits between scraping and model invocation and is the main place where “tailoring logic” is encoded. In architecture terms, it is the policy layer that shapes how job information is transformed into CV content.
9. Rendering and compilation
src/cvalchemix/tools/latex_renderer.py turns the structured CV model into LaTeX and compiles it to PDF. The README says it uses a Jinja2 template and then calls tectonic as an external binary. That means PDF generation is a two-step boundary:
- template rendering inside Python
- TeX compilation outside Python via a local system dependency
The intermediate .tex file is intentionally preserved next to the PDF, making the renderer both a generator and an inspection point.
10. Template assets
The bundled template lives in templates/classic.tex.j2. This is the visual presentation layer for the generated CV. Because only one template is shipped, template choice is currently not a branching subsystem; it is a fixed output style with room for future expansion.
11. End-to-end data flow
The typical generate path is:
- read local config and environment
- verify Gemini key, base CV path, and LinkedIn session readiness
- scrape the LinkedIn posting
- prompt Gemini to rewrite the CV into the internal schema
- render that schema into LaTeX
- compile LaTeX to PDF with tectonic
- write both cv.tex and cv.pdf under the chosen output directory
The output structure is job-specific and timestamped, which suggests each generation is treated as an immutable artifact rather than an in-place update.
12. Operational constraints and external dependencies
The architecture depends on three external systems: LinkedIn for job data, Google Gemini for content transformation, and tectonic for PDF compilation. Playwright is the browser automation runtime behind scraping and login persistence. These dependencies define the app’s reliability envelope: if LinkedIn markup changes, Gemini is unavailable, or tectonic is missing, the pipeline fails at different stages.
13. Repository shape and packaging
The project is packaged as a Python CLI app under src/, with supporting install scripts (install.sh, install.ps1) and a pyproject.toml-based build. The presence of uv.lock suggests reproducible dependency management in development or release workflows. This is a self-contained command-line product rather than a library-first repository.
14. What to emphasize in an architecture diagram
A clear diagram should show:
- the CLI as the orchestrator
- local config/session storage as stateful inputs
- LinkedIn scraping as the first external I/O boundary
- Gemini as the transformation engine
- the CV schema as the internal contract between AI and rendering
- LaTeX/Jinja2 plus tectonic as the final presentation/compilation stage
- generated artifacts (cv.tex, cv.pdf) as outputs
That captures the repo’s true shape: a stateful, single-user, command-driven document generation pipeline.
Main entry points: main.py CLI · config.py Config · latex_renderer.py LaTeX renderer · linkedin_scraper.py LinkedIn scraper
Components 18
Entry points
CLI launchers and command surface
Config & state
Local settings, persisted config, and session state
- Config · Loads runtime settings and local config
src/cvalchemix/config/config.py - Settings · Environment-driven options such as API key and output dir
src/cvalchemix/config/settings.py - Constants · Repository-wide constants
src/cvalchemix/config/constants.py - Terminal UI · User interaction and prompts in the terminal
src/cvalchemix/config/ui.py - Logging · Application-wide logging configuration
src/cvalchemix/config/logging.py
LinkedIn input
Browser-based job posting and login flows
- Login helper · Persistent browser login and profile reuse
login_helper.py - LinkedIn scraper · Extracts job title, company, location, and description from LinkedIn
src/cvalchemix/tools/linkedin_scraper.py - Tool base · Shared base abstractions for tooling
src/cvalchemix/tools/base.py
LLM rewrite
Prompting and model provider for tailoring content
CV model
Structured CV contracts and domain errors
Rendering output
LaTeX template rendering and PDF compilation
- LaTeX renderer · Renders Jinja2 template and compiles PDF via tectonic
src/cvalchemix/tools/latex_renderer.py - Classic template · Bundled CV presentation template
templates/classic.tex.j2
Connections 20
- Launcher → CLI: launches · Starts the CLI application
- CLI → Config: loads · Reads persisted and runtime configuration
- CLI → Logging: initializes · Sets up application logging
- CLI → Terminal UI: interacts · Prompts and displays command output
- CLI → Login helper: login · Runs persistent LinkedIn authentication flow
- CLI → LinkedIn scraper: generate · Scrapes the target LinkedIn job posting
- Login helper → LinkedIn scraper: enables · Provides authenticated browser context for scraping
- LinkedIn scraper → CV prompt: feeds · Supplies job data to the tailoring prompt
- CV prompt → Gemini: drives · Constructs the rewrite request for the model
- LLM base → Gemini: implements · Defines the provider abstraction used by Gemini
- Gemini → CV schema: returns · Produces structured CV content
- CV schema → LaTeX renderer: inputs · Provides normalized data for rendering
- LaTeX renderer → Classic template: renders · Applies the LaTeX/Jinja2 template
- LaTeX renderer → CLI: outputs · Writes generated .tex and .pdf artifacts
- Config → Settings: derives · Combines local config with environment settings
- Config → Constants: uses · Shares repository-wide constants
- Config → Errors: raises · Uses domain errors for validation and failures
- Tool base → LinkedIn scraper: base for · Common tool abstraction for scraper implementation
- Tool base → LaTeX renderer: base for · Common tool abstraction for renderer implementation
- Schemas → CV schema: supports · Additional shared data contracts