# wzsyyh/auto-slides architecture

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

- Interactive diagram: https://gitdiagram.com/wzsyyh/auto-slides
- Repository: https://github.com/wzsyyh/auto-slides

## Overview

1. **What this repository is**
   Auto-Slides is a command-line pipeline that turns an academic PDF into Beamer slide decks. The architecture is not a single monolith; it is a staged multi-agent workflow that moves from PDF understanding to slide planning, LaTeX generation, validation/repair, and optional interactive revision.

2. **Top-level entry and orchestration**
   `main.py` is the primary entry point. It likely parses CLI flags such as language, theme, revision mode, verification/repair toggles, and speech generation, then coordinates the workflow across the modules. `modules/tex_workflow.py` and `modules/workflow_state.py` appear to hold the orchestration logic and shared state for the pipeline.

3. **PDF ingestion and content extraction**
   The first subsystem is PDF parsing: `modules/pdf_parser.py` plus extractors such as `lightweight_extractor.py`, `simple_text_extractor.py`, and `table_image_extractor_v2.py`. The README indicates the system can use a heavier PDF model (`marker-pdf`, downloaded via `down_model.py`) for layout-aware extraction, including text, figures, tables, and structure. This is the boundary where the original paper is converted into normalized raw content.

4. **Multimodal asset handling**
   Figures and tables are handled as first-class artifacts rather than embedded text blobs. `modules/intelligent_figure_matcher.py`, `table_image_extractor_v2.py`, and `special_char_handler.py` likely map extracted visual elements to the right slide locations and clean up text/LaTeX-unfriendly characters. The repository’s `static/figures` and `static/themes` directories support presentation assets and theme styling.

5. **Presentation planning layer**
   After extraction, the system plans the slide structure. `modules/lightweight_planner.py` and `modules/presentation_planner.py` generate a pedagogically optimized outline: what sections to show, what to emphasize, and how to split the paper into slides. The `prompts/slides_planning*` and `prompts/summarize_text_for_presentation*` files are the prompt layer that drives this planning step.

6. **Reference and citation subsystem**
   The `modules/reference_agent/` package is a dedicated sub-pipeline for literature-aware enhancement. It includes citation extraction, content extraction, content integration, and literature search, with a small cache under `literature_cache/`. This subsystem is separate from the core slide planner because it augments the presentation content with reference context rather than only summarizing the source paper.

7. **LaTeX/Beamer generation**
   Slide rendering is done through a family of TEX generators: `basic_tex_generator.py`, `direct_tex_generator.py`, `tex_generator.py`, and `revision_tex_generator.py`. These modules turn the presentation plan into Beamer source, selecting themes, formatting equations/code/tables, and embedding extracted images. Prompt templates in `prompts/tex_generation*`, `prompts/basic_tex_generation.py`, and `prompts/direct_tex_generation*` drive this generation layer.

8. **Quality control: verification and repair loop**
   Generated slide content is checked before final output. `modules/verification_agent.py`, `simplified_verification_agent.py`, and `tex_validator.py` appear to inspect whether the TEX matches the planned content and whether it compiles cleanly. If issues are found, `modules/repair_agent.py` and `simplified_repair_agent.py` attempt automated fixes. This creates a closed loop between generation, validation, and repair.

9. **Interactive revision path**
   The repository also supports human-in-the-loop refinement. `modules/interactive_reviser.py`, `react_interactive_editor.py`, and `react_interactive_editor_new.py` suggest a dialog-based revision interface using ReAct-style prompting. Prompt files such as `prompts/interactive_refinement.py` and `prompts/react_editor_prompts.py` define how user feedback is translated into plan or TEX edits.

10. **Optional speech generation**
   `modules/speech_generator.py` adds an auxiliary output channel: a presentation speech script aligned to the slide deck. The README’s speech options imply this is downstream of slide planning and generation, using the planned structure to produce a timed narration.

11. **LLM integration and configuration**
   `modules/llm_interface.py` is the abstraction boundary to the language model provider. `config/llm_params.py` stores model parameters, and `patch_openai.py` suggests compatibility handling around the OpenAI client. The system is configured via `.env`, with OpenAI API access as the central runtime dependency.

