How hiennd02/excalidraw works
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.