# visshon/morphiccanvas architecture

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

- Interactive diagram: https://gitdiagram.com/visshon/morphiccanvas
- Repository: https://github.com/visshon/morphiccanvas

## Overview

##### Main Components Identification

The system should be represented with these primary components:

A. Frontend Layer (Client-Side)
- Next.js Application Container
- Canvas System (FabricJS Integration)
- Search & Filter System
- Context Management
- User Interface Components

##### Architectural Pattern Representation

**┌─ Next.js Application ──────────────────────────┐**

- ┌─ Context Layer ─────────────────────────┐  │
- CanvasContext                        │  │
- FilterContext                        │  │
- ┘  │

- ┌─ Component Layer ──────────────────────┐  │
- ┌─ Core Components ─┐ ┌─ UI Layer ──┐ │  │
- FabricCanvas   │ │ - TextMenu  │ │  │
- GlobalSearch   │ │ - SearchUI  │ │  │
- ┘ └────────────┘  │  │
- ┘  │

- ┌─ Utility Layer ────────────────────────┐  │
- Custom Hooks                        │  │
- Library Functions                   │  │
- ┘  │
- ┘

##### Specific Implementation Details

a. Canvas System:
- FabricCanvas component integration with fabric.js
- Mouse interaction handling through useMouse hook
- Canvas state management via CanvasContext

b. Search System:
- GlobalSearch component architecture
- SearchDialog component hierarchy
- Filter management through FilterContext

c. Shortcut System:
- useShortcut hook integration
- Command handling flow
- Integration with canvas and search features

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph NextApp["Next.js Application"]
        direction TB
        subgraph ContextLayer["Context Layer"]
            direction TB
            CC[CanvasContext]:::context
            FC[FilterContext]:::context
        end

        subgraph ComponentLayer["Component Layer"]
            direction TB
            subgraph CoreComponents["Core Components"]
                direction TB
                FCanvas[FabricCanvas]:::canvas
                GSearch[GlobalSearch]:::search
            end

            subgraph UILayer["UI Layer"]
                direction TB
                TMenu[TextMenu]:::ui
                SDialog[SearchDialog]:::search
                VPanel[VerticalPanel]:::ui
                ActionBar[ActionBar]:::ui
                PButton[PrimaryButton]:::ui
                Backdrop[Backdrop]:::ui
                CheckBox[CheckBox]:::ui
                Radio[RadioButton]:::ui
            end
        end

        subgraph UtilityLayer["Utility Layer"]
            direction TB
            Mouse[useMouse]:::util
            Shortcut[useShortcut]:::util
            FabricLib[FabricJS Lib]:::util
            NameCard[NameCard Util]:::util
            Members[Members Util]:::util
            Filters[Filters Constants]:::util
        end

        App[_app.tsx]:::core
        Index[index.tsx]:::core
    end

    %% Relationships
    App --> Index
    Index --> FCanvas
    Index --> GSearch
    
    CC --> FCanvas
    FC --> GSearch
    FC --> SDialog
    
    FCanvas --> FabricLib
    FCanvas --> Mouse
    
    GSearch --> SDialog
    SDialog --> ActionBar
    SDialog --> PButton
    SDialog --> Backdrop
    SDialog --> CheckBox
    SDialog --> Radio
    
    Shortcut --> FCanvas
    Shortcut --> GSearch
    
    FabricLib --> NameCard
    FabricLib --> Members
    
    GSearch --> Filters

    %% Click Events
    click App "https://github.com/VisShon/MorphicCanvas/blob/main/pages/_app.tsx"
    click Index "https://github.com/VisShon/MorphicCanvas/blob/main/pages/index.tsx"
    click FCanvas "https://github.com/VisShon/MorphicCanvas/blob/main/components/FabricCanvas.tsx"
    click FabricLib "https://github.com/VisShon/MorphicCanvas/blob/main/lib/fabric.ts"
    click Mouse "https://github.com/VisShon/MorphicCanvas/blob/main/hooks/useMouse.ts"
    click GSearch "https://github.com/VisShon/MorphicCanvas/blob/main/components/GlobalSearch.tsx"
    click SDialog "https://github.com/VisShon/MorphicCanvas/blob/main/components/SearchDialog/index.tsx"
    click Filters "https://github.com/VisShon/MorphicCanvas/blob/main/constants/filters.ts"
    click CC "https://github.com/VisShon/MorphicCanvas/blob/main/context/CanvasContext.tsx"
    click FC "https://github.com/VisShon/MorphicCanvas/blob/main/context/FilterContext.tsx"
    click TMenu "https://github.com/VisShon/MorphicCanvas/blob/main/components/TextMenu.tsx"
    click VPanel "https://github.com/VisShon/MorphicCanvas/blob/main/components/VerticalPanel.tsx"
    click ActionBar "https://github.com/VisShon/MorphicCanvas/blob/main/components/SearchDialog/others/ActionBar.tsx"
    click PButton "https://github.com/VisShon/MorphicCanvas/blob/main/components/SearchDialog/others/PrimaryButton.tsx"
    click Shortcut "https://github.com/VisShon/MorphicCanvas/blob/main/hooks/useShortcut.ts"
    click NameCard "https://github.com/VisShon/MorphicCanvas/blob/main/lib/namecard.ts"
    click Members "https://github.com/VisShon/MorphicCanvas/blob/main/lib/members.ts"
    click Backdrop "https://github.com/VisShon/MorphicCanvas/blob/main/components/SearchDialog/others/Backdrop.tsx"
    click CheckBox "https://github.com/VisShon/MorphicCanvas/blob/main/components/SearchDialog/others/CheckBox.tsx"
    click Radio "https://github.com/VisShon/MorphicCanvas/blob/main/components/SearchDialog/others/RadioButton.tsx"

    %% Styles
    classDef core fill:#2196F3,color:white
    classDef canvas fill:#4CAF50,color:white
    classDef search fill:#FF9800,color:white
    classDef context fill:#9C27B0,color:white
    classDef ui fill:#607D8B,color:white
    classDef util fill:#795548,color:white

    %% Legend
    subgraph Legend
        L1[Next.js Core]:::core
        L2[Canvas Components]:::canvas
        L3[Search Components]:::search
        L4[Context Providers]:::context
        L5[UI Components]:::ui
        L6[Utilities]:::util
    end
```