12. **Compilation and runtime artifacts**
   The final stage is LaTeX compilation and artifact organization. The README describes output folders for raw extraction, plans, TEX, images, verification, repair, and speech, which implies the workflow persists intermediate state at each boundary. The project depends on a local LaTeX toolchain for producing the final PDF, and compilation can be skipped to keep only TEX output.

13. **How to think about the architecture diagram**
   A good diagram would show a left-to-right pipeline with feedback loops: PDF input → extraction → planning → TEX generation → validation/repair → LaTeX compilation → final slides, with side branches for reference enhancement, interactive revision, and speech generation. The key architectural distinction is that raw PDF understanding, slide reasoning, and presentation rendering are separated into distinct modules connected by persisted intermediate artifacts and shared workflow state.

Main entry points: [`modules/tex_workflow.py`](https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_workflow.py) (Tex workflow), [`modules/tex_generator.py`](https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_generator.py) (TEX generator), [`modules/llm_interface.py`](https://github.com/wzsyyh/auto-slides/blob/main/modules/llm_interface.py) (LLM interface), [`modules/pdf_parser.py`](https://github.com/wzsyyh/auto-slides/blob/main/modules/pdf_parser.py) (PDF parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_orchestration["Orchestration"]
  node_node_main["main.py<br/>CLI entrypoint<br/>[main.py]"]
  node_node_workflow["Tex workflow<br/>pipeline orchestrator<br/>[tex_workflow.py]"]
  node_node_state[("Workflow state<br/>shared state<br/>[workflow_state.py]")]
end

subgraph group_group_extraction["PDF Extraction"]
  node_node_pdf_parser["PDF parser<br/>pdf boundary<br/>[pdf_parser.py]"]
  node_node_light_extractor["Light extractor<br/>text/layout extractor"]
  node_node_simple_text["Text extractor"]
  node_node_table_image["Table images<br/>table/figure extractor"]
  node_node_figure_matcher["Figure matcher<br/>asset aligner"]
end

subgraph group_group_planning["Slide Planning"]
  node_node_planner["Presentation planner<br/>slide planner"]
  node_node_light_planner["Light planner<br/>outline planner"]
  node_node_summarize_prompt["Summarize prompt<br/>prompt template"]
  node_node_slides_prompt["Slides prompt<br/>prompt template<br/>[slides_planning.py]"]
end

subgraph group_group_generation["TEX Generation"]
  node_node_tex_gen["TEX generator<br/>beamer generator<br/>[tex_generator.py]"]
  node_node_basic_tex["Basic TEX<br/>tex generator"]
  node_node_revision_tex["Revision TEX<br/>tex generator"]
  node_node_verifier["Verifier<br/>quality gate"]
  node_node_repair["Repair agent<br/>fixup loop<br/>[repair_agent.py]"]
  node_node_tex_validator["TEX validator<br/>compile check<br/>[tex_validator.py]"]
end

subgraph group_group_reference["Reference & Revision"]
  node_node_reference["Reference agent<br/>citation pipeline<br/>[reference_agent.py]"]
  node_node_interactive["Interactive reviser<br/>human-in-loop editor"]
  node_node_speech["Speech generator<br/>narration output"]
end

subgraph group_group_runtime["Runtime & Assets"]
  node_node_llm["LLM interface<br/>model adapter<br/>[llm_interface.py]"]
  node_node_config["LLM params<br/>configuration<br/>[llm_params.py]"]
  node_node_prompts["Prompts<br/>prompt assets"]
  node_node_assets[("Static assets<br/>themes/figures")]
end

node_node_main -->|"starts"| node_node_workflow
node_node_workflow -->|"stores"| node_node_state
node_node_workflow -->|"ingests"| node_node_pdf_parser
node_node_pdf_parser -->|"dispatches"| node_node_light_extractor
node_node_pdf_parser -->|"fallback"| node_node_simple_text
node_node_pdf_parser -->|"extracts"| node_node_table_image
node_node_table_image -->|"matches"| node_node_figure_matcher
node_node_workflow -->|"plans"| node_node_planner
node_node_workflow -.->|"alternative path"| node_node_light_planner
node_node_planner -->|"guided by"| node_node_slides_prompt
node_node_planner -->|"summarizes with"| node_node_summarize_prompt
node_node_workflow -.->|"enriches"| node_node_reference
node_node_workflow -.->|"optional output"| node_node_speech
node_node_planner -->|"feeds"| node_node_tex_gen
node_node_tex_gen -.->|"variant"| node_node_basic_tex
node_node_tex_gen -.->|"variant"| node_node_revision_tex
node_node_tex_gen -->|"checks"| node_node_verifier
node_node_verifier -->|"fails over"| node_node_repair
node_node_repair -->|"regenerates"| node_node_revision_tex
node_node_verifier -->|"compile check"| node_node_tex_validator
node_node_interactive -->|"edits"| node_node_revision_tex
node_node_reference -->|"uses"| node_node_llm
node_node_interactive -->|"uses"| node_node_llm
node_node_workflow -->|"drives"| node_node_llm
node_node_llm -->|"configured by"| node_node_config
node_node_llm -->|"prompted by"| node_node_prompts
node_node_tex_gen -->|"styles with"| node_node_assets

click node_node_main "https://github.com/wzsyyh/auto-slides/blob/main/main.py"
click node_node_workflow "https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_workflow.py"
click node_node_state "https://github.com/wzsyyh/auto-slides/blob/main/modules/workflow_state.py"
click node_node_pdf_parser "https://github.com/wzsyyh/auto-slides/blob/main/modules/pdf_parser.py"
click node_node_light_extractor "https://github.com/wzsyyh/auto-slides/blob/main/modules/lightweight_extractor.py"
click node_node_simple_text "https://github.com/wzsyyh/auto-slides/blob/main/modules/simple_text_extractor.py"
click node_node_table_image "https://github.com/wzsyyh/auto-slides/blob/main/modules/table_image_extractor_v2.py"
click node_node_figure_matcher "https://github.com/wzsyyh/auto-slides/blob/main/modules/intelligent_figure_matcher.py"
click node_node_planner "https://github.com/wzsyyh/auto-slides/blob/main/modules/presentation_planner.py"
click node_node_light_planner "https://github.com/wzsyyh/auto-slides/blob/main/modules/lightweight_planner.py"
click node_node_summarize_prompt "https://github.com/wzsyyh/auto-slides/blob/main/prompts/summarize_text_for_presentation.py"
click node_node_slides_prompt "https://github.com/wzsyyh/auto-slides/blob/main/prompts/slides_planning.py"
click node_node_tex_gen "https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_generator.py"
click node_node_basic_tex "https://github.com/wzsyyh/auto-slides/blob/main/modules/basic_tex_generator.py"
click node_node_revision_tex "https://github.com/wzsyyh/auto-slides/blob/main/modules/revision_tex_generator.py"
click node_node_verifier "https://github.com/wzsyyh/auto-slides/blob/main/modules/verification_agent.py"
click node_node_repair "https://github.com/wzsyyh/auto-slides/blob/main/modules/repair_agent.py"
click node_node_tex_validator "https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_validator.py"
click node_node_reference "https://github.com/wzsyyh/auto-slides/blob/main/modules/reference_agent/reference_agent.py"
click node_node_interactive "https://github.com/wzsyyh/auto-slides/blob/main/modules/interactive_reviser.py"
click node_node_speech "https://github.com/wzsyyh/auto-slides/blob/main/modules/speech_generator.py"
click node_node_llm "https://github.com/wzsyyh/auto-slides/blob/main/modules/llm_interface.py"
click node_node_config "https://github.com/wzsyyh/auto-slides/blob/main/config/llm_params.py"
click node_node_prompts "https://github.com/wzsyyh/auto-slides/tree/main/prompts"
click node_node_assets "https://github.com/wzsyyh/auto-slides/tree/main/static"

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_node_main,node_node_workflow,node_node_state toneBlue
class node_node_pdf_parser,node_node_light_extractor,node_node_simple_text,node_node_table_image,node_node_figure_matcher toneAmber
class node_node_planner,node_node_light_planner,node_node_summarize_prompt,node_node_slides_prompt toneMint
class node_node_tex_gen,node_node_basic_tex,node_node_revision_tex,node_node_verifier,node_node_repair,node_node_tex_validator toneRose
class node_node_reference,node_node_interactive,node_node_speech toneIndigo
class node_node_llm,node_node_config,node_node_prompts,node_node_assets toneTeal
```

## Components

### Orchestration

CLI entrypoint and shared workflow state.

- [main.py](https://github.com/wzsyyh/auto-slides/blob/main/main.py): CLI entrypoint · Parses options and starts the slide-generation pipeline. · `main.py`
- [Tex workflow](https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_workflow.py): pipeline orchestrator · Coordinates extraction, planning, generation, and finalization. · `modules/tex_workflow.py`
- [Workflow state](https://github.com/wzsyyh/auto-slides/blob/main/modules/workflow_state.py): shared state · Carries intermediate artifacts and pipeline status across stages. · `modules/workflow_state.py`

### PDF Extraction

PDF parsing and content normalization.

- [PDF parser](https://github.com/wzsyyh/auto-slides/blob/main/modules/pdf_parser.py): pdf boundary · Central PDF ingestion layer for document parsing and dispatch. · `modules/pdf_parser.py`
- [Light extractor](https://github.com/wzsyyh/auto-slides/blob/main/modules/lightweight_extractor.py): text/layout extractor · Fast extraction path for paper text and structure. · `modules/lightweight_extractor.py`
- [Text extractor](https://github.com/wzsyyh/auto-slides/blob/main/modules/simple_text_extractor.py): plain-text extractor · Fallback or simplified text extraction from PDFs. · `modules/simple_text_extractor.py`
- [Table images](https://github.com/wzsyyh/auto-slides/blob/main/modules/table_image_extractor_v2.py): table/figure extractor · Extracts and normalizes tables and image-based assets. · `modules/table_image_extractor_v2.py`
- [Figure matcher](https://github.com/wzsyyh/auto-slides/blob/main/modules/intelligent_figure_matcher.py): asset aligner · Matches extracted figures to the right presentation locations. · `modules/intelligent_figure_matcher.py`

### Slide Planning

Outline and presentation structure synthesis.

- [Presentation planner](https://github.com/wzsyyh/auto-slides/blob/main/modules/presentation_planner.py): slide planner · Builds the main pedagogical slide structure from extracted content. · `modules/presentation_planner.py`
- [Light planner](https://github.com/wzsyyh/auto-slides/blob/main/modules/lightweight_planner.py): outline planner · Fast planning path for concise slide outlines. · `modules/lightweight_planner.py`
- [Summarize prompt](https://github.com/wzsyyh/auto-slides/blob/main/prompts/summarize_text_for_presentation.py): prompt template · Prompt for condensing paper text into presentation-ready content. · `prompts/summarize_text_for_presentation.py`
- [Slides prompt](https://github.com/wzsyyh/auto-slides/blob/main/prompts/slides_planning.py): prompt template · Prompt layer that shapes slide planning decisions. · `prompts/slides_planning.py`

### TEX Generation

Beamer rendering, validation, and repair.

- [TEX generator](https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_generator.py): beamer generator · Primary rendering layer for Beamer source generation. · `modules/tex_generator.py`
- [Basic TEX](https://github.com/wzsyyh/auto-slides/blob/main/modules/basic_tex_generator.py): tex generator · Simpler generation path for producing Beamer output. · `modules/basic_tex_generator.py`
- [Revision TEX](https://github.com/wzsyyh/auto-slides/blob/main/modules/revision_tex_generator.py): tex generator · Generates updated TEX after interactive or repair-driven changes. · `modules/revision_tex_generator.py`
- [Verifier](https://github.com/wzsyyh/auto-slides/blob/main/modules/verification_agent.py): quality gate · Checks generated TEX against the plan and expected output quality. · `modules/verification_agent.py`
- [Repair agent](https://github.com/wzsyyh/auto-slides/blob/main/modules/repair_agent.py): fixup loop · Attempts automated fixes when TEX or content validation fails. · `modules/repair_agent.py`
- [TEX validator](https://github.com/wzsyyh/auto-slides/blob/main/modules/tex_validator.py): compile check · Validates generated LaTeX for structural or compilation issues. · `modules/tex_validator.py`

### Reference & Revision

Citation enrichment and interactive edits.

- [Reference agent](https://github.com/wzsyyh/auto-slides/blob/main/modules/reference_agent/reference_agent.py): citation pipeline · Adds literature context and citation-aware enhancements. · `modules/reference_agent/reference_agent.py`
- [Interactive reviser](https://github.com/wzsyyh/auto-slides/blob/main/modules/interactive_reviser.py): human-in-loop editor · Supports dialog-based revision of slides and TEX. · `modules/interactive_reviser.py`
- [Speech generator](https://github.com/wzsyyh/auto-slides/blob/main/modules/speech_generator.py): narration output · Produces an aligned presentation speech script. · `modules/speech_generator.py`

### Runtime & Assets

Configuration, prompts, themes, and compiled artifacts.

- [LLM interface](https://github.com/wzsyyh/auto-slides/blob/main/modules/llm_interface.py): model adapter · Abstraction boundary for language-model calls. · `modules/llm_interface.py`
- [LLM params](https://github.com/wzsyyh/auto-slides/blob/main/config/llm_params.py): configuration · Model and runtime settings used by the pipeline. · `config/llm_params.py`
- [Prompts](https://github.com/wzsyyh/auto-slides/tree/main/prompts): prompt assets · Repository prompt templates that drive extraction, planning, generation, and revision. · `prompts`
- [Static assets](https://github.com/wzsyyh/auto-slides/tree/main/static): themes/figures · Presentation themes and reusable figure assets. · `static`

## Connections

- main.py → Tex workflow: starts · CLI hands off execution to the workflow orchestrator.
- Tex workflow → Workflow state: stores · Workflow state tracks artifacts across stages.
- Tex workflow → PDF parser: ingests · Begins by parsing the source PDF.
- PDF parser → Light extractor: dispatches · Routes to a fast extraction path.
- PDF parser → Text extractor: fallback · Uses simplified text extraction when needed.
- PDF parser → Table images: extracts · Pulls tables and image-based elements.
- Table images → Figure matcher: matches · Aligns extracted visual assets with source content.
- Tex workflow → Presentation planner: plans · Hands normalized content to the main slide planner.
- Tex workflow → Light planner: alternative path · Supports a lighter planning strategy.
- Presentation planner → Slides prompt: guided by · Planning behavior is shaped by prompt templates.
- Presentation planner → Summarize prompt: summarizes with · Uses summarization prompts to condense source content.
- Tex workflow → Reference agent: enriches · Optional reference-aware enhancement stage.
- Tex workflow → Speech generator: optional output · Can generate a narration script from the slide plan.
- Presentation planner → TEX generator: feeds · Presentation plan becomes TEX generation input.
- TEX generator → Basic TEX: variant · Basic generator is one rendering option.
- TEX generator → Revision TEX: variant · Revision-aware generator supports edits and fixes.
- TEX generator → Verifier: checks · Generated TEX is validated against expectations.
- Verifier → Repair agent: fails over · Validation problems route to automated repair.
- Repair agent → Revision TEX: regenerates · Repair loop produces revised TEX.
- Verifier → TEX validator: compile check · LaTeX syntax and compilation are checked.
- Interactive reviser → Revision TEX: edits · Human-in-the-loop changes flow into revised TEX.
- Reference agent → LLM interface: uses · Reference pipeline relies on model calls.
- Interactive reviser → LLM interface: uses · Interactive editing also routes through the LLM boundary.
- Tex workflow → LLM interface: drives · Core workflow delegates reasoning tasks to the model layer.
- LLM interface → LLM params: configured by · Model behavior is parameterized centrally.
- LLM interface → Prompts: prompted by · Prompt assets define task-specific behavior.
- TEX generator → Static assets: styles with · Themes and figures support final presentation rendering.
