# ckeditor/ckeditor5 architecture

> Architecture diagram of the GitHub repository ckeditor/ckeditor5, 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/ckeditor/ckeditor5
- Repository: https://github.com/ckeditor/ckeditor5

## Overview

##### Core Architecture Components
- UI Layer (Blue) - Handles user interactions and view rendering
- Core Layer (Green) - Contains the MVC implementation and main editor logic
- Data Model Layer (Yellow) - Manages the editor's data model and state
- Engine Layer (Orange) - Handles DOM manipulation and virtual DOM

##### Main Components and Their Relationships
a. Editor Core (Center)
- ┌─────────────────────┐
- Editor Core     │
- ┌───────────────┐  │
- Data Pipeline │  │
- Command Stack │  │
- Plugin System │  │
- ┘  │
- ┘

b. Plugin System (Connected to Core)
- ┌─────────────────┐
- Plugin Manager  │←──── Feature Plugins
- Event System    │←──── UI Plugins
- Command System  │←──── Core Plugins
- ┘

##### Data Flow Architecture
- User Input → UI Layer → Commands → Data Model → Engine → DOM
- ↓
- Undo Manager

##### Integration Points
External connection points:
- ┌─────────────────┐    ┌──────────────┐
- Upload Adapter  │←───│ File System  │
- Data Processor │←───│ HTML/Markdown │
- Collaboration  │←───│ Real-time    │
- ┘    └──────────────┘

##### Key Subsystems
- Editor Types (Classic, Inline, Balloon, Decoupled)
- UI Components (Toolbar, Dropdown, Dialog)
- Core Features (Typing, Enter, Delete)
- Advanced Features (Tables, Images, Lists)

##### Cross-cutting Concerns
Horizontal layers for:
- ┌─────────────────────────────────┐
- Translation System              │
- Error Handling                  │
- Undo/Redo Management           │
- Selection & Focus Management    │
- ┘

##### Build System & Packaging
A section showing:
- ┌─────────────────┐
- DLL Builds      │
- NPM Packages    │
- Custom Builds   │
- ┘

##### Framework Integration
Compatibility with:
- ┌─────────────────┐
- Angular         │
- React           │
- Vue.js          │
- ┘

Important Elements to Highlight:

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,color:white
    classDef core fill:#2ecc71,color:white
    classDef model fill:#f1c40f,color:black
    classDef engine fill:#e67e22,color:white
    classDef feature fill:#95a5a6,color:white
    classDef integration fill:#1abc9c,color:white
    classDef build fill:#7f8c8d,color:white

    %% Core Architecture
    subgraph Architecture
        UI["UI Layer"]:::ui
        Core["Core Layer"]:::core
        Model["Data Model Layer"]:::model
        Engine["Engine Layer"]:::engine
    end

    %% Editor Core Components
    subgraph EditorCore
        PluginSystem["Plugin System"]:::core
        CommandSystem["Command System"]:::core
        DataPipeline["Data Pipeline"]:::core
    end

    %% Editor Types
    subgraph EditorTypes
        Classic["Classic Editor"]:::ui
        Inline["Inline Editor"]:::ui
        Balloon["Balloon Editor"]:::ui
        Decoupled["Decoupled Editor"]:::ui
    end

    %% UI Components
    subgraph UIComponents
        Toolbar["Toolbar"]:::ui
        Dialog["Dialog"]:::ui
        Panel["Panel"]:::ui
        Button["Button"]:::ui
    end

    %% Core Features
    subgraph CoreFeatures
        Typing["Typing"]:::feature
        Enter["Enter"]:::feature
        Undo["Undo"]:::feature
        Clipboard["Clipboard"]:::feature
    end

    %% Advanced Features
    subgraph AdvancedFeatures
        Table["Table"]:::feature
        Image["Image"]:::feature
        Link["Link"]:::feature
        List["List"]:::feature
    end

    %% Cross-cutting Concerns
    subgraph CrossCutting
        Translation["Translation System"]:::core
        ErrorHandling["Error Handling"]:::core
        UndoRedo["Undo/Redo Management"]:::core
        FocusManagement["Focus Management"]:::core
    end

    %% Relationships
    UI --> Core
    Core --> Model
    Model --> Engine
    
    PluginSystem --> Core
    CommandSystem --> Core
    DataPipeline --> Model

    Classic & Inline & Balloon & Decoupled --> UI
    Toolbar & Dialog & Panel & Button --> UI

    CoreFeatures --> Core
    AdvancedFeatures --> Core
    CrossCutting --> Core

    %% Click Events
    click UI "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-ui/"
    click Core "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-core/"
    click Model "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-engine/src/model/"
    click Engine "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-engine/"
    click PluginSystem "https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-core/src/plugin.ts"
    click CommandSystem "https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-core/src/command.ts"
    click DataPipeline "https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/controller/datacontroller.ts"
    click Classic "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-editor-classic/"
    click Inline "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-editor-inline/"
    click Balloon "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-editor-balloon/"
    click Decoupled "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-editor-decoupled/"
    click Typing "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-typing/"
    click Enter "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-enter/"
    click Undo "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-undo/"
    click Clipboard "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-clipboard/"
    click Table "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-table/"
    click Image "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-image/"
    click Link "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-link/"
    click List "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-list/"
    click Toolbar "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-ui/src/toolbar/"
    click Dialog "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-ui/src/dialog/"
    click Panel "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-ui/src/panel/"
    click Button "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-ui/src/button/"
    click Translation "https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/translation-service.ts"
    click ErrorHandling "https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/ckeditorerror.ts"
    click UndoRedo "https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-undo/"
    click FocusManagement "https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/focustracker.ts"
```
