# ajaxorg/ace architecture

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

- Interactive diagram: https://gitdiagram.com/ajaxorg/ace
- Repository: https://github.com/ajaxorg/ace

## Overview

Ace is an embeddable browser-based code editor. A user edits text through the editor; the edit session manages document state and language behavior, while the renderer presents that state in the browser. The README also documents language modes, themes, search, folding, completion, multiple selections, and optional syntax checking. Paths identify the relevant implementation files or enclosing directories; several feature modules were not sampled, so their internal wiring is not asserted.

Main entry points: [`src/edit_session.js`](https://github.com/ajaxorg/ace/blob/master/src/edit_session.js) (Edit Session), [`src/editor.js`](https://github.com/ajaxorg/ace/blob/master/src/editor.js) (Editor), [`src/mouse/mouse_handler.js`](https://github.com/ajaxorg/ace/blob/master/src/mouse/mouse_handler.js) (Mouse Handling), [`src/edit_session/folding.js`](https://github.com/ajaxorg/ace/blob/master/src/edit_session/folding.js) (Code Folding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editing["Editing Core"]
  node_editor["Editor<br/>[editor.js]"]
  node_session["Edit Session<br/>[edit_session.js]"]
  node_document["Text Document<br/>[document.js]"]
  node_selection["Selection and Ranges<br/>[selection.js]"]
  node_undo["Undo Manager<br/>[undomanager.js]"]
  node_core_utilities["Core Utilities"]
end

subgraph group_interaction["Input and Commands"]
  node_commands["Command Manager<br/>[command_manager.js]"]
  node_keyboard["Keyboard Bindings<br/>[keybinding.js]"]
  node_mouse["Mouse Handling<br/>[mouse_handler.js]"]
end

subgraph group_language["Language Services"]
  node_tokenizer["Background Tokenizer"]
  node_language_modes["Language Modes"]
  node_syntax_workers["Syntax Workers"]
  node_highlighting["Static Highlighting"]
end

subgraph group_presentation["Editor Presentation"]
  node_renderer["Virtual Renderer"]
  node_themes["Themes"]
  node_configuration["Configuration and Loading<br/>[config.js]"]
end

subgraph group_extensions["Editor Features"]
  node_search["Search and Replace<br/>[search.js]"]
  node_folding["Code Folding<br/>[folding.js]"]
  node_completion["Autocomplete<br/>[language_tools.js]"]
  node_multi_select["Multiple Selections<br/>[multi_select.js]"]
  node_clipboard["Clipboard<br/>[clipboard.js]"]
end

node_user(("Editor User"))

node_user -->|"edits in"| node_editor
node_editor -->|"uses session"| node_session
node_editor -->|"renders through"| node_renderer
node_editor -->|"dispatches commands"| node_commands
node_editor -->|"configures bindings"| node_keyboard
node_editor -->|"handles pointer input"| node_mouse
node_editor -->|"provides search"| node_search
node_editor -->|"uses configuration"| node_configuration
node_session -->|"manages document"| node_document
node_session -->|"tracks selection"| node_selection
node_session -->|"uses undo manager"| node_undo
node_session -->|"uses tokenizer"| node_tokenizer
node_session -->|"sets language mode"| node_language_modes
node_session -->|"manages folds"| node_folding
node_session -->|"starts mode workers"| node_syntax_workers
node_commands -->|"inherits handlers"| node_keyboard
node_mouse -->|"updates selection"| node_selection
node_mouse -->|"adds drag markers"| node_session
node_folding -->|"reads session"| node_session
node_renderer -->|"renders session state"| node_session
node_configuration -->|"loads theme modules"| node_themes
node_user -->|"chooses theme"| node_themes
node_user -->|"chooses language mode"| node_language_modes
node_user -->|"views highlighted code"| node_highlighting
node_user -->|"requests completion"| node_completion
node_user -->|"uses multiple selections"| node_multi_select
node_user -->|"cuts and pastes"| node_clipboard
node_user -->|"folds code"| node_folding
node_user -->|"searches and replaces"| node_search
node_session -->|"uses shared utilities"| node_core_utilities

click node_editor "https://github.com/ajaxorg/ace/blob/master/src/editor.js"
click node_session "https://github.com/ajaxorg/ace/blob/master/src/edit_session.js"
click node_document "https://github.com/ajaxorg/ace/blob/master/src/document.js"
click node_selection "https://github.com/ajaxorg/ace/blob/master/src/selection.js"
click node_undo "https://github.com/ajaxorg/ace/blob/master/src/undomanager.js"
click node_commands "https://github.com/ajaxorg/ace/blob/master/src/commands/command_manager.js"
click node_keyboard "https://github.com/ajaxorg/ace/blob/master/src/keyboard/keybinding.js"
click node_mouse "https://github.com/ajaxorg/ace/blob/master/src/mouse/mouse_handler.js"
click node_search "https://github.com/ajaxorg/ace/blob/master/src/search.js"
click node_folding "https://github.com/ajaxorg/ace/blob/master/src/edit_session/folding.js"
click node_completion "https://github.com/ajaxorg/ace/blob/master/src/ext/language_tools.js"
click node_tokenizer "https://github.com/ajaxorg/ace/blob/master/src/background_tokenizer.js"
click node_language_modes "https://github.com/ajaxorg/ace/tree/master/src/mode"
click node_syntax_workers "https://github.com/ajaxorg/ace/tree/master/lib/ace/mode"
click node_renderer "https://github.com/ajaxorg/ace/blob/master/src/virtual_renderer.js"
click node_themes "https://github.com/ajaxorg/ace/tree/master/src/theme"
click node_configuration "https://github.com/ajaxorg/ace/blob/master/src/config.js"
click node_highlighting "https://github.com/ajaxorg/ace/blob/master/src/ext/static_highlight.js"
click node_multi_select "https://github.com/ajaxorg/ace/blob/master/src/multi_select.js"
click node_clipboard "https://github.com/ajaxorg/ace/blob/master/src/clipboard.js"
click node_core_utilities "https://github.com/ajaxorg/ace/tree/master/src/lib"

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_editor,node_session,node_document,node_selection,node_undo,node_core_utilities,node_user toneBlue
class node_commands,node_keyboard,node_mouse toneAmber
class node_tokenizer,node_language_modes,node_syntax_workers,node_highlighting toneMint
class node_renderer,node_themes,node_configuration toneRose
class node_search,node_folding,node_completion,node_multi_select,node_clipboard toneIndigo
```

## Components

### Editing Core

- [Editor](https://github.com/ajaxorg/ace/blob/master/src/editor.js): `src/editor.js`
- [Edit Session](https://github.com/ajaxorg/ace/blob/master/src/edit_session.js): `src/edit_session.js`
- [Text Document](https://github.com/ajaxorg/ace/blob/master/src/document.js): `src/document.js`
- [Selection and Ranges](https://github.com/ajaxorg/ace/blob/master/src/selection.js): `src/selection.js`
- [Undo Manager](https://github.com/ajaxorg/ace/blob/master/src/undomanager.js): `src/undomanager.js`
- [Core Utilities](https://github.com/ajaxorg/ace/tree/master/src/lib): `src/lib`

### Input and Commands

- [Command Manager](https://github.com/ajaxorg/ace/blob/master/src/commands/command_manager.js): `src/commands/command_manager.js`
- [Keyboard Bindings](https://github.com/ajaxorg/ace/blob/master/src/keyboard/keybinding.js): `src/keyboard/keybinding.js`
- [Mouse Handling](https://github.com/ajaxorg/ace/blob/master/src/mouse/mouse_handler.js): `src/mouse/mouse_handler.js`

### Language Services

- [Background Tokenizer](https://github.com/ajaxorg/ace/blob/master/src/background_tokenizer.js): `src/background_tokenizer.js`
- [Language Modes](https://github.com/ajaxorg/ace/tree/master/src/mode): `src/mode`
- [Syntax Workers](https://github.com/ajaxorg/ace/tree/master/lib/ace/mode): `lib/ace/mode`
- [Static Highlighting](https://github.com/ajaxorg/ace/blob/master/src/ext/static_highlight.js): `src/ext/static_highlight.js`

### Editor Presentation

- [Virtual Renderer](https://github.com/ajaxorg/ace/blob/master/src/virtual_renderer.js): `src/virtual_renderer.js`
- [Themes](https://github.com/ajaxorg/ace/tree/master/src/theme): `src/theme`
- [Configuration and Loading](https://github.com/ajaxorg/ace/blob/master/src/config.js): `src/config.js`

### Editor Features

- [Search and Replace](https://github.com/ajaxorg/ace/blob/master/src/search.js): `src/search.js`
- [Code Folding](https://github.com/ajaxorg/ace/blob/master/src/edit_session/folding.js): `src/edit_session/folding.js`
- [Autocomplete](https://github.com/ajaxorg/ace/blob/master/src/ext/language_tools.js): `src/ext/language_tools.js`
- [Multiple Selections](https://github.com/ajaxorg/ace/blob/master/src/multi_select.js): `src/multi_select.js`
- [Clipboard](https://github.com/ajaxorg/ace/blob/master/src/clipboard.js): `src/clipboard.js`

### Other components

- **Editor User**

## Connections

- Editor User → Editor: edits in
- Editor → Edit Session: uses session (evidence: `src/editor.js`)
- Editor → Virtual Renderer: renders through (evidence: `src/editor.js`)
- Editor → Command Manager: dispatches commands (evidence: `src/editor.js`)
- Editor → Keyboard Bindings: configures bindings (evidence: `src/editor.js`)
- Editor → Mouse Handling: handles pointer input (evidence: `src/editor.js`)
- Editor → Search and Replace: provides search (evidence: `src/editor.js`)
- Editor → Configuration and Loading: uses configuration (evidence: `src/config.js`)
- Edit Session → Text Document: manages document (evidence: `src/edit_session.js`)
- Edit Session → Selection and Ranges: tracks selection (evidence: `src/edit_session.js`)
- Edit Session → Undo Manager: uses undo manager (evidence: `src/edit_session.js`)
- Edit Session → Background Tokenizer: uses tokenizer (evidence: `src/edit_session.js`)
- Edit Session → Language Modes: sets language mode (evidence: `src/edit_session.js`)
- Edit Session → Code Folding: manages folds (evidence: `src/edit_session.js`)
- Edit Session → Syntax Workers: starts mode workers (evidence: `src/edit_session.js`)
- Command Manager → Keyboard Bindings: inherits handlers (evidence: `src/commands/command_manager.js`)
- Mouse Handling → Selection and Ranges: updates selection
- Mouse Handling → Edit Session: adds drag markers
- Code Folding → Edit Session: reads session (evidence: `src/edit_session/folding.js`)
- Virtual Renderer → Edit Session: renders session state
- Configuration and Loading → Themes: loads theme modules (evidence: `src/config.js`)
- Editor User → Themes: chooses theme
- Editor User → Language Modes: chooses language mode
- Editor User → Static Highlighting: views highlighted code
- Editor User → Autocomplete: requests completion
- Editor User → Multiple Selections: uses multiple selections
- Editor User → Clipboard: cuts and pastes
- Editor User → Code Folding: folds code
- Editor User → Search and Replace: searches and replaces
- Edit Session → Core Utilities: uses shared utilities (evidence: `src/edit_session.js`)
