# chunrapeepat/inscribed architecture

> Architecture diagram of the GitHub repository chunrapeepat/inscribed, 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/chunrapeepat/inscribed
- Repository: https://github.com/chunrapeepat/inscribed

## Overview

##### Main Components
a. User Interface Layer:
- Entry Point & App Shell: Highlight index.html, src/main.tsx, and src/App.tsx as the bootstrap and main container for the whole UI.
- Components: Illustrate various UI components (Canvas, Toolbar, SlideList, SlidePreview, presentation modals, embed components, etc.). Consider grouping them by functionality (e.g., primary slide editor components like Canvas and Toolbar, modals for custom fonts, document settings, export options, and preview/presentation mode).
- Pages/Routes: Represent distinct app views defined in src/pages (the Inscribed Editor, Embed view, etc.).

b. State Management & Data Handling:
- Store: The src/store directory shows the use of centralized state (for document settings, modals, library, etc.). Indicate how state modules like custom-fonts, document, library, and modal interact with UI components.

c. External Integrations & Exports:
- Excalidraw Integration: Since the tool uses Excalidraw for an interactive canvas, show it as an external dependency interfacing with the Canvas component and related utilities (src/utils/excalidraw.ts).
- Google Fonts: Highlight this integration (supported in components like CustomFontsModal and documented in docs/custom-fonts.md).
- Export and Sharing: Include modules supporting GIF export (src/utils/export.ts), embed support (iframe integration documented), and data import/export functionality.
- Presentation Mode & Embedding: Components and pages that allow presentation mode and embed support should be visualized as parts of the UI that provide different interaction paradigms.

d. Configuration & Deployment:
- Configuration Files: Display files such as vite.config.ts, package.json, tailwind.config.js, and firebase.json to indicate build settings, styling configurations, and potential deployment platforms (Firebase indicated).
- Documentation: The docs folder and README provide additional context, which can be noted as metadata for understanding feature behavior (e.g., export options, custom fonts, etc.).

##### Relationships & Interactions
– From the User interacting with the UI (through pages and components) to state management modules (src/store).
– From UI components to utility modules (data processing, exporting).
– Between the canvas component (powered by Excalidraw) and modals or tools that manipulate slide content.
- How presentation mode and embed functionality branch off from the core editing experience. For example, a component like PresentationMode.tsx should be connected both to the UI layer and the export/embed functionalities.

##### Architectural Patterns & Design Principles
- Modular Component-Based Design: The clear separation of UI (in src/components/ and src/pages) and logic (src/store and src/utils) suggests a component-first, modular architecture.
- Centralized State Management: Using a store organized by domain (document, custom fonts, modals) points to a state-management pattern, possibly with something similar to Redux patterns, even if implemented using React’s Context or other state libraries.
- Separation of Concerns: UI presentation, business logic (state management, export logic), and external integrations (Excalidraw, Google Fonts) are distinctly separated.
- Client-Side Rendered SPA: With Vite, TypeScript, and React, the entire architecture is centered on client-side rendering with support for hot module replacement (HMR) and efficient bundling.

