# kaliedarik/scrawl-canvas architecture

> Architecture diagram of the GitHub repository kaliedarik/scrawl-canvas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaliedarik/scrawl-canvas
- Repository: https://github.com/kaliedarik/scrawl-canvas

## Overview

##### Main Components

a) Core System Components:
- Core Module System
- Animation Loop
- Cycle
- Event Handling
- User Interaction
- Library Management
- Snippets System

b) Factory System:
- Element Factories
- Animation Factories
- Pattern & Gradient Factories
- Particle System Factories

c) Asset Management System:
- Image Assets
- Video Assets
- Sprite Assets
- Noise Assets
- Raw Assets

d) Mixin System:
- Base Mixins
- Asset Mixins
- DOM Mixins
- Animation Mixins

**[User Application]**
- ↓
**[Scrawl-canvas API Layer]**
- ↓
**┌─────────────────────────────────────┐**
- Core System               │
- ┬──────────┬───────────┤
- Animation   │ Display  │  Event    │
- Loop      │  Cycle   │ Handling  │
- ┴──────────┴───────────┘
- ↓             ↓          ↓
**┌─────────────────────────────────────┐**
- Factory System              │
- ┬─────────────┬────────────┤
- Patterns │ Particles   │ Gradients  │
- ┴─────────────┴────────────┘
- ↓             ↓          ↓
**┌─────────────────────────────────────┐**
- Asset Management System        │
- ┬─────────────┬────────────┤
- Images  │   Videos    │  Sprites   │
- Noise   │    Raw      │           │
- ┴─────────────┴────────────┘
- ↓             ↓          ↓
**┌─────────────────────────────────────┐**
- Mixin System               │
- ┬─────────────┬────────────┤
- DOM    │ Animation   │            │
- ┴─────────────┴────────────┘
- ↓             ↓          ↓
**[HTML5 Canvas Element]**

##### Additional Elements
- Documentation generation flow
- TypeScript support indication
- Testing and Demo system relationship

##### Important Notes
- Modular nature of the system
- Accessibility and responsiveness features
- Event handling and user interaction flows
- Relationship with the DOM and canvas API

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Layer"
        UA[User Application]
    end

    subgraph "API Layer"
        API[Scrawl-canvas API]
    end

    subgraph "Core System"
        AL["Animation Loop"]:::core
        DC["Display Cycle"]:::core
        EH["Event Handling"]:::core
        UI["User Interaction"]:::core
        LM["Library Management"]:::core
        SS["Snippets System"]:::core
    end

    subgraph "Factory System"
        EF["Element Factory"]:::factory
        SF["Shape Factory"]:::factory
        AF["Animation Factory"]:::factory
        PF["Pattern Factory"]:::factory
        GF["Gradient Factory"]:::factory
        PS["Particle System"]:::factory
    end

    subgraph "Asset Management"
        IA["Image Assets"]:::asset
        VA["Video Assets"]:::asset
        SA["Sprite Assets"]:::asset
        NA["Noise Assets"]:::asset
        RA["Raw Assets"]:::asset
    end

    subgraph "Mixin System"
        BM["Base Mixin"]:::mixin
        SM["Shape Mixins"]:::mixin
        AM["Asset Mixins"]:::mixin
        DM["DOM Mixins"]:::mixin
        TM["Animation Mixins"]:::mixin
    end

    subgraph "Canvas Layer"
        CE[HTML5 Canvas Element]
    end

    %% Relationships
    UA --> API
    API --> AL & DC & EH
    AL --> EF & AF
    DC --> SF & PF & GF
    EH --> UI
    UI --> LM
    LM --> SS
    
    EF & SF & AF & PF & GF & PS --> IA & VA & SA & NA & RA
    
    IA & VA & SA & NA & RA --> BM & SM & AM & DM & TM
    
    BM & SM & AM & DM & TM --> CE

    %% Styles
    classDef core fill:#a8d1f0
    classDef factory fill:#90EE90
    classDef asset fill:#FFB347
    classDef mixin fill:#DDA0DD

    %% Click events
    click AL "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/core/animation-loop.js"
    click DC "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/core/display-cycle.js"
    click EH "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/core/events.js"
    click UI "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/core/user-interaction.js"
    click LM "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/core/library.js"
    click SS "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/core/snippets.js"
    
    click EF "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/factory/element.js"
    click SF "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/factory/shape.js"
    click AF "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/factory/animation.js"
    click PF "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/factory/pattern.js"
    click GF "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/factory/gradient.js"
    click PS "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/factory/particle-world.js"
    
    click IA "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/asset-management/image-asset.js"
    click VA "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/asset-management/video-asset.js"
    click SA "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/asset-management/sprite-asset.js"
    click NA "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/asset-management/noise-asset.js"
    click RA "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/asset-management/raw-asset.js"
    
    click BM "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/mixin/base.js"
    click SM "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/mixin/shape-basic.js"
    click AM "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/mixin/asset.js"
    click DM "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/mixin/dom.js"
    click TM "https://github.com/KaliedaRik/Scrawl-canvas/blob/v8/source/mixin/tween.js"
```
