# htmujahid/shadcn-editor architecture

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

- Interactive diagram: https://gitdiagram.com/htmujahid/shadcn-editor
- Repository: https://github.com/htmujahid/shadcn-editor

## Overview

##### Main Components Structure

Frontend Application Layer:
- Next.js Application Structure
- App Router (app/ directory)
- Registry System (__registry__/ and registry/)
- Component Library (components/)
- UI Components (ui/)

Core Editor Layer:
- Editor Core
- Context Management
- Hooks
- Plugins System
- Node System
- Transformers
- UI Components

Theme System:
- Default Theme
- New York Theme
- Style Registry

##### Key Relationships to Highlight

**┌─────────────────────────────────────────────────────┐**
- Application Layer                   │
- ┤
- ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
- Routes    │ │  Components  │ │     Hooks     │ │
- ┘ └──────────────┘ └───────────────┘ │
- ┬─────────────────────────────┘

**┌───────────────────────▼─────────────────────────────┐**
- Editor Core                       │
- ┤
- ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
- Plugins   │ │    Nodes     │ │  Transformers │ │
- ┘ └──────────────┘ └───────────────┘ │
- ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
- Context    │ │    Hooks     │ │     Utils     │ │
- ┘ └──────────────┘ └───────────────┘ │
- ┬─────────────────────────────┘

**┌───────────────────────▼─────────────────────────────┐**
- Theme System                       │
- ┤
- ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ │
- Default   │ │   New York   │ │    Styles     │ │
- ┘ └──────────────┘ └───────────────┘ │
- ┘

##### Important Elements

- User Input → Editor Core
- Editor Core → State Management
- State → Rendering Pipeline
- Theme System → UI Components

Integration Points:
- Plugin System connections
- Theme switching mechanism
- Registry system interaction

##### Additional Details

Component Relationships:
**Editor Core**
- Plugins System
- Text Formatting
- Block Formatting
- History
- Custom Plugins
- Node System
- Basic Nodes
- Custom Nodes
- Embeds
- Transformers
- Markdown
- HTML
- Custom Formats

##### Implementation Notes
- Use different line styles for different types of relationships
- Version information and dependencies
- Configuration flow
- Extensibility points

##### Key Interactions
- How the editor integrates with the Next.js application
- Plugin loading and initialization
- Demonstrate theme switching mechanism
- State management flow

- Nested components
- Custom styling
- Clear typography
- Export in high resolution

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph AppLayer["Frontend Application Layer"]
        Router["App Router"]
        Registry["Registry System"]
        CompLib["Component Library"]
        UIComp["UI Components"]
    end

    subgraph EditorCore["Editor Core Layer"]
        Context["Context Management"]
        EditorHooks["Hooks"]
        Plugins["Plugins System"]
        Nodes["Node System"]
        Trans["Transformers"]
        EditorUI["Editor UI Components"]
        MainEditor["Main Editor"]
        CoreNodes["Core Nodes"]
        CorePlugins["Core Plugins"]
    end

    subgraph ThemeSystem["Theme System"]
        DefaultTheme["Default Theme"]
        NYTheme["New York Theme"]
        ThemeComp["Theme Components"]
        ThemeConfig["Theme Configuration"]
    end

    subgraph Utils["Utilities and Documentation"]
        SharedUtils["Shared Utils"]
        GenUtils["General Utils"]
        CommonHooks["Common Hooks"]
        PluginDocs["Plugin Documentation"]
        MainDocs["Main Documentation"]
    end

    %% Relationships
    Router --> MainEditor
    Registry --> ThemeSystem
    CompLib --> EditorCore
    UIComp --> EditorUI

    Context --> MainEditor
    EditorHooks --> MainEditor
    Plugins --> CorePlugins
    Nodes --> CoreNodes
    Trans --> MainEditor
    EditorUI --> MainEditor

    DefaultTheme --> ThemeConfig
    NYTheme --> ThemeConfig
    ThemeComp --> ThemeConfig

    SharedUtils --> EditorCore
    GenUtils --> AppLayer
    CommonHooks --> EditorCore
    PluginDocs --> Plugins
    MainDocs --> AppLayer

    %% Click Events
    click Router "https://github.com/htmujahid/shadcn-editor/tree/main/app/"
    click Registry "https://github.com/htmujahid/shadcn-editor/tree/main/registry/"
    click CompLib "https://github.com/htmujahid/shadcn-editor/tree/main/components/"
    click UIComp "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/ui/"
    click Context "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/context/"
    click EditorHooks "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/editor-hooks/"
    click Plugins "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/plugins/"
    click Nodes "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/nodes/"
    click Trans "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/transformers/"
    click EditorUI "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/editor-ui/"
    click MainEditor "https://github.com/htmujahid/shadcn-editor/blob/main/components/blocks/editor/editor.tsx"
    click CoreNodes "https://github.com/htmujahid/shadcn-editor/blob/main/components/blocks/editor/nodes.ts"
    click CorePlugins "https://github.com/htmujahid/shadcn-editor/blob/main/components/blocks/editor/plugins.tsx"
    click DefaultTheme "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/"
    click NYTheme "https://github.com/htmujahid/shadcn-editor/tree/main/registry/new-york/"
    click ThemeComp "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/themes/"
    click ThemeConfig "https://github.com/htmujahid/shadcn-editor/blob/main/registry/registry-themes.ts"
    click PluginDocs "https://github.com/htmujahid/shadcn-editor/tree/main/content/docs/plugins/"
    click MainDocs "https://github.com/htmujahid/shadcn-editor/tree/main/content/docs/"
    click SharedUtils "https://github.com/htmujahid/shadcn-editor/tree/main/registry/default/editor/shared/"
    click GenUtils "https://github.com/htmujahid/shadcn-editor/tree/main/lib/"
    click CommonHooks "https://github.com/htmujahid/shadcn-editor/tree/main/hooks/"

    %% Styling
    classDef app fill:#2563eb,color:white
    classDef core fill:#16a34a,color:white
    classDef theme fill:#ea580c,color:white
    classDef util fill:#64748b,color:white

    class Router,Registry,CompLib,UIComp app
    class Context,EditorHooks,Plugins,Nodes,Trans,EditorUI,MainEditor,CoreNodes,CorePlugins core
    class DefaultTheme,NYTheme,ThemeComp,ThemeConfig theme
    class SharedUtils,GenUtils,CommonHooks,PluginDocs,MainDocs util
```
