How ondras/my-mind works
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: backend.ts Storage · format.ts Formats · my-mind.ts App shell · ui.ts Editor UI
Components 32
Runtime
Browser entry points and compiled assets
- index.html · Main browser entry for the mind map app
index.html - editor.html · Editor-specific browser entry
editor.html
Core
Map model, commands, history, and orchestration
- App shell · Top-level application wiring and startup
src/my-mind.ts - Map model · Primary mind map data structure
src/map.ts - Items · Map item structure and node content
src/item.ts - Titles · Title and text handling for nodes
src/title.ts - Actions · Normalized user actions for editing
src/action.ts - Command core · Command abstraction for applying edits
src/command/command.ts - Edit cmds · Commands that mutate map content
src/command/edit.ts - Select cmds · Commands for selection and navigation
src/command/select.ts - History · Tracks reversible edit operations
src/history.ts - Pub/Sub · Internal signaling between app subsystems
src/pubsub.ts
View
Layout, rendering, shapes, and HTML/SVG helpers
UI
Editor chrome and user controls
Integrations
Formats and storage backends
- Storage · Persistence boundary for load/save operations
src/backend/backend.ts - Formats · Import/export adapters between models and files
src/format/format.ts - Local · Local browser storage backend
src/backend/local.ts - File · File-based storage backend
src/backend/file.ts - Drive · Google Drive backend
src/backend/gdrive.ts - WebDAV · WebDAV backend
src/backend/webdav.ts - Firebase · Firebase backend
src/backend/firebase.ts - Image · Image export/import backend
src/backend/image.ts - Native · Native mind map serialization
src/format/native.ts - FreeMind · FreeMind import/export
src/format/freemind.ts - MMA · MMA format adapter
src/format/mma.ts - MUP · MUP format adapter
src/format/mup.ts - Plain text · Text-based import/export
src/format/plaintext.ts
Connections 41
- 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