# ondras/my-mind architecture

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

- Interactive diagram: https://gitdiagram.com/ondras/my-mind
- Repository: https://github.com/ondras/my-mind

## Overview

1. **What this repo is**
   - My Mind is a **browser-based mind map editor**. It is primarily a **client-side application**: the README says it runs from a local web server, and the tree shows only static assets, TypeScript sources, HTML entry points, and stylesheet sources.

2. **Entry points and packaging**
   - The top-level runtime entry points are **`index.html`** and **`editor.html`**, which load the compiled app assets such as **`my-mind.js`** and **`my-mind.css`**.
   - The repo is built from **TypeScript** under `src/` plus **LESS/CSS** under `css/`, then served as a static web app.

3. **Core application boundary**
   - The main orchestration layer appears to live in **`src/my-mind.ts`**.
   - Core domain state is split across modules like **`map.ts`**, **`item.ts`**, and **`title.ts`**, with helper layers for HTML/SVG generation in **`html.ts`** and **`svg.ts`**.
   - A **pub/sub** module suggests the app uses internal event signaling rather than a heavyweight framework.

4. **User interaction pipeline**
   - Input is handled explicitly through **`keyboard.ts`**, **`mouse.ts`**, and **`clipboard.ts`**.
   - User actions are normalized into a command/action model via **`src/action.ts`** and the **`src/command/`** subsystem.
   - This is the main edit boundary: input events become commands, commands mutate map state, and the UI reflects the resulting model.

5. **Undo/redo and editing semantics**
   - **`history.ts`** is a distinct subsystem, indicating edits are tracked as reversible operations.
   - The command folders (`edit.ts`, `select.ts`, plus `command.ts`) imply separation between **editing behavior** and **selection/navigation behavior**.
   - For an architecture diagram, this is a key loop: **interaction → command → history/state update → re-render**.

6. **Layout and visualization**
   - Layout is separated into **`src/layout/`** with `layout.ts`, `map.ts`, `tree.ts`, and `graph.ts`.
   - This indicates the app can compute different spatial arrangements for the same underlying mind map, rather than hardcoding one visual style.
   - Rendering uses shape abstractions in **`src/shape/`** (`box`, `ellipse`, `underline`), plus SVG helpers, so the visual layer is likely composition-based and data-driven.

7. **Persistence and external storage**
   - Storage is abstracted under **`src/backend/`** and mirrored in **`src/ui/backend/`**.
   - Concrete backends include **local**, **file**, **Google Drive**, **WebDAV**, **Firebase**, and **image** handling.
   - This is the main integration boundary to the outside world: the app can save/load maps locally or through third-party services without changing the core editing model.

8. **Import/export formats**
   - The **`src/format/`** directory contains converters for **native**, **FreeMind**, **MMA**, **MUP**, and **plain text**.
   - These format adapters sit between the map model and persistence/export flows.
   - In the architecture diagram, they belong alongside storage but are distinct from storage itself: **formatting transforms data**, while **backends move data**.

9. **UI chrome and editor panels**
   - The `src/ui/` subtree contains the editor shell: **context menu, format selector, help, icons, I/O controls, layout controls, notes, shape pickers, status, tips, text color, values**.
   - These modules are mostly presentation and control surfaces around the core map editor, not separate business logic.
   - They connect user-facing controls to the command and backend layers.

10. **Styling and assets**
   - Styling is split between LESS source files like **`context-menu.less`**, **`map.less`**, **`pane.less`**, and **`print.less`**, plus compiled CSS files at the top level.
   - Images and logo assets live under **`img/`** and **`logo/`**.
   - This separation matters if you are drawing build/runtime boundaries: the app’s visual appearance is compiled ahead of time and then consumed statically by the browser.

11. **Representative end-to-end data flow**
   - A map is **loaded from a backend** or example file, **parsed by a format module**, **materialized into the core map/item model**, **laid out**, and then **rendered to the DOM/SVG UI**.
   - During editing, **mouse/keyboard/clipboard events** become **commands**, which update the model and history, after which the layout and render layers refresh.
   - Saving/export reverses the path: **model → format adapter → backend**.

12. **How to draw the architecture**
   - Center the diagram on the **core map model and command/history loop**.
   - Surround it with three major rings:
     - **Input/UI chrome** on the user-facing side,
     - **Layout/rendering** on the visualization side,
     - **Formats/backends** on the persistence/integration side.
   - The external boundaries are the **browser DOM**, **static file hosting**, and optional external services like **Google Drive, Firebase, and WebDAV**.

