# elloza/pptx2pdfwasm architecture

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

- Interactive diagram: https://gitdiagram.com/elloza/pptx2pdfwasm
- Repository: https://github.com/elloza/pptx2pdfwasm

## Overview

- Client Application / User Code – This is where a developer calls the Python API (for example, creating an instance of the PPTXtoPDFConverter, starting the server, initiating a conversion, and eventually stopping the server).
- PPTXtoPDFConverter Class – Central to the library, encapsulating the logic to launch and manage the conversion process.
- Local Web Server – Spawned by the converter; its main role is to host the web application which in turn utilizes the Libre Office wasm binaries.
- Static Assets & WASM Files – These resources (found in pptx2pdfwasm/static/static.zip) are extracted on the first run and include the compiled Libre Office wasm code and related web assets.
- Headless Browser (Playwright/Selenium) – This acts as a remote controller that loads the hosted web page, triggers the conversion within the WASM-based Libre Office instance, and finally handles conversion output.
- Test Suite – Represents the automated tests (located in the tests directory) ensuring that conversion works as expected.

##### Relationships and interactions
- The Client Application (or user’s code) calls the PPTXtoPDFConverter API.
- PPTXtoPDFConverter starts the local web server and ensures the static assets are extracted.
- The converter then launches a headless browser session (using Playwright or Selenium) to load the web page provided by the server.
- The web page uses the Libre Office wasm version to perform the conversion task.
- Finally, the output (converted PDF) is returned back to the converter, which then completes the process.
- All these interactions are verified in the Test Suite.

##### Architectural patterns and design principles
- Modular Design: Note how the conversion logic is isolated in its own module (converter.py) and the static assets are packaged separately, allowing for a clear separation of concerns.
- Resource Initialization: The on-first-run extraction of compressed static resources is an important initialization step.
- Use of Automation: The role of the headless browser for controlling the conversion process is a key part of this design.

##### Technology details
- Python for the main library (as evidenced by files like setup.py, pyproject.toml, and the package structure in pptx2pdfwasm/).
- Headless browser tools such as Playwright (or Selenium).
- Libre Office wasm (from ZetaOffice) as the underlying conversion engine.
- Web server technology (likely a lightweight built-in server to serve static content).

##### Specific elements to add
- Boxed components representing each subsystem with concise labels.
- From Client Application to PPTXtoPDFConverter.
- From Converter to Local Web Server.
- From Local Web Server to Headless Browser.
- From WASM execution (within the Headless Browser) back to the Converter with the conversion results.
- Annotations noting key actions such as "extract static.zip on first run", "start headless browser session", and "perform conversion using Libre Office WASM".

## Diagram (Mermaid)

```mermaid
graph TD
    A["Client Application / User Code"]:::client
    B["Python API (PPTXtoPDFConverter)"]:::api
    C["Local Web Server"]:::server
    D["Static Assets & Libre Office WASM"]:::resource
    E["Headless Browser Controller"]:::browser

    subgraph "Test Suite"
        F1["tests"]:::test
        F2["tests/test_converter.py"]:::test
        F3["tests/test.pptx"]:::test
    end

    A -->|"calls"| B
    B -->|"starts"| C
    B -->|"extracts"| D
    C -->|"hostsConversionPage"| E
    E -->|"returnsConversionResult"| B
    F1 -->|"verifies"| B
    F2 -->|"tests"| B
    F3 -->|"tests"| B

    click B "https://github.com/elloza/pptx2pdfwasm/blob/main/pptx2pdfwasm/converter.py"
    click D "https://github.com/elloza/pptx2pdfwasm/blob/main/pptx2pdfwasm/static/static.zip"
    click F1 "https://github.com/elloza/pptx2pdfwasm/tree/main/tests"
    click F2 "https://github.com/elloza/pptx2pdfwasm/blob/main/tests/test_converter.py"
    click F3 "https://github.com/elloza/pptx2pdfwasm/blob/main/tests/test.pptx"

    classDef client fill:#f9c,stroke:#333,stroke-width:2px;
    classDef api fill:#ccf,stroke:#333,stroke-width:2px;
    classDef server fill:#cfc,stroke:#333,stroke-width:2px;
    classDef resource fill:#fc9,stroke:#333,stroke-width:2px;
    classDef browser fill:#9cf,stroke:#333,stroke-width:2px;
    classDef test fill:#ffc,stroke:#333,stroke-width:2px;
```