##### Additional Notes
- Although the project is relatively front-end centric, mention any hosting or deployment insights drawn from configuration files (firebase.json hints at possible Firebase hosting).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User("User"):::external

    %% User Interface Layer
    subgraph "User Interface Layer"
        MainAppShell("Main Application Shell"):::ui
        Canvas("Interactive Canvas"):::ui
        Toolbar("Toolbar & UI Controls"):::ui
        
        subgraph "Slide Management"
            SlideList("Slide List"):::ui
            SlidePreview("Slide Preview"):::ui
        end

        subgraph "Modals & Dialogs"
            CustomFontsModal("Custom Fonts Modal"):::ui
            DocumentSettingsModal("Document Settings Modal"):::ui
            ExportModal("Export Modal"):::ui
        end

        subgraph "Pages & Routes"
            InscribedEditor("Inscribed Editor Page"):::ui
            EmbedPage("Embed Page"):::ui
        end

        subgraph "Presentation & Embedding"
            PresentationMode("Presentation Mode"):::ui
            EmbedComponents("Embed Components"):::ui
        end
    end

    %% State Management & Data Handling
    subgraph "State Management & Data Handling"
        Store("State Store"):::state
    end

    %% Utility Functions & Exports
    subgraph "Utility Functions & Exports"
        ExportUtil("Export Utilities"):::util
        FontUtil("Font Utilities"):::util
        GeneralHelpers("General Helpers"):::util
        Excalidraw("Excalidraw Integration"):::util
    end

    %% Configuration & Deployment
    subgraph "Configuration & Deployment"
        Config("Build & Deployment Config"):::config
        Documentation("Documentation"):::config
    end

    %% Data Flow Connections
    User --> MainAppShell

    MainAppShell --> Canvas
    MainAppShell --> Toolbar
    MainAppShell --> SlideList
    MainAppShell --> SlidePreview
    MainAppShell --> CustomFontsModal
    MainAppShell --> DocumentSettingsModal
    MainAppShell --> ExportModal
    MainAppShell --> InscribedEditor
    MainAppShell --> EmbedPage
    MainAppShell --> PresentationMode
    MainAppShell --> EmbedComponents

    Canvas -->|"uses"| Excalidraw
    Canvas -->|"updates"| Store
    Toolbar -->|"triggers"| ExportUtil
    Toolbar -->|"updates"| Store
    CustomFontsModal -->|"utilizes"| FontUtil
    ExportModal -->|"calls"| ExportUtil
    SlideList -->|"reads"| Store
    SlidePreview -->|"reads"| Store
    InscribedEditor <==>|"state sync"| Store
    EmbedPage -->|"state sync"| Store
    PresentationMode -->|"invokes"| ExportUtil
    EmbedComponents -->|"renders in"| EmbedPage

    %% Utilities supporting UI components
    GeneralHelpers --> Canvas
    GeneralHelpers --> Toolbar

    %% Configuration influences
    Config --> MainAppShell
    Documentation --> MainAppShell

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef state fill:#D5F5E3,stroke:#145A32,stroke-width:2px;
    classDef util fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef config fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#C0392B,stroke-width:2px;

    %% Click Events
    click MainAppShell "https://github.com/chunrapeepat/inscribed/blob/master/src/App.tsx"
    click Canvas "https://github.com/chunrapeepat/inscribed/blob/master/src/components/Canvas.tsx"
    click Toolbar "https://github.com/chunrapeepat/inscribed/blob/master/src/components/Toolbar.tsx"
    click SlideList "https://github.com/chunrapeepat/inscribed/blob/master/src/components/SlideList.tsx"
    click SlidePreview "https://github.com/chunrapeepat/inscribed/blob/master/src/components/SlidePreview.tsx"
    click CustomFontsModal "https://github.com/chunrapeepat/inscribed/blob/master/src/components/CustomFontsModal.tsx"
    click DocumentSettingsModal "https://github.com/chunrapeepat/inscribed/blob/master/src/components/DocumentSettingModal.tsx"
    click ExportModal "https://github.com/chunrapeepat/inscribed/blob/master/src/components/ExportModal.tsx"
    click PresentationMode "https://github.com/chunrapeepat/inscribed/blob/master/src/components/PresentationMode.tsx"
    click EmbedComponents "https://github.com/chunrapeepat/inscribed/tree/master/src/components/embed"
    click EmbedPage "https://github.com/chunrapeepat/inscribed/blob/master/src/pages/Embed.tsx"
    click InscribedEditor "https://github.com/chunrapeepat/inscribed/blob/master/src/pages/InscribedEditor.tsx"
    click Store "https://github.com/chunrapeepat/inscribed/tree/master/src/store"
    click ExportUtil "https://github.com/chunrapeepat/inscribed/blob/master/src/utils/export.ts"
    click FontUtil "https://github.com/chunrapeepat/inscribed/blob/master/src/utils/fonts.ts"
    click GeneralHelpers "https://github.com/chunrapeepat/inscribed/blob/master/src/utils/general.ts"
    click Excalidraw "https://github.com/chunrapeepat/inscribed/blob/master/src/utils/excalidraw.ts"
    click Config "https://github.com/chunrapeepat/inscribed/blob/master/vite.config.ts"
    click Documentation "https://github.com/chunrapeepat/inscribed/tree/master/docs"
```
