# lacig/slidev architecture

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

- Interactive diagram: https://gitdiagram.com/lacig/slidev
- Repository: https://github.com/lacig/slidev

## Overview

##### Main Components
- CLI/Server (packages/slidev): This package contains the core CLI commands, server setup (for live preview, building, serving), and integrations (e.g., exporting slides, handling add-ons). It communicates with the parsing layer and with the client.
- Presentation Client (packages/client): A Vue-based frontend application that renders the slides. It encapsulates components like layouts (in packages/client/layouts), interactive controls, and embedded Vue components to support interactivity (e.g., drawing, live coding).
- Theme & App Scaffolding (packages/create-app and packages/create-theme): Provides templates and tooling to rapidly bootstrap new projects or themes, facilitating customization.
- VSCode Integration (packages/vscode): Contains the language server, commands, and live preview capabilities for an integrated development experience in VSCode.
- Shared Types and Utilities (packages/types, shared state): These packages define TypeScript definitions used across the project and contain shared logic (e.g., configuration, context menus, and state management).

##### Out Relationships and Interactions
- User Workflow: A developer writes slides in Markdown. The CLI (Slidev) is then used to start a development session.
- The CLI fetches the markdown content and passes it to the Parser, which processes it and produces an intermediate representation.
- The Presentation Client picks up this processed data and renders the slides using Vue 3. This client communicates with both the backend (for live preview, reloading, presenter mode, etc.) and with external libraries.
- Theme and plugin systems inject additional functionalities (e.g., UnoCSS for styling, Shiki and Monaco for code editing and syntax highlighting, RecordRTC for recording).
- The VSCode extension integrates directly with these components, providing an editor experience with real-time preview and debugging support.

##### Architectural Patterns and Design Principles
- Monorepo Structure: Emphasize that all packages are maintained in one repository, facilitating shared tooling and consistency. It follows a modular design where each package has its own responsibility.
- Separation of Concerns: UI (client), processing/parsing (parser), and command/control (CLI/slidev) are clearly decoupled.
- Plugin and Extensibility: Multiple integration points (themes, addons, VSCode integration) enable high customizability.
- Developer Experience Focus: Fast reloading via Vite, a rich set of interactive features, and a focus on markdown as the source of truth.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Components
    USER["User Input (Markdown Files)"]:::core
    PARSER["Markdown Parser (packages/parser) - Parses Markdown"]:::core
    CLI["Slidev CLI (packages/slidev) - Handles build, serve, export"]:::core
    CLIENT["Presentation Client (packages/client) - Renders interactive slides"]:::core
    SHARED["Shared Types & Utilities (packages/types) - TS definitions & shared logic"]:::core

    %% Scaffolding Tools
    APPSCAFF["App Scaffolding (packages/create-app) - Bootstraps new apps"]:::scaffolding
    THEMESCAFF["Theme Scaffolding (packages/create-theme) - Bootstraps themes"]:::scaffolding

    %% VSCode Extension
    VSCODE["VSCode Extension (packages/vscode) - Provides integrated preview & editing"]:::integration

    %% External Libraries/Integrations Subgraph
    subgraph "External Libraries & Integrations"
        VUE["Vue 3"]:::external
        VITE["Vite"]:::external
        UNOCSS["UnoCSS"]:::external
        SHIKI_MONACO["Shiki/Monaco"]:::external
        KATEX["KaTeX"]:::external
        MERMAID["Mermaid"]:::external
        RECORDRTC["RecordRTC"]:::external
        ICONIFY["Iconify"]:::external
    end

    %% Main Flow
    USER -->|"feeds"| PARSER
    PARSER -->|"produces slide data"| CLI
    CLI -->|"delivers slides"| CLIENT

    %% Shared Utilities usage (core modules use shared types)
    CLI ---|"uses"| SHARED
    PARSER ---|"uses"| SHARED
    CLIENT ---|"uses"| SHARED

    %% Scaffolding interactions (CLI utilizes scaffolding tools for bootstrapping)
    CLI -->|"triggers"| APPSCAFF
    CLI -->|"triggers"| THEMESCAFF

    %% VSCode Extension interactions
    VSCODE -->|"integrates with"| CLI
    VSCODE -->|"integrates with"| CLIENT

    %% Presentation Client integrating with external libraries
    CLIENT -->|"renders via"| VUE
    CLIENT -->|"bundled with"| VITE
    CLIENT -->|"styles with"| UNOCSS
    CLIENT -->|"code editing via"| SHIKI_MONACO
    CLIENT -->|"math rendering via"| KATEX
    CLIENT -->|"diagram support via"| MERMAID
    CLIENT -->|"recording via"| RECORDRTC
    CLIENT -->|"icons via"| ICONIFY

    %% Click Events for Component Mapping
    click CLI "https://github.com/lacig/slidev/tree/main/packages/slidev"
    click PARSER "https://github.com/lacig/slidev/tree/main/packages/parser"
    click CLIENT "https://github.com/lacig/slidev/tree/main/packages/client"
    click APPSCAFF "https://github.com/lacig/slidev/tree/main/packages/create-app"
    click THEMESCAFF "https://github.com/lacig/slidev/tree/main/packages/create-theme"
    click VSCODE "https://github.com/lacig/slidev/tree/main/packages/vscode"
    click SHARED "https://github.com/lacig/slidev/tree/main/packages/types"

    %% Styles
    classDef core fill:#AEDFF7,stroke:#000,stroke-width:1px;
    classDef scaffolding fill:#C2F4B2,stroke:#000,stroke-width:1px;
    classDef integration fill:#F7D6AE,stroke:#000,stroke-width:1px;
    classDef external fill:#F7A8F7,stroke:#000,stroke-width:1px;
```