Main entry points: [`src/backend/backend.ts`](https://github.com/ondras/my-mind/blob/master/src/backend/backend.ts) (Storage), [`src/format/format.ts`](https://github.com/ondras/my-mind/blob/master/src/format/format.ts) (Formats), [`src/my-mind.ts`](https://github.com/ondras/my-mind/blob/master/src/my-mind.ts) (App shell), [`src/ui/ui.ts`](https://github.com/ondras/my-mind/blob/master/src/ui/ui.ts) (Editor UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_index_html["index.html<br/>entry page<br/>[index.html]"]
  node_editor_html["editor.html<br/>entry page<br/>[editor.html]"]
end

subgraph group_core["Core"]
  node_my_mind_ts["App shell<br/>orchestrator<br/>[my-mind.ts]"]
  node_map_ts["Map model<br/>domain state<br/>[map.ts]"]
  node_item_ts["Items<br/>domain entities<br/>[item.ts]"]
  node_title_ts["Titles<br/>text model<br/>[title.ts]"]
  node_action_ts["Actions<br/>action model<br/>[action.ts]"]
  node_command_ts["Command core<br/>command layer<br/>[command.ts]"]
  node_edit_ts["Edit cmds<br/>editing commands<br/>[edit.ts]"]
  node_select_ts["Select cmds<br/>selection commands<br/>[select.ts]"]
  node_history_ts["History<br/>undo/redo<br/>[history.ts]"]
  node_pubsub_ts(("Pub/Sub<br/>event bus<br/>[pubsub.ts]"))
end

subgraph group_view["View"]
  node_layout_ts["Layout<br/>[layout.ts]"]
  node_render_helpers["HTML/SVG<br/>render helpers<br/>[html.ts]"]
  node_shape_ts{{"Shapes<br/>shape system<br/>[shape.ts]"}}
end

subgraph group_ui["UI"]
  node_keyboard_ts["Keyboard<br/>input<br/>[keyboard.ts]"]
  node_mouse_ts["Mouse<br/>input<br/>[mouse.ts]"]
  node_clipboard_ts["Clipboard<br/>input<br/>[clipboard.ts]"]
  node_ui_shell["Editor UI<br/>chrome<br/>[ui.ts]"]
end

subgraph group_integrations["Integrations"]
  node_backend_ts["Storage<br/>backend abstraction<br/>[backend.ts]"]
  node_format_ts["Formats<br/>format adapters<br/>[format.ts]"]
  node_local_backend[("Local<br/>backend<br/>[local.ts]")]
  node_file_backend[("File<br/>backend<br/>[file.ts]")]
  node_gdrive_backend[("Drive<br/>backend<br/>[gdrive.ts]")]
  node_webdav_backend[("WebDAV<br/>backend<br/>[webdav.ts]")]
  node_firebase_backend[("Firebase<br/>backend<br/>[firebase.ts]")]
  node_image_backend[("Image<br/>backend<br/>[image.ts]")]
  node_native_format["Native<br/>format<br/>[native.ts]"]
  node_freemind_format["FreeMind<br/>format<br/>[freemind.ts]"]
  node_mma_format["MMA<br/>format<br/>[mma.ts]"]
  node_mup_format["MUP<br/>format<br/>[mup.ts]"]
  node_plaintext_format["Plain text<br/>format<br/>[plaintext.ts]"]
end

node_index_html -->|"loads"| node_my_mind_ts
node_editor_html -->|"loads"| node_my_mind_ts
node_my_mind_ts -->|"wires UI"| node_ui_shell
node_my_mind_ts -->|"owns state"| node_map_ts
node_my_mind_ts -->|"coordinates"| node_layout_ts
node_my_mind_ts -->|"renders"| node_render_helpers
node_keyboard_ts -->|"normalizes"| node_action_ts
node_mouse_ts -->|"normalizes"| node_action_ts
node_clipboard_ts -->|"normalizes"| node_action_ts
node_action_ts -->|"dispatches"| node_command_ts
node_command_ts -->|"includes"| node_edit_ts
node_command_ts -->|"includes"| node_select_ts
node_edit_ts -->|"mutates"| node_map_ts
node_select_ts -->|"updates"| node_map_ts
node_command_ts -->|"records"| node_history_ts
node_history_ts -->|"replays"| node_map_ts
node_ui_shell -->|"captures"| node_keyboard_ts
node_ui_shell -->|"captures"| node_mouse_ts
node_ui_shell -->|"captures"| node_clipboard_ts
node_ui_shell -->|"connects"| node_backend_ts
node_layout_ts -->|"uses"| node_shape_ts
node_layout_ts -->|"feeds"| node_render_helpers
node_render_helpers -->|"draws"| node_shape_ts
node_backend_ts -->|"implements"| node_local_backend
node_backend_ts -->|"implements"| node_file_backend
node_backend_ts -->|"implements"| node_gdrive_backend
node_backend_ts -->|"implements"| node_webdav_backend
node_backend_ts -->|"implements"| node_firebase_backend
node_backend_ts -->|"implements"| node_image_backend
node_format_ts -->|"implements"| node_native_format
node_format_ts -->|"implements"| node_freemind_format
node_format_ts -->|"implements"| node_mma_format
node_format_ts -->|"implements"| node_mup_format
node_format_ts -->|"implements"| node_plaintext_format
node_backend_ts -->|"uses"| node_format_ts
node_format_ts -->|"serializes"| node_map_ts
node_map_ts -->|"contains"| node_item_ts
node_item_ts -->|"uses"| node_title_ts
node_my_mind_ts -->|"signals"| node_pubsub_ts
node_pubsub_ts -->|"notifies"| node_ui_shell
node_pubsub_ts -->|"notifies"| node_layout_ts

click node_index_html "https://github.com/ondras/my-mind/blob/master/index.html"
click node_editor_html "https://github.com/ondras/my-mind/blob/master/editor.html"
click node_my_mind_ts "https://github.com/ondras/my-mind/blob/master/src/my-mind.ts"
click node_map_ts "https://github.com/ondras/my-mind/blob/master/src/map.ts"
click node_item_ts "https://github.com/ondras/my-mind/blob/master/src/item.ts"
click node_title_ts "https://github.com/ondras/my-mind/blob/master/src/title.ts"
click node_action_ts "https://github.com/ondras/my-mind/blob/master/src/action.ts"
click node_command_ts "https://github.com/ondras/my-mind/blob/master/src/command/command.ts"
click node_edit_ts "https://github.com/ondras/my-mind/blob/master/src/command/edit.ts"
click node_select_ts "https://github.com/ondras/my-mind/blob/master/src/command/select.ts"
click node_history_ts "https://github.com/ondras/my-mind/blob/master/src/history.ts"
click node_pubsub_ts "https://github.com/ondras/my-mind/blob/master/src/pubsub.ts"
click node_keyboard_ts "https://github.com/ondras/my-mind/blob/master/src/keyboard.ts"
click node_mouse_ts "https://github.com/ondras/my-mind/blob/master/src/mouse.ts"
click node_clipboard_ts "https://github.com/ondras/my-mind/blob/master/src/clipboard.ts"
click node_ui_shell "https://github.com/ondras/my-mind/blob/master/src/ui/ui.ts"
click node_layout_ts "https://github.com/ondras/my-mind/blob/master/src/layout/layout.ts"
click node_render_helpers "https://github.com/ondras/my-mind/blob/master/src/html.ts"
click node_shape_ts "https://github.com/ondras/my-mind/blob/master/src/shape/shape.ts"
click node_backend_ts "https://github.com/ondras/my-mind/blob/master/src/backend/backend.ts"
click node_format_ts "https://github.com/ondras/my-mind/blob/master/src/format/format.ts"
click node_local_backend "https://github.com/ondras/my-mind/blob/master/src/backend/local.ts"
click node_file_backend "https://github.com/ondras/my-mind/blob/master/src/backend/file.ts"
click node_gdrive_backend "https://github.com/ondras/my-mind/blob/master/src/backend/gdrive.ts"
click node_webdav_backend "https://github.com/ondras/my-mind/blob/master/src/backend/webdav.ts"
click node_firebase_backend "https://github.com/ondras/my-mind/blob/master/src/backend/firebase.ts"
click node_image_backend "https://github.com/ondras/my-mind/blob/master/src/backend/image.ts"
click node_native_format "https://github.com/ondras/my-mind/blob/master/src/format/native.ts"
click node_freemind_format "https://github.com/ondras/my-mind/blob/master/src/format/freemind.ts"
click node_mma_format "https://github.com/ondras/my-mind/blob/master/src/format/mma.ts"
click node_mup_format "https://github.com/ondras/my-mind/blob/master/src/format/mup.ts"
click node_plaintext_format "https://github.com/ondras/my-mind/blob/master/src/format/plaintext.ts"

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_index_html,node_editor_html toneBlue
class node_my_mind_ts,node_map_ts,node_item_ts,node_title_ts,node_action_ts,node_command_ts,node_edit_ts,node_select_ts,node_history_ts,node_pubsub_ts toneAmber
class node_layout_ts,node_render_helpers,node_shape_ts toneMint
class node_keyboard_ts,node_mouse_ts,node_clipboard_ts,node_ui_shell toneRose
class node_backend_ts,node_format_ts,node_local_backend,node_file_backend,node_gdrive_backend,node_webdav_backend,node_firebase_backend,node_image_backend,node_native_format,node_freemind_format,node_mma_format,node_mup_format,node_plaintext_format toneIndigo
```

## Components

### Runtime

Browser entry points and compiled assets

- [index.html](https://github.com/ondras/my-mind/blob/master/index.html): entry page · Main browser entry for the mind map app · `index.html`
- [editor.html](https://github.com/ondras/my-mind/blob/master/editor.html): entry page · Editor-specific browser entry · `editor.html`

### Core

Map model, commands, history, and orchestration

- [App shell](https://github.com/ondras/my-mind/blob/master/src/my-mind.ts): orchestrator · Top-level application wiring and startup · `src/my-mind.ts`
- [Map model](https://github.com/ondras/my-mind/blob/master/src/map.ts): domain state · Primary mind map data structure · `src/map.ts`
- [Items](https://github.com/ondras/my-mind/blob/master/src/item.ts): domain entities · Map item structure and node content · `src/item.ts`
- [Titles](https://github.com/ondras/my-mind/blob/master/src/title.ts): text model · Title and text handling for nodes · `src/title.ts`
- [Actions](https://github.com/ondras/my-mind/blob/master/src/action.ts): action model · Normalized user actions for editing · `src/action.ts`
- [Command core](https://github.com/ondras/my-mind/blob/master/src/command/command.ts): command layer · Command abstraction for applying edits · `src/command/command.ts`
- [Edit cmds](https://github.com/ondras/my-mind/blob/master/src/command/edit.ts): editing commands · Commands that mutate map content · `src/command/edit.ts`
- [Select cmds](https://github.com/ondras/my-mind/blob/master/src/command/select.ts): selection commands · Commands for selection and navigation · `src/command/select.ts`
- [History](https://github.com/ondras/my-mind/blob/master/src/history.ts): undo/redo · Tracks reversible edit operations · `src/history.ts`
- [Pub/Sub](https://github.com/ondras/my-mind/blob/master/src/pubsub.ts): event bus · Internal signaling between app subsystems · `src/pubsub.ts`

### View

Layout, rendering, shapes, and HTML/SVG helpers

- [Layout](https://github.com/ondras/my-mind/blob/master/src/layout/layout.ts): layout orchestrator · Chooses and coordinates map layouts · `src/layout/layout.ts`
- [HTML/SVG](https://github.com/ondras/my-mind/blob/master/src/html.ts): render helpers · DOM and SVG generation helpers · `src/html.ts`
- [Shapes](https://github.com/ondras/my-mind/blob/master/src/shape/shape.ts): shape system · Visual shape abstraction for nodes · `src/shape/shape.ts`

### UI

Editor chrome and user controls

- [Keyboard](https://github.com/ondras/my-mind/blob/master/src/keyboard.ts): input · Keyboard event handling · `src/keyboard.ts`
- [Mouse](https://github.com/ondras/my-mind/blob/master/src/mouse.ts): input · Mouse event handling · `src/mouse.ts`
- [Clipboard](https://github.com/ondras/my-mind/blob/master/src/clipboard.ts): input · Clipboard interaction and paste/copy flow · `src/clipboard.ts`
- [Editor UI](https://github.com/ondras/my-mind/blob/master/src/ui/ui.ts): chrome · Editor controls and panels around the map canvas · `src/ui/ui.ts`

### Integrations

Formats and storage backends

- [Storage](https://github.com/ondras/my-mind/blob/master/src/backend/backend.ts): backend abstraction · Persistence boundary for load/save operations · `src/backend/backend.ts`
- [Formats](https://github.com/ondras/my-mind/blob/master/src/format/format.ts): format adapters · Import/export adapters between models and files · `src/format/format.ts`
- [Local](https://github.com/ondras/my-mind/blob/master/src/backend/local.ts): backend · Local browser storage backend · `src/backend/local.ts`
- [File](https://github.com/ondras/my-mind/blob/master/src/backend/file.ts): backend · File-based storage backend · `src/backend/file.ts`
- [Drive](https://github.com/ondras/my-mind/blob/master/src/backend/gdrive.ts): backend · Google Drive backend · `src/backend/gdrive.ts`
- [WebDAV](https://github.com/ondras/my-mind/blob/master/src/backend/webdav.ts): backend · WebDAV backend · `src/backend/webdav.ts`
- [Firebase](https://github.com/ondras/my-mind/blob/master/src/backend/firebase.ts): backend · Firebase backend · `src/backend/firebase.ts`
- [Image](https://github.com/ondras/my-mind/blob/master/src/backend/image.ts): backend · Image export/import backend · `src/backend/image.ts`
- [Native](https://github.com/ondras/my-mind/blob/master/src/format/native.ts): format · Native mind map serialization · `src/format/native.ts`
- [FreeMind](https://github.com/ondras/my-mind/blob/master/src/format/freemind.ts): format · FreeMind import/export · `src/format/freemind.ts`
- [MMA](https://github.com/ondras/my-mind/blob/master/src/format/mma.ts): format · MMA format adapter · `src/format/mma.ts`
- [MUP](https://github.com/ondras/my-mind/blob/master/src/format/mup.ts): format · MUP format adapter · `src/format/mup.ts`
- [Plain text](https://github.com/ondras/my-mind/blob/master/src/format/plaintext.ts): format · Text-based import/export · `src/format/plaintext.ts`

## Connections

- index.html → App shell: loads · Bootstraps the main app runtime
- editor.html → App shell: loads · Bootstraps the editor runtime
- App shell → Editor UI: wires UI · Connects the editor shell to core services
- App shell → Map model: owns state · Holds the active mind map model
- App shell → Layout: coordinates · Triggers layout recomputation
- App shell → HTML/SVG: renders · Updates DOM/SVG output
- Keyboard → Actions: normalizes · Converts key events into actions
- Mouse → Actions: normalizes · Converts pointer events into actions
- Clipboard → Actions: normalizes · Converts clipboard events into actions
- Actions → Command core: dispatches · Routes actions into executable commands
- Command core → Edit cmds: includes · Edit-oriented command implementations
- Command core → Select cmds: includes · Selection and navigation command implementations
- Edit cmds → Map model: mutates · Applies content changes to the map model
- Select cmds → Map model: updates · Changes selection state on the map model
- Command core → History: records · Stores reversible edits for undo/redo
- History → Map model: replays · Restores previous map states
- Editor UI → Keyboard: captures · Routes keyboard input from the editor UI
- Editor UI → Mouse: captures · Routes mouse input from the editor UI
- Editor UI → Clipboard: captures · Routes clipboard input from the editor UI
- Editor UI → Storage: connects · Exposes storage controls and backend selection
- Layout → Shapes: uses · Relies on shape abstraction during layout/rendering
- Layout → HTML/SVG: feeds · Provides positioned nodes to the renderer
- HTML/SVG → Shapes: draws · Renders map elements using shape primitives
- Storage → Local: implements · Concrete local storage backend
- Storage → File: implements · Concrete file storage backend
- Storage → Drive: implements · Concrete Google Drive backend
- Storage → WebDAV: implements · Concrete WebDAV backend
- Storage → Firebase: implements · Concrete Firebase backend
- Storage → Image: implements · Concrete image backend
- Formats → Native: implements · Native serialization adapter
- Formats → FreeMind: implements · FreeMind adapter
- Formats → MMA: implements · MMA adapter
- Formats → MUP: implements · MUP adapter
- Formats → Plain text: implements · Plain text adapter
- Storage → Formats: uses · Backends exchange data through formats
- Formats → Map model: serializes · Converts between map model and external representations
- Map model → Items: contains · Map is composed of items
- Items → Titles: uses · Items carry editable title text
- App shell → Pub/Sub: signals · Uses pub/sub for internal coordination
- Pub/Sub → Editor UI: notifies · Broadcasts state changes to UI surfaces
- Pub/Sub → Layout: notifies · Triggers downstream layout refreshes
