# rodolfo-gallegos/pdf_to_excel architecture

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

- Interactive diagram: https://gitdiagram.com/rodolfo-gallegos/pdf_to_excel
- Repository: https://github.com/rodolfo-gallegos/pdf_to_excel

## Overview

This is a desktop PDF-table extraction tool, with a secondary command-line entry point. The main workflow is selecting PDFs and extraction options in the GUI, validating a locally stored Gemini key, analyzing selected pages with Gemini, then saving extracted tables as Excel, CSV, or Markdown. Page selection, resumable progress, normalization, and bilingual controls are documented capabilities. The sampled processor shows page-to-image conversion, Gemini requests, and Markdown parsing; some GUI orchestration is omitted, so those links are marked unverified rather than asserted as direct calls.

Main entry points: [`src/ui/app.py`](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py) (Desktop GUI), [`src/cli.py`](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/cli.py) (CLI), [`src/logic/processor.py`](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py) (Page selection), [`src/main.py`](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/main.py) (Desktop entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_cli["CLI<br/>[cli.py]"]
  node_main["Desktop entry<br/>[main.py]"]
end

subgraph group_interaction["User interaction"]
  node_gui["Desktop GUI<br/>[app.py]"]
  node_keycheck["Key validation<br/>[api_key.py]"]
  node_settings["Prompts and settings<br/>[config.py]"]
end

subgraph group_extraction["Extraction pipeline"]
  node_page_selection["Page selection<br/>[processor.py]"]
  node_pdf_render["PDF page rendering<br/>[processor.py]"]
  node_table_parse["Markdown table parsing<br/>[processor.py]"]
  node_normalization["Data normalization<br/>[processor.py]"]
end

subgraph group_outputs["Progress and outputs"]
  node_progress_cache[("Resume and cache<br/>[app.py]")]
  node_export["Format exports<br/>[app.py]"]
end

node_user(("User"))
node_pdfs["PDF files"]
node_gemini{{"Gemini API"}}
node_output_files["Excel, CSV, Markdown"]

node_user -->|"configures and starts"| node_gui
node_main -->|"opens"| node_gui
node_user -.->|"runs"| node_cli
node_pdfs -->|"selects"| node_gui
node_pdfs -->|"processes"| node_cli
node_gui -->|"validates key"| node_keycheck
node_gui -.->|"uses prompt"| node_settings
node_gui -.->|"requests extraction"| node_page_selection
node_cli -->|"selects pages"| node_page_selection
node_page_selection -.->|"processes pages"| node_pdf_render
node_pdf_render -->|"sends page image"| node_gemini
node_gemini -->|"returns Markdown"| node_table_parse
node_cli -->|"parses response"| node_table_parse
node_table_parse -.->|"normalizes optionally"| node_normalization
node_gui -->|"resumes progress"| node_progress_cache
node_gui -->|"writes selected formats"| node_export
node_cli -->|"writes formats"| node_export
node_export -->|"saves"| node_output_files

click node_gui "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py"
click node_cli "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/cli.py"
click node_main "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/main.py"
click node_keycheck "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/api_key.py"
click node_settings "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/config.py"
click node_page_selection "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py"
click node_pdf_render "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py"
click node_table_parse "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py"
click node_normalization "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py"
click node_progress_cache "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py"
click node_export "https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py"

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_cli,node_main,node_user toneBlue
class node_gui,node_keycheck,node_settings toneAmber
class node_page_selection,node_pdf_render,node_table_parse,node_normalization,node_gemini toneMint
class node_progress_cache,node_export toneRose
class node_pdfs,node_output_files toneIndigo
```

## Components

### Application entry

- [CLI](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/cli.py): `src/cli.py`
- [Desktop entry](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/main.py): `src/main.py`

### User interaction

- [Desktop GUI](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py): `src/ui/app.py`
- [Key validation](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/api_key.py): `src/logic/api_key.py`
- [Prompts and settings](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/config.py): `src/config.py`

### Extraction pipeline

- [Page selection](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py): `src/logic/processor.py`
- [PDF page rendering](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py): `src/logic/processor.py`
- [Markdown table parsing](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py): `src/logic/processor.py`
- [Data normalization](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/logic/processor.py): `src/logic/processor.py`

### Progress and outputs

- [Resume and cache](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py): `src/ui/app.py`
- [Format exports](https://github.com/rodolfo-gallegos/pdf_to_excel/blob/main/src/ui/app.py): `src/ui/app.py`

### Other components

- **User**
- **PDF files**
- **Gemini API**
- **Excel, CSV, Markdown**

## Connections

- User → Desktop GUI: configures and starts (evidence: `README.md`)
- Desktop entry → Desktop GUI: opens (evidence: `src/main.py`)
- User → CLI: runs
- PDF files → Desktop GUI: selects (evidence: `README.md`)
- PDF files → CLI: processes (evidence: `src/cli.py`)
- Desktop GUI → Key validation: validates key (evidence: `src/ui/app.py`)
- Desktop GUI → Prompts and settings: uses prompt (evidence: `src/ui/app.py`)
- Desktop GUI → Page selection: requests extraction (evidence: `src/ui/app.py`)
- CLI → Page selection: selects pages (evidence: `src/cli.py`)
- Page selection → PDF page rendering: processes pages (evidence: `src/logic/processor.py`)
- PDF page rendering → Gemini API: sends page image (evidence: `src/logic/processor.py`)
- Gemini API → Markdown table parsing: returns Markdown (evidence: `src/logic/processor.py`)
- CLI → Markdown table parsing: parses response (evidence: `src/cli.py`)
- Markdown table parsing → Data normalization: normalizes optionally (evidence: `src/logic/processor.py`)
- Desktop GUI → Resume and cache: resumes progress (evidence: `README.md`)
- Desktop GUI → Format exports: writes selected formats (evidence: `src/ui/app.py`)
- CLI → Format exports: writes formats (evidence: `src/cli.py`)
- Format exports → Excel, CSV, Markdown: saves (evidence: `README.md`)
