# figureland/kit architecture

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

- Interactive diagram: https://gitdiagram.com/figureland/kit
- Repository: https://github.com/figureland/kit

## Overview

##### High-Level Architecture

**┌─────────────────────── @figureland/kit ───────────────────────┐**

- ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌───────┐  │
- Math   │ │  State  │ │ Infinity │ │ Browser │ │ Tools │  │
- ┘ └─────────┘ └──────────┘ └─────────┘ └───────┘  │

- ┘

##### Module Details

a. Math Module:
**┌─────────── Math Module ───────────┐**

- Vector (2D/3D/4D)              │
- Matrix2D                        │
- Geometry                        │
- Bezier Curves                   │
- ┘

b. State Module:
**┌─────────── State Module ──────────┐**

- ┌─────────┐    ┌──────────────┐  │
- Manager │←───│ Subscriptions│  │
- ┘    └──────────────┘  │

- ┌─────────┐    ┌──────────────┐  │
- History │    │ Framework     │  │
- ┘    │ Integrations  │  │
- ┘  │
- ┘

c. Infinity Module:
**┌────────── Infinity Module ────────┐**

- ┌─────────┐    ┌──────────────┐  │
- Canvas  │←───│    Tools     │  │
- ┘    └──────────────┘  │

- ┌─────────┐    ┌──────────────┐  │
- Query   │    │ Interaction  │  │
- API   │    │   Adapter    │  │
- ┘    └──────────────┘  │
- ┘

##### Cross-Module Interactions
- Math module is used by Infinity for calculations
- State management can be used across all modules
- Browser module provides platform-specific implementations

##### Important Notes
- Framework integration points (React, Vue, Svelte)
- No-build-step distribution model
- Test coverage for each module

##### The focus on creative programming utilities
3. The clean separation of concerns between mathematical operations, state management, and UI interactions
##### The modern TypeScript-first architecture

Remember to maintain a balance between showing the technical architecture while emphasizing the creative programming aspects that make this toolkit unique in its approach to providing tools for both prototyping and production use cases.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Kit["@figureland/kit"]
        subgraph Math["Math Module"]
            Vector["Vector (2D/3D/4D)"]:::math
            Matrix["Matrix2D"]:::math
            Bezier["Bezier Curves"]:::math
            Box["Box/Size Calculations"]:::math
        end

        subgraph State["State Module"]
            Manager["State Manager"]:::state
            Subscriptions["Subscriptions"]:::state
            History["History"]:::state
            Frameworks["Framework Integrations"]:::state
        end

        subgraph Infinity["Infinity Module"]
            Canvas["Canvas"]:::infinity
            Tools["Tools"]:::infinity
            QueryAPI["Query API"]:::infinity
            InteractionAdapter["Interaction Adapter"]:::infinity
        end

        subgraph Browser["Browser Module"]
            Device["Device Handling"]:::browser
            DOMEvents["DOM Events"]:::browser
            Pointer["Pointer Interactions"]:::browser
            Media["Media Handling"]:::browser
            Clipboard["Clipboard"]:::browser
            Screen["Screen Management"]:::browser
        end

        subgraph Tools["Tools Module"]
            ArrayUtils["Array Utilities"]:::tools
            AsyncUtils["Async Utilities"]:::tools
            ObjectUtils["Object Utilities"]:::tools
            TimeUtils["Time Utilities"]:::tools
            TypeGuards["Type Guards"]:::tools
        end
    end

    %% Relationships
    Math --> Infinity
    State --> Infinity
    State --> Browser
    Browser --> Infinity
    Tools --> State
    Tools --> Infinity
    Tools --> Browser

    %% Click Events
    click Vector "https://github.com/figureland/kit/blob/main/src/math/vector2.ts"
    click Matrix "https://github.com/figureland/kit/blob/main/src/math/matrix2D.ts"
    click Bezier "https://github.com/figureland/kit/blob/main/src/math/cubicBezier2D.ts"
    click Box "https://github.com/figureland/kit/blob/main/src/math/box.ts"
    click Manager "https://github.com/figureland/kit/blob/main/src/state/manager.ts"
    click Subscriptions "https://github.com/figureland/kit/blob/main/src/state/subscriptions.ts"
    click History "https://github.com/figureland/kit/blob/main/src/state/history.ts"
    click Frameworks "https://github.com/figureland/kit/tree/main/src/state/frameworks"
    click Canvas "https://github.com/figureland/kit/blob/main/src/infinity/Canvas.ts"
    click Tools "https://github.com/figureland/kit/tree/main/src/infinity/tools"
    click QueryAPI "https://github.com/figureland/kit/blob/main/src/infinity/query/QueryAPI.ts"
    click InteractionAdapter "https://github.com/figureland/kit/blob/main/src/infinity/InteractionAdapter.ts"
    click Device "https://github.com/figureland/kit/blob/main/src/browser/device.ts"
    click DOMEvents "https://github.com/figureland/kit/blob/main/src/browser/dom-events.ts"
    click Pointer "https://github.com/figureland/kit/blob/main/src/browser/pointer.ts"
    click Media "https://github.com/figureland/kit/blob/main/src/browser/media.ts"
    click Clipboard "https://github.com/figureland/kit/blob/main/src/browser/clipboard.ts"
    click Screen "https://github.com/figureland/kit/blob/main/src/browser/screen.ts"
    click ArrayUtils "https://github.com/figureland/kit/blob/main/src/tools/array.ts"
    click AsyncUtils "https://github.com/figureland/kit/blob/main/src/tools/async.ts"
    click ObjectUtils "https://github.com/figureland/kit/blob/main/src/tools/object.ts"
    click TimeUtils "https://github.com/figureland/kit/blob/main/src/tools/time.ts"
    click TypeGuards "https://github.com/figureland/kit/blob/main/src/tools/guards.ts"

    %% Styles
    classDef math fill:#3498db,stroke:#2980b9,color:white
    classDef state fill:#2ecc71,stroke:#27ae60,color:white
    classDef infinity fill:#e67e22,stroke:#d35400,color:white
    classDef browser fill:#9b59b6,stroke:#8e44ad,color:white
    classDef tools fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        Math_L["Math"]:::math
        State_L["State"]:::state
        Infinity_L["Infinity"]:::infinity
        Browser_L["Browser"]:::browser
        Tools_L["Tools"]:::tools
    end
```
