# basecamp/lexxy architecture

> Architecture diagram of the GitHub repository basecamp/lexxy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/basecamp/lexxy
- Repository: https://github.com/basecamp/lexxy

## Overview

Lexxy is a Rails-integrated rich-text editor built on Lexical. Users edit formatted content in a custom editor, use toolbar, prompt, table, and attachment interactions, and produce HTML compatible with Action Text. The frontend also provides Markdown behavior, code highlighting, configurable prompts, attachment previews, and sanitization; the Rails engine connects it to Action Text and Active Storage. Several feature modules are represented from the tree and README, but their internal wiring is not shown, so those relationships are omitted.

Main entry points: [`src/elements/editor.js`](https://github.com/basecamp/lexxy/blob/main/src/elements/editor.js) (Editor element), [`src/index.js`](https://github.com/basecamp/lexxy/blob/main/src/index.js) (JS entry), [`lib/lexxy/engine.rb`](https://github.com/basecamp/lexxy/blob/main/lib/lexxy/engine.rb) (Rails engine), [`src/nodes/custom_action_text_attachment_node.js`](https://github.com/basecamp/lexxy/blob/main/src/nodes/custom_action_text_attachment_node.js) (Custom attachment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Editor runtime"]
  node_entry["JS entry<br/>[index.js]"]
  node_editor["Editor element<br/>[editor.js]"]
  node_config["Editor config<br/>[lexxy.js]"]
  node_selection["Selection<br/>[selection.js]"]
  node_sanitizer["Editor sanitizer<br/>[sanitizer.js]"]
  node_format["Format helpers<br/>[format_helper.js]"]
  node_html["HTML helpers<br/>[html_helper.js]"]
  node_lexical["Lexical helpers<br/>[lexical_helper.js]"]
end

subgraph group_interaction["Editing interactions"]
  node_toolbar["Toolbar<br/>[toolbar.js]"]
  node_heading["Heading dropdown<br/>[heading.js]"]
  node_prompt["Prompt UI<br/>[prompt.js]"]
  node_tabletools["Table tools<br/>[table_tools.js]"]
  node_tablecontroller["Table controller"]
  node_markdown["Markdown handler"]
  node_highlight["Code highlighting"]
end

subgraph group_attachments["Attachments"]
  node_attachment["Action Text attachment"]
  node_customattachment["Custom attachment"]
  node_dragdrop["Custom drag and drop<br/>[drag_and_drop.js]"]
end

subgraph group_rails["Rails integration"]
  node_railsengine["Rails engine<br/>[engine.rb]"]
  node_railseditor["Action Text editor adapter<br/>[lexxy_editor.rb]"]
  node_remotemedia["Remote video attachable<br/>[remote_video.rb]"]
  node_previewurl["Preview URL support"]
end

node_user(("Editor user"))

node_user -->|"edits content"| node_editor
node_entry -->|"configures"| node_config
node_entry -->|"exports"| node_sanitizer
node_entry -->|"exports"| node_highlight
node_entry -->|"registers elements"| node_editor
node_editor -->|"uses"| node_selection
node_editor -->|"uses"| node_toolbar
node_editor -->|"uses"| node_markdown
node_editor -->|"uses"| node_lexical
node_heading -->|"uses icons"| node_toolbar
node_tabletools -->|"uses"| node_tablecontroller
node_attachment -->|"creates markup"| node_html
node_customattachment -->|"sanitizes through"| node_sanitizer
node_dragdrop -->|"moves"| node_customattachment
node_railsengine -->|"registers adapter"| node_railseditor
node_railsengine -->|"loads attachable"| node_remotemedia
node_railsengine -->|"loads extension"| node_previewurl

click node_entry "https://github.com/basecamp/lexxy/blob/main/src/index.js"
click node_editor "https://github.com/basecamp/lexxy/blob/main/src/elements/editor.js"
click node_config "https://github.com/basecamp/lexxy/blob/main/src/config/lexxy.js"
click node_selection "https://github.com/basecamp/lexxy/blob/main/src/editor/selection.js"
click node_sanitizer "https://github.com/basecamp/lexxy/blob/main/src/editor/sanitizer.js"
click node_format "https://github.com/basecamp/lexxy/blob/main/src/helpers/format_helper.js"
click node_html "https://github.com/basecamp/lexxy/blob/main/src/helpers/html_helper.js"
click node_lexical "https://github.com/basecamp/lexxy/blob/main/src/helpers/lexical_helper.js"
click node_toolbar "https://github.com/basecamp/lexxy/blob/main/src/elements/toolbar.js"
click node_heading "https://github.com/basecamp/lexxy/blob/main/src/elements/dropdown/heading.js"
click node_prompt "https://github.com/basecamp/lexxy/blob/main/src/elements/prompt.js"
click node_tabletools "https://github.com/basecamp/lexxy/blob/main/src/elements/table/table_tools.js"
click node_tablecontroller "https://github.com/basecamp/lexxy/blob/main/src/elements/table/table_controller.js"
click node_markdown "https://github.com/basecamp/lexxy/blob/main/src/editor/markdown/leading_tag_handler.js"
click node_highlight "https://github.com/basecamp/lexxy/blob/main/src/helpers/code_highlighting_helper.js"
click node_attachment "https://github.com/basecamp/lexxy/blob/main/src/nodes/action_text_attachment_node.js"
click node_customattachment "https://github.com/basecamp/lexxy/blob/main/src/nodes/custom_action_text_attachment_node.js"
click node_dragdrop "https://github.com/basecamp/lexxy/blob/main/src/editor/attachments/custom/drag_and_drop.js"
click node_railsengine "https://github.com/basecamp/lexxy/blob/main/lib/lexxy/engine.rb"
click node_railseditor "https://github.com/basecamp/lexxy/blob/main/lib/action_text/editor/lexxy_editor.rb"
click node_remotemedia "https://github.com/basecamp/lexxy/blob/main/lib/action_text/attachables/remote_video.rb"
click node_previewurl "https://github.com/basecamp/lexxy/blob/main/lib/active_storage/blob_with_preview_url.rb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_editor,node_config,node_selection,node_sanitizer,node_format,node_html,node_lexical,node_user toneBlue
class node_toolbar,node_heading,node_prompt,node_tabletools,node_tablecontroller,node_markdown,node_highlight toneAmber
class node_attachment,node_customattachment,node_dragdrop toneMint
class node_railsengine,node_railseditor,node_remotemedia,node_previewurl toneRose
```

## Components

### Editor runtime

- [JS entry](https://github.com/basecamp/lexxy/blob/main/src/index.js): `src/index.js`
- [Editor element](https://github.com/basecamp/lexxy/blob/main/src/elements/editor.js): `src/elements/editor.js`
- [Editor config](https://github.com/basecamp/lexxy/blob/main/src/config/lexxy.js): `src/config/lexxy.js`
- [Selection](https://github.com/basecamp/lexxy/blob/main/src/editor/selection.js): `src/editor/selection.js`
- [Editor sanitizer](https://github.com/basecamp/lexxy/blob/main/src/editor/sanitizer.js): `src/editor/sanitizer.js`
- [Format helpers](https://github.com/basecamp/lexxy/blob/main/src/helpers/format_helper.js): `src/helpers/format_helper.js`
- [HTML helpers](https://github.com/basecamp/lexxy/blob/main/src/helpers/html_helper.js): `src/helpers/html_helper.js`
- [Lexical helpers](https://github.com/basecamp/lexxy/blob/main/src/helpers/lexical_helper.js): `src/helpers/lexical_helper.js`

### Editing interactions

- [Toolbar](https://github.com/basecamp/lexxy/blob/main/src/elements/toolbar.js): `src/elements/toolbar.js`
- [Heading dropdown](https://github.com/basecamp/lexxy/blob/main/src/elements/dropdown/heading.js): `src/elements/dropdown/heading.js`
- [Prompt UI](https://github.com/basecamp/lexxy/blob/main/src/elements/prompt.js): `src/elements/prompt.js`
- [Table tools](https://github.com/basecamp/lexxy/blob/main/src/elements/table/table_tools.js): `src/elements/table/table_tools.js`
- [Table controller](https://github.com/basecamp/lexxy/blob/main/src/elements/table/table_controller.js): `src/elements/table/table_controller.js`
- [Markdown handler](https://github.com/basecamp/lexxy/blob/main/src/editor/markdown/leading_tag_handler.js): `src/editor/markdown/leading_tag_handler.js`
- [Code highlighting](https://github.com/basecamp/lexxy/blob/main/src/helpers/code_highlighting_helper.js): `src/helpers/code_highlighting_helper.js`

### Attachments

- [Action Text attachment](https://github.com/basecamp/lexxy/blob/main/src/nodes/action_text_attachment_node.js): `src/nodes/action_text_attachment_node.js`
- [Custom attachment](https://github.com/basecamp/lexxy/blob/main/src/nodes/custom_action_text_attachment_node.js): `src/nodes/custom_action_text_attachment_node.js`
- [Custom drag and drop](https://github.com/basecamp/lexxy/blob/main/src/editor/attachments/custom/drag_and_drop.js): `src/editor/attachments/custom/drag_and_drop.js`

### Rails integration

- [Rails engine](https://github.com/basecamp/lexxy/blob/main/lib/lexxy/engine.rb): `lib/lexxy/engine.rb`
- [Action Text editor adapter](https://github.com/basecamp/lexxy/blob/main/lib/action_text/editor/lexxy_editor.rb): `lib/action_text/editor/lexxy_editor.rb`
- [Remote video attachable](https://github.com/basecamp/lexxy/blob/main/lib/action_text/attachables/remote_video.rb): `lib/action_text/attachables/remote_video.rb`
- [Preview URL support](https://github.com/basecamp/lexxy/blob/main/lib/active_storage/blob_with_preview_url.rb): `lib/active_storage/blob_with_preview_url.rb`

### Other components

- **Editor user**

## Connections

- Editor user → Editor element: edits content
- JS entry → Editor config: configures (evidence: `src/index.js`)
- JS entry → Editor sanitizer: exports (evidence: `src/index.js`)
- JS entry → Code highlighting: exports (evidence: `src/index.js`)
- JS entry → Editor element: registers elements
- Editor element → Selection: uses (evidence: `src/elements/editor.js`)
- Editor element → Toolbar: uses (evidence: `src/elements/editor.js`)
- Editor element → Markdown handler: uses (evidence: `src/elements/editor.js`)
- Editor element → Lexical helpers: uses (evidence: `src/elements/editor.js`)
- Heading dropdown → Toolbar: uses icons (evidence: `src/elements/dropdown/heading.js`)
- Table tools → Table controller: uses (evidence: `src/elements/table/table_tools.js`)
- Action Text attachment → HTML helpers: creates markup (evidence: `src/nodes/action_text_attachment_node.js`)
- Custom attachment → Editor sanitizer: sanitizes through (evidence: `src/nodes/custom_action_text_attachment_node.js`)
- Custom drag and drop → Custom attachment: moves (evidence: `src/editor/attachments/custom/drag_and_drop.js`)
- Rails engine → Action Text editor adapter: registers adapter (evidence: `lib/lexxy/engine.rb`)
- Rails engine → Remote video attachable: loads attachable (evidence: `lib/lexxy/engine.rb`)
- Rails engine → Preview URL support: loads extension (evidence: `lib/lexxy/engine.rb`)
