# getfrontend/next-figma-clone architecture

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

- Interactive diagram: https://gitdiagram.com/getfrontend/next-figma-clone
- Repository: https://github.com/getfrontend/next-figma-clone

## Overview

##### Main System Components

a. Client Layer (Frontend)
- Next.js Application Container
- Canvas System (Fabric.js)
- Real-time Collaboration Layer (Liveblocks)
- UI Components Layer

b. External Services Layer
- Liveblocks Service
- Asset Storage (for uploaded images)

##### Component Breakdown

Create distinct sections for the following component groups:
a. Core Components:
- Canvas (Main workspace)
- Room Management
- Collaboration Features

b. UI Components:
- Navigation System
- Sidebars (Left/Right)
- Settings Panels

##### Data Flow Visualization

- Real-time updates between clients via Liveblocks
- User interactions with the canvas
- State management flow
- Asset upload/download paths

**[Client Browser]**

- [Next.js App Container]

- [Layout Layer]
- Navbar
- LeftSidebar (Tools)
- RightSidebar (Properties)

- [Canvas System]
- Fabric.js Instance
- Drawing Tools

- [Collaboration System]
- Live Cursors
- Cursor Chat
- Comments
- Reactions

- [State Management]
- Canvas State
- User State
- Collaboration State

- [External Services]
- Liveblocks
- Asset Storage

Important Elements to Include:

##### Connection Types
- Double lines: Real-time data flow

##### Component Relationships
How these key features interact:
- Cursor system with chat overlay
- Comments system with canvas elements
- Real-time state synchronization
- User presence and activity tracking

##### State Flow
How state changes propagate:
- User actions → Canvas updates
- Collaboration events → UI updates
- Tool selection → Canvas mode changes

Remember to:
- Keep the main components clearly visible at a glance
- Use consistent iconography for similar components
- Annotations for complex interactions
- Scalability aspects of the system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Browser"]
        NextApp["Next.js App Container"]
        click NextApp "https://github.com/getFrontend/next-figma-clone/blob/main/app/App.tsx"

        subgraph Layout["Layout Layer"]
            Nav["Navigation System"]
            click Nav "https://github.com/getFrontend/next-figma-clone/blob/main/components/Navbar.tsx"
            LSidebar["Left Sidebar"]
            click LSidebar "https://github.com/getFrontend/next-figma-clone/blob/main/components/LeftSidebar.tsx"
            RSidebar["Right Sidebar"]
            click RSidebar "https://github.com/getFrontend/next-figma-clone/blob/main/components/RightSidebar.tsx"
        end

        subgraph CanvasSystem["Canvas System"]
            FabricInstance["Fabric.js Instance"]
            click FabricInstance "https://github.com/getFrontend/next-figma-clone/blob/main/lib/canvas.ts"
            ShapeMgmt["Shape Management"]
            click ShapeMgmt "https://github.com/getFrontend/next-figma-clone/blob/main/lib/shapes.ts"
            DrawTools["Drawing Tools"]
            click DrawTools "https://github.com/getFrontend/next-figma-clone/blob/main/components/ShapesMenu.tsx"
        end

        subgraph CollabSystem["Collaboration System"]
            LiveCursors["Live Cursors"]
            click LiveCursors "https://github.com/getFrontend/next-figma-clone/blob/main/components/cursor/LiveCursors.tsx"
            CursorChat["Cursor Chat"]
            click CursorChat "https://github.com/getFrontend/next-figma-clone/blob/main/components/cursor/CursorChat.tsx"
            Comments["Comments"]
            click Comments "https://github.com/getFrontend/next-figma-clone/blob/main/components/comments/Comments.tsx"
            Reactions["Reactions"]
            click Reactions "https://github.com/getFrontend/next-figma-clone/blob/main/components/reaction/ReactionButton.tsx"
        end

        subgraph StateMgmt["State Management"]
            CanvasState["Canvas State"]
            UserState["User State"]
            click UserState "https://github.com/getFrontend/next-figma-clone/blob/main/components/users/ActiveUsers.tsx"
            CollabState["Collaboration State"]
            click CollabState "https://github.com/getFrontend/next-figma-clone/blob/main/liveblocks.config.ts"
        end

        subgraph Settings["Settings Panels"]
            ColorSet["Color Settings"]
            click ColorSet "https://github.com/getFrontend/next-figma-clone/blob/main/components/settings/Color.tsx"
            DimSet["Dimension Settings"]
            click DimSet "https://github.com/getFrontend/next-figma-clone/blob/main/components/settings/Dimensions.tsx"
            ExportSet["Export Settings"]
            click ExportSet "https://github.com/getFrontend/next-figma-clone/blob/main/components/settings/Export.tsx"
            TextSet["Text Settings"]
            click TextSet "https://github.com/getFrontend/next-figma-clone/blob/main/components/settings/Text.tsx"
        end
    end

    subgraph External["External Services"]
        Liveblocks["Liveblocks Service"]
        AssetStorage["Asset Storage"]
    end

    %% Connections
    NextApp --> Layout
    NextApp --> CanvasSystem
    NextApp --> CollabSystem
    NextApp --> StateMgmt
    NextApp --> Settings

    CollabSystem --> Liveblocks
    CanvasSystem --> AssetStorage

    %% State Management Connections
    CanvasSystem --> CanvasState
    CollabSystem --> CollabState
    UserState --> CollabState

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef service fill:#ff9900,stroke:#333
    classDef core fill:#3498db,stroke:#333
    classDef collab fill:#2ecc71,stroke:#333
    classDef state fill:#9b59b6,stroke:#333
    classDef ui fill:#95a5a6,stroke:#333

    class External,Liveblocks,AssetStorage service
    class NextApp,CanvasSystem core
    class CollabSystem collab
    class StateMgmt state
    class Layout,Settings ui
```
