# pipipi-pikachu/pptist architecture

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

- Interactive diagram: https://gitdiagram.com/pipipi-pikachu/pptist
- Repository: https://github.com/pipipi-pikachu/pptist

## Overview

##### Project Type & Purpose
- PPTist is a front-end, single-page application (SPA) that emulates Microsoft PowerPoint’s features. Its primary purpose is slide editing, real-time presentation editing, and previewing across devices (desktop, mobile, and presenter modes).
- Built with Vue 3, the project avoids heavy third-party UI libraries to facilitate custom styling and easier extension.

##### Analyzing the File Structure
- Top-Level Layout: Notice files like index.html, package.json, vite.config.ts, and configuration files that solidify it as a frontend SPA.
- src Directory: This is the heart of the application. It contains:
- Component layers (e.g., src/components and src/views) which clearly divide UI elements for different parts of the app.
- Views are grouped based on use-cases—Editor (full slide editing), Mobile (mobile editing and preview), and Screen (presentation mode).
- Directories like src/hooks and src/services indicate reusable logic layers (custom hooks for operations like dragging, scaling, history, etc., and services for config and communication).
- The store (src/store) provides state management across UI components.
- Documentation (doc/): Provides extra context such as element behaviors, canvas layout, and custom element information.

##### Core Components and Relationships
a. Main Components to Highlight:
– Presentation Editor: Comprises the “Editor” view (src/views/Editor) that holds the canvas, toolbar, thumbnail panel, export dialogs, etc.
– Canvas & Slide Management: The canvas area (src/views/Editor/Canvas) where slides are rendered for editing. Also includes gridlines, guides, and selection components.
– Toolbar & Context Menus: Tools for adjusting styles and options (many are under src/views/Editor/Toolbar) and a context menu available globally (src/components/Contextmenu).
– Mobile & Screen Views: Submodules like src/views/Mobile and src/views/Screen capture adaptation for mobile editing and presentation modes.
– Global Utilities & Store: The global state management in src/store and utility functions in src/utils (such as clipboard, DOM manipulation, prosemirror integrations) tie the UI together.

b. Relationships & Interactions:
– The Editor view interacts with Canvas, which in turn renders individual slide elements.
– Toolbar and context menus provide controls that trigger actions through hooks (src/hooks) and update state via the store.
– Custom directives (in src/plugins/directive) manage DOM event behaviors, like click-outside or tooltips.
– Services (in src/services) abstract configuration or integration logic, forming the bridge between UI state and “back-end-like” operations (e.g., export functions).
– Communication flows from UI events (e.g., dragging, selecting, editing) through custom hooks (e.g., useMoveElement, useDeleteElement) to update the Vue store.
– Reusable utility libraries (in src/utils and src/views/components/element/hooks) handle transformations, parsing (like the HTML and SVG parsers), and other operations.

##### Architectural Patterns & Design Principles
- Component-Based Architecture: Uses Vue’s single-file component design to modularize complex slide editing and presentation functions.
- Separation of Concerns: Dividing views (editor, mobile, screen) from business logic (services, hooks, store) makes the design maintainable.
- Reusability: Custom hooks and utilities encourage reuse across various editing capabilities.
- State Management: The central store (with modules like slides, snapshot, keyboard, and screen) is pivotal for synchronizing UI state and interaction events.
- Responsive Design: Multiple views (Editor, Mobile, Screen) cater to different device requirements using similar underlying logic.

## Diagram (Mermaid)

```mermaid
graph TD
    %% UI Layer
    subgraph "UI Layer"
        A1["Presentation Editor"]:::ui
        A2["Canvas & Slide Management"]:::ui
        A3["Toolbar & Context Menus"]:::ui
        A6["Element Components"]:::ui_elem
        A4["Mobile Views"]:::ui
        A5["Screen Presentation Mode"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        B1["Custom Hooks"]:::logic
        B2["Global State Management"]:::logic
        B3["Services"]:::logic
    end

    %% Utilities Layer
    subgraph "Utilities Layer"
        C1["Vue Directives"]:::utils
        C2["Utility Functions"]:::utils
    end

    %% UI Interactions
    A1 -->|"renders via"| A2
    A1 -->|"uses"| A3
    A2 -->|"contains"| A6
    A2 -->|"triggers"| B1
    A3 -->|"updates"| B2
    A1 -->|"also shown in"| A4
    A1 -->|"also in"| A5
    A1 -->|"syncs state with"| B2

    %% Business Logic Interactions
    B1 -->|"updates"| B2
    B3 -->|"configures/exports for"| A1
    A3 -->|"calls"| B3

    %% Utilities Interactions
    C1 -->|"applied on"| A1
    C2 -->|"supports"| A2

    %% Click Events
    click A1 "https://github.com/pipipi-pikachu/pptist/blob/master/src/views/Editor/index.vue"
    click A2 "https://github.com/pipipi-pikachu/pptist/tree/master/src/views/Editor/Canvas"
    click A3 "https://github.com/pipipi-pikachu/pptist/tree/master/src/views/Editor/Toolbar"
    click A6 "https://github.com/pipipi-pikachu/pptist/tree/master/src/views/components/element"
    click A4 "https://github.com/pipipi-pikachu/pptist/tree/master/src/views/Mobile"
    click A5 "https://github.com/pipipi-pikachu/pptist/tree/master/src/views/Screen"
    click B2 "https://github.com/pipipi-pikachu/pptist/tree/master/src/store"
    click B1 "https://github.com/pipipi-pikachu/pptist/tree/master/src/hooks"
    click B3 "https://github.com/pipipi-pikachu/pptist/tree/master/src/services"
    click C1 "https://github.com/pipipi-pikachu/pptist/tree/master/src/plugins/directive"
    click C2 "https://github.com/pipipi-pikachu/pptist/tree/master/src/utils"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef logic fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef utils fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef ui_elem fill:#B0E0E6,stroke:#000,stroke-width:1px;
```
