# kayesferdous/cvalchemix architecture

> Architecture diagram of the GitHub repository kayesferdous/cvalchemix, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kayesferdous/cvalchemix
- Repository: https://github.com/kayesferdous/cvalchemix

## Overview

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: [`src/cvalchemix/cli/main.py`](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/cli/main.py) (CLI), [`src/cvalchemix/config/config.py`](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/config.py) (Config), [`src/cvalchemix/tools/latex_renderer.py`](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/latex_renderer.py) (LaTeX renderer), [`src/cvalchemix/tools/linkedin_scraper.py`](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/linkedin_scraper.py) (LinkedIn scraper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_root_main["Launcher<br/>python entrypoint<br/>[main.py]"]
  node_cli_main["CLI<br/>command runner<br/>[main.py]"]
end

subgraph group_state["Config & state"]
  node_app_config["Config<br/>persistent settings<br/>[config.py]"]
  node_settings["Settings<br/>[settings.py]"]
  node_constants["Constants<br/>shared values<br/>[constants.py]"]
  node_ui["Terminal UI<br/>console helpers<br/>[ui.py]"]
  node_logging_cfg["Logging<br/>[logging.py]"]
end

subgraph group_ingest["LinkedIn input"]
  node_login_helper["Login helper<br/>session setup<br/>[login_helper.py]"]
  node_linkedin_scraper["LinkedIn scraper<br/>job ingestion"]
  node_tool_base["Tool base<br/>tool interface<br/>[base.py]"]
end

subgraph group_ai["LLM rewrite"]
  node_prompt["CV prompt<br/>prompt template"]
  node_llm_base["LLM base<br/>provider interface<br/>[base.py]"]
  node_gemini["Gemini<br/>llm provider<br/>[gemini.py]"]
end

subgraph group_model["CV model"]
  node_cv_schema["CV schema<br/>structured contract<br/>[cv_schema.py]"]
  node_schemas["Schemas<br/>data models<br/>[schemas.py]"]
  node_exceptions["Errors<br/>[exceptions.py]"]
end

subgraph group_render["Rendering output"]
  node_latex_renderer["LaTeX renderer<br/>render pipeline<br/>[latex_renderer.py]"]
  node_template["Classic template<br/>tex template<br/>[classic.tex.j2]"]
end

node_root_main -->|"launches"| node_cli_main
node_cli_main -->|"loads"| node_app_config
node_cli_main -->|"initializes"| node_logging_cfg
node_cli_main -->|"interacts"| node_ui
node_cli_main -->|"login"| node_login_helper
node_cli_main -->|"generate"| node_linkedin_scraper
node_login_helper -->|"enables"| node_linkedin_scraper
node_linkedin_scraper -->|"feeds"| node_prompt
node_prompt -->|"drives"| node_gemini
node_llm_base -->|"implements"| node_gemini
node_gemini -->|"returns"| node_cv_schema
node_cv_schema -->|"inputs"| node_latex_renderer
node_latex_renderer -->|"renders"| node_template
node_latex_renderer -->|"outputs"| node_cli_main
node_app_config -->|"derives"| node_settings
node_app_config -->|"uses"| node_constants
node_app_config -->|"raises"| node_exceptions
node_tool_base -->|"base for"| node_linkedin_scraper
node_tool_base -->|"base for"| node_latex_renderer
node_schemas -->|"supports"| node_cv_schema

click node_root_main "https://github.com/kayesferdous/cvalchemix/blob/main/main.py"
click node_cli_main "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/cli/main.py"
click node_app_config "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/config.py"
click node_settings "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/settings.py"
click node_constants "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/constants.py"
click node_ui "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/ui.py"
click node_logging_cfg "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/logging.py"
click node_login_helper "https://github.com/kayesferdous/cvalchemix/blob/main/login_helper.py"
click node_linkedin_scraper "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/linkedin_scraper.py"
click node_tool_base "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/base.py"
click node_prompt "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/prompts/cv_rewrite_prompt.py"
click node_llm_base "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/llm/base.py"
click node_gemini "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/llm/gemini.py"
click node_cv_schema "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/models/cv_schema.py"
click node_schemas "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/models/schemas.py"
click node_exceptions "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/models/exceptions.py"
click node_latex_renderer "https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/latex_renderer.py"
click node_template "https://github.com/kayesferdous/cvalchemix/blob/main/templates/classic.tex.j2"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_main,node_cli_main toneBlue
class node_app_config,node_settings,node_constants,node_ui,node_logging_cfg toneAmber
class node_login_helper,node_linkedin_scraper,node_tool_base toneMint
class node_prompt,node_llm_base,node_gemini toneRose
class node_cv_schema,node_schemas,node_exceptions toneIndigo
class node_latex_renderer,node_template toneTeal
```

## Components

### Entry points

CLI launchers and command surface

- [Launcher](https://github.com/kayesferdous/cvalchemix/blob/main/main.py): python entrypoint · Repository-level convenience launcher · `main.py`
- [CLI](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/cli/main.py): command runner · Implements configure, login, generate, show-config, delete · `src/cvalchemix/cli/main.py`

### Config & state

Local settings, persisted config, and session state

- [Config](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/config.py): persistent settings · Loads runtime settings and local config · `src/cvalchemix/config/config.py`
- [Settings](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/settings.py): env settings · Environment-driven options such as API key and output dir · `src/cvalchemix/config/settings.py`
- [Constants](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/constants.py): shared values · Repository-wide constants · `src/cvalchemix/config/constants.py`
- [Terminal UI](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/ui.py): console helpers · User interaction and prompts in the terminal · `src/cvalchemix/config/ui.py`
- [Logging](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/config/logging.py): logging setup · Application-wide logging configuration · `src/cvalchemix/config/logging.py`

### LinkedIn input

Browser-based job posting and login flows

- [Login helper](https://github.com/kayesferdous/cvalchemix/blob/main/login_helper.py): session setup · Persistent browser login and profile reuse · `login_helper.py`
- [LinkedIn scraper](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/linkedin_scraper.py): job ingestion · Extracts job title, company, location, and description from LinkedIn · `src/cvalchemix/tools/linkedin_scraper.py`
- [Tool base](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/base.py): tool interface · Shared base abstractions for tooling · `src/cvalchemix/tools/base.py`

### LLM rewrite

Prompting and model provider for tailoring content

- [CV prompt](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/prompts/cv_rewrite_prompt.py): prompt template · Shapes job and CV data into tailored rewrite instructions · `src/cvalchemix/prompts/cv_rewrite_prompt.py`
- [LLM base](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/llm/base.py): provider interface · Abstract interface for model providers · `src/cvalchemix/llm/base.py`
- [Gemini](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/llm/gemini.py): llm provider · Google Gemini implementation used for rewriting · `src/cvalchemix/llm/gemini.py`

### CV model

Structured CV contracts and domain errors

- [CV schema](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/models/cv_schema.py): structured contract · Normalizes model output into structured CV data · `src/cvalchemix/models/cv_schema.py`
- [Schemas](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/models/schemas.py): data models · Additional shared schemas for the domain · `src/cvalchemix/models/schemas.py`
- [Errors](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/models/exceptions.py): domain errors · Repository-specific exception types · `src/cvalchemix/models/exceptions.py`

### Rendering output

LaTeX template rendering and PDF compilation

- [LaTeX renderer](https://github.com/kayesferdous/cvalchemix/blob/main/src/cvalchemix/tools/latex_renderer.py): render pipeline · Renders Jinja2 template and compiles PDF via tectonic · `src/cvalchemix/tools/latex_renderer.py`
- [Classic template](https://github.com/kayesferdous/cvalchemix/blob/main/templates/classic.tex.j2): tex template · Bundled CV presentation template · `templates/classic.tex.j2`

## Connections

- 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
