# mfontanini/presenterm architecture

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

- Interactive diagram: https://gitdiagram.com/mfontanini/presenterm
- Repository: https://github.com/mfontanini/presenterm

## Overview

##### Main Components
- Presentation Input & Parsing:
- Input “Markdown file” that defines the presentation.
- Components responsible for parsing and processing Markdown content (see the src/markdown directory with modules such as elements.rs, parse.rs, etc.).
- Presentation Processing & Building:
- “Presentation Builder” in src/presentation, which constructs the internal presentation model, assembling slides, snippets, and layout details.
- Rendering & Layout Engine:
- Layout operations, text rendering, and validation components (engine.rs, layout.rs, operation.rs, etc.).
- Terminal Interaction:
- Terminal module (src/terminal) that manages ANSI support, image protocols (kitty, iterm, ascii, sixel, etc.), and output abstraction.
- Code Execution & Highlighting:
- Subsystem for code execution and snippet handling (in src/code and src/ui/execution) along with highlighting features.
- Export & Output Converters:
- Integrate the export module (src/export) to show that the tool can export presentations to HTML or PDF.
- Theme & Configuration:
- Configuration handling (src/config.rs) and theming support (src/theme), plus the sample configurations and provided themes in the themes/ folder.
- Command Processing & Interaction:
- How commands and key bindings are processed (src/commands) for functionality like pausing and speaker notes.
- Additional Utilities:
- Mention supportive modules like transitions (src/transitions) and helper utilities (src/tools.rs, src/third_party.rs).

##### Relationships and Interactions
- The Markdown Parser creates an internal representation which is then passed to the “Presentation Builder” to create a structured model of the slides.
- This model flows into the “Rendering Engine” which interacts with the “Terminal Manager” to output the presentation in a styled, theme-aware format.
- Parallel to the display flow, the “Code Executor”/“Highlighter” processes any embedded source code with dependencies to external libraries (like bat or syntect) and produces syntax-highlighted output.
- When exporting, the same structured presentation model is handed over to the “Export Component” to generate PDF/HTML outputs.
- Underlying all of these is a configuration layer (parsing config-file-schema.json and config.sample.yaml) that informs theme selection, key bindings, and runtime behavior.
- Supportive modules (commands processing for interactive features, dynamic reloading, and transitions) that integrate with the presentation flow.

##### Architectural Patterns and Design Principles
- Modularity: Each major functionality (parsing, rendering, terminal handling, exporting) is divided into separate modules as detailed in the src/ subdirectories.
- Separation of Concerns: The system clearly separates content processing (parsing and structuring) from presentation (rendering and terminal output) and external export.
- Extensibility: The presence of themes, pluggable code execution (with support for multiple languages), and configuration files show that the design supports easy extension and customization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Input (Markdown File)"]:::inputStyle

    subgraph "Content Processing"
        MP["Markdown Parser"]:::processingStyle
        PB["Presentation Builder"]:::processingStyle
    end

    subgraph "Rendering & Code Execution"
        subgraph "Code Execution"
            CE["Code Executor & Highlighter"]:::renderingStyle
            EU["Execution UI"]:::renderingStyle
        end
        RE["Rendering Engine"]:::renderingStyle
    end

    subgraph "Output"
        TM["Terminal Manager"]:::outputStyle
        EM["Export Module"]:::outputStyle
    end

    TC["Theme & Configuration"]:::configStyle
    CP["Command Processing"]:::commandStyle
    AU["Additional Utilities"]:::utilitiesStyle

    U -->|"parses"| MP
    MP -->|"creates_model"| PB
    PB -->|"builds_presentation"| RE
    PB -->|"handles_codeSnippets"| CE
    CE -->|"triggers_execution"| EU
    EU -->|"feeds_highlightedCode"| RE
    PB -->|"prepares_export"| EM
    RE -->|"renders_to"| TM
    CP -->|"interacts_with"| TM

    TC -.-> MP
    TC -.-> PB
    TC -.-> RE
    TC -.-> TM
    TC -.-> EM

    AU -.-> PB
    AU -.-> RE

    click MP "https://github.com/mfontanini/presenterm/tree/master/src/markdown"
    click PB "https://github.com/mfontanini/presenterm/tree/master/src/presentation"
    click RE "https://github.com/mfontanini/presenterm/tree/master/src/render"
    click TM "https://github.com/mfontanini/presenterm/tree/master/src/terminal"
    click CE "https://github.com/mfontanini/presenterm/tree/master/src/code"
    click EU "https://github.com/mfontanini/presenterm/blob/master/src/ui/execution.rs"
    click EM "https://github.com/mfontanini/presenterm/tree/master/src/export"
    click TC "https://github.com/mfontanini/presenterm/blob/master/src/config.rs"
    click TC "https://github.com/mfontanini/presenterm/tree/master/src/theme"
    click CP "https://github.com/mfontanini/presenterm/tree/master/src/commands"
    click AU "https://github.com/mfontanini/presenterm/tree/master/src/transitions"
    click AU "https://github.com/mfontanini/presenterm/blob/master/src/tools.rs"
    click AU "https://github.com/mfontanini/presenterm/blob/master/src/third_party.rs"

    classDef inputStyle fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef processingStyle fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef renderingStyle fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef outputStyle fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef configStyle fill:#EEE8AA,stroke:#333,stroke-width:2px;
    classDef commandStyle fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef utilitiesStyle fill:#F08080,stroke:#333,stroke-width:2px;
```
