# hiennd02/excalidraw architecture

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

- Interactive diagram: https://gitdiagram.com/hiennd02/excalidraw
- Repository: https://github.com/hiennd02/excalidraw

## Overview

The Excalidraw repository is a large, monorepo-style project focused on a collaborative, hand-drawn style whiteboard editor that is both an embeddable npm package and a full-blown web application. It also includes a host of supporting packages (such as math and utils), documentation, examples, tests, CI/CD configurations, and deployment resources.

##### Main Components
- Excalidraw Editor (NPM Package): This is the core library found under “packages/excalidraw.” It includes its own modular structure (e.g., scene, element, data, hooks, renderer) that implements the drawing engine, state management, and UI components.
- Excalidraw App: Located under “excalidraw-app,” this is the actual web application that uses the editor package to render the interactive whiteboard, manage collaboration features (such as real-time sharing, local autosave, and end-to-end encryption), and handle frontend routing (PWA support, offline support).
- Documentation & Developer Tools: The “dev-docs” folder (alongside examples in “examples”) provides developer guides and integration samples, acting as both documentation and a demo of how to use the system.
- External Integrations and Deployment: The repository also features integrations with Firebase (via the “firebase-project” folder), Docker configurations, and various GitHub workflows for CI/CD. Other external services such as Sentry, Vercel, and Crowdin are referenced in the README and workflow files.

##### Relationships and Interactions
- The Excalidraw App consumes the Editor package (npm module) to render the whiteboard UI.
- The Editor, in turn, is composed of multiple modules (e.g., rendering layer, scene management, element manipulation, event handling, state management) that interact with each other.
- Supporting packages (math and utils) are used by the Editor modules to provide advanced functionality (e.g., robust geometric calculations, collision detection).
- The app layer handles additional features (like real-time collaboration, local persistence, shareable links) and integrates with external services (Firebase, Sentry, etc.) through dedicated modules (e.g., data/firebase.ts).
- CI/CD pipelines (Docker, GitHub workflows) ensure that every change is built, linted, tested, and deployed automatically.

##### Architectural Patterns and Design Principles
- Modular Monorepo Architecture: The repository is organized as a monorepo with clear separation between the core library (editor), the application, supporting utilities, and documentation.
- Component-Based UI: The use of React components for the editor and app, along with a well-factored component structure (as seen in “excalidraw-app/components” and “packages/excalidraw/components”), suggests a clear separation of concerns.
- Extensibility and Plugin Support: The README emphasizes that additional features (collaboration, plugins, etc.) can be added as drop-in extensions, indicating an extensible design.
- Integration with Modern Tooling: The repository includes configurations for Docker, ESLint, Prettier, and CI workflows, meaning that the deployment pipeline and development infrastructure are also essential components of the system’s architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Application Layer
    subgraph "Frontend Application Layer"
        A1["Excalidraw App (Web Application)"]:::app
    end

    %% Core Library Layer
    subgraph "Core Library"
        E1["Excalidraw Editor"]:::editor
        E2["Scene Management"]:::module
        E3["Element Manipulation"]:::module
        E4["State Management"]:::module
        E5["Renderer"]:::module
        E6["Hooks & Events"]:::module
    end

    %% Supporting Packages Layer
    subgraph "Supporting Packages"
        M["Math Package"]:::support
        U["Utils Package"]:::support
    end

    %% Documentation & Developer Tools
    subgraph "Documentation & Developer Tools"
        D["Developer Docs"]:::doc
        X["Examples"]:::doc
    end

    %% CI/CD & Deployment Configurations
    subgraph "CI/CD & Deployment Configurations"
        CI["GitHub Workflows"]:::ci
        Docker["Docker & Configs"]:::ci
    end

    %% External Integrations
    subgraph "External Integrations"
        F["Firebase"]:::external
        S["Sentry"]:::external
        V["Vercel"]:::external
        C["Crowdin"]:::external
    end

    %% Relationships
    A1 -->|"consumes"| E1

    E1 -->|"contains"| E2
    E1 -->|"contains"| E3
    E1 -->|"contains"| E4
    E1 -->|"contains"| E5
    E1 -->|"contains"| E6

    E1 -->|"utilizes"| M
    E1 -->|"utilizes"| U

    A1 -->|"integrates_with"| F
    A1 -->|"integrates_with"| S
    A1 -->|"integrates_with"| V
    A1 -->|"integrates_with"| C

    CI -->|"builds_deploys"| A1
    CI -->|"builds_deploys"| E1
    Docker -->|"containerizes"| A1
    Docker -->|"containerizes"| E1

    D -->|"guides"| A1
    D -->|"guides"| E1
    X -->|"demonstrates_usage"| A1

    %% Click Events
    click A1 "https://github.com/hiennd02/excalidraw/tree/master/excalidraw-app"
    click E1 "https://github.com/hiennd02/excalidraw/tree/master/packages/excalidraw"
    click M "https://github.com/hiennd02/excalidraw/tree/master/packages/math"
    click U "https://github.com/hiennd02/excalidraw/tree/master/packages/utils"
    click D "https://github.com/hiennd02/excalidraw/tree/master/dev-docs"
    click X "https://github.com/hiennd02/excalidraw/tree/master/examples"
    click CI "https://github.com/hiennd02/excalidraw/tree/master/.github/workflows"
    click Docker "https://github.com/hiennd02/excalidraw/tree/master/Dockerfile"

    %% Styles
    classDef app fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef editor fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef module fill:#a0c4ff,stroke:#333,stroke-width:2px;
    classDef support fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef doc fill:#d4a373,stroke:#333,stroke-width:2px;
    classDef ci fill:#277da1,stroke:#333,stroke-width:2px;
    classDef external fill:#bc6c25,stroke:#333,stroke-width:2px;
```
