Updated: 2026-11-19, including the native Structurizr explorer (increment 021). Local desktop application built with Tauri 2, React 19, TypeScript, and Vite.
| Component | Responsibility |
|---|---|
src/App.tsx |
Workspace, lazy explorer, tabs, modes, prompts, and command coordination |
src/Editor.tsx |
CodeMirror 6 instances, per-tab history, edit events, and outline navigation |
src/outline.ts |
Active-buffer Markdown heading extraction and nested section hierarchy |
src/text.ts |
Applying changes to original text and resolving relative links |
src/Preview.tsx |
React Markdown, GFM, omitted frontmatter, queued Pele rendering, and sanitized SVG |
src/pele-renderer.ts |
Lazy local Pele rendering with links and images disabled |
src/styles.css |
Presentation and responsive layout |
src-tauri/src/lib.rs |
Authorized workspace, session metadata, native pickers, reading, saving, menus |
src-tauri/tauri.conf.json |
Window, CSP, and bundling |
src-tauri/capabilities/default.json |
Minimal window capabilities |
tests/text.test.ts and Rust tests in lib.rs |
Text preservation, links, and filesystem boundaries |
Rust maintains Mutex<Option<PathBuf>>: a canonicalized root selected through the native dialog. React tracks open documents with content, saved, revision, and a generation used to recreate the editor after reload. On normal relaunch, a small Rust-owned JSON record in Tauri's app config directory restores the last workspace, relative tab paths in order, and the active tab. It contains no document contents; restored files are read and validated through the existing Rust path boundary and start clean. Missing files are skipped, and a stale workspace leaves the welcome screen available. The app does not recover unsaved edits, editor history, or view state.
IPC commands include load_session, save_session, and restore_workspace alongside choose_workspace, create_markdown_document, list_directory, open_document, write_document, workspace_snapshot, and check_reference_targets. Session IPC reads and writes only the bounded navigation record; React has no general filesystem API. Rust resolves document paths, rejects symlink components, requires containment within the root, and uses exclusive creation for new documents.
Opening a file returns UTF-8 text and its SHA-256 revision. The editor applies changes to the original text while preserving the BOM and untouched line endings. Saving checks the revision, writes and syncs a temporary file next to the destination, checks again, then renames it. A concurrency window remains between the final check and rename; external writers are not locked out.
src-tauri/src/connections.rs builds a bounded read-only workspace snapshot through shared directory enumeration and the existing authorized reader. workspace_snapshot runs blocking I/O on a worker thread. check_reference_targets validates absent targets without reading their contents, distinguishing missing, excluded, and unavailable destinations and returning canonical paths for existing files. Both commands use the selected Rust-owned workspace; neither adds a general-purpose filesystem API.
src/connections.ts parses saved Markdown with unified/remark and the same GFM/frontmatter conventions as the preview. It derives document records and directed reference pairs. src/useConnections.ts fetches snapshots, batches target checks, atomically replaces completed indexes, and retains a visibly stale snapshot on failure. Calls run inside App's serialized actions, preventing overlapping workspace changes and refreshes. Save errors propagate before indexing; indexing errors stay separate from successful disk writes.
src/ConnectionsView.tsx provides reference/backlink lists, missing-target reporting, and empty/error states. src/ConnectionGraph.tsx renders a deterministic SVG graph, fits it with ResizeObserver, and delegates navigation to App. Editors remain mounted inside a hidden wrapper during graph use. The graph and index are derived, in-memory state, with no semantic dependency model or persistent database.
src/Preview.tsx gives rendered headings internal source-offset identifiers for outline navigation; these identifiers do not alter authored fragment links. src/App.tsx derives the outline from the active buffer, coordinates source and preview jumps, and owns the transient accessible panel. The outline parser and rendered headings both normalize an initial UTF-8 BOM and omitted frontmatter consistently. Source navigation scrolls the existing CodeMirror instance without replacing it. In Split mode, only an explicit outline selection navigates both panes; subsequent scrolling remains independent.
GFM tables render inside labelled, keyboard-focusable local overflow regions. CSS applies content-based table sizing and minimum cell widths so narrow columns remain readable while wide tables do not expand the document pane. Preview left-aligns all header and body cell text for scanability; authored GFM alignment markers remain unchanged in the Markdown source.
src/styles.css owns the shared visual tokens and responsive presentation. src/App.tsx derives a compact effective pane mode from viewport width while preserving the selected mode and mounted editor state. The workspace owns transient Explorer and Source/Preview size preferences; pointer-capture separators clamp them to usable bounds, expose keyboard adjustment, and reset to responsive defaults. These preferences are not part of session metadata. Tauri's configured platform icons are generated from src-tauri/icons/source.svg.
tests/connections.test.ts covers Markdown semantics and resolution. tests/connections-interactions.test.tsx uses a simulated IPC boundary to cover saved/dirty buffers, navigation, save/scan failures, retries, refresh, and workspace switching. Native checks supplement these tests; they do not replace filesystem tests in Rust.
File → Open Folder… emits open-folder-requested to the main window. The React listener uses the same guarded open flow as the welcome screen. ⌘O is registered natively; the web handler is only a browser fallback. Closing the window or quitting uses the unsaved-document guard. Force quit cannot protect edits in memory.
Session metadata is written atomically by Rust after workspace/tab navigation changes and before a guarded normal quit completes. The record is bounded and validates absolute workspace paths, relative Markdown paths, duplicate entries, and the active index. Startup canonicalizes the saved workspace and rejects a path that now resolves differently; each tab is reopened through open_document, which rejects traversal, symlinks, invalid Markdown, non-UTF-8 content, and oversized files. Persistence errors do not prevent editing or normal quit.
Bulk tab actions emit close-tabs-requested with an all/others scope. Rust stores menu handles in TabMenu; set_tab_menu_state only updates their enabled state. React queues availability updates in order and revalidates targets inside its action lock. It removes tabs only after the targeted dirty documents have been resolved; partial-save failures retain every editor and the successful saves already completed. The bulk prompt lists affected relative paths in a bounded scrollable list.
While an action is pending, background UI is inert. CodeMirror checks the synchronous action lock at transaction dispatch, including undo transactions that bypass transaction filters. This preserves mounted editor state/history and prevents edits during pending-close resolution without introducing new filesystem access.
pele-renderer.ts derives expected flowchart node IDs from Pele's parsed source model after rendering, excluding subgraph IDs; for C4 diagrams, it uses Pele's C4 parser to derive shape aliases and relationship endpoints. Preview forwards these identities alongside the current sanitized SVG to App. diagram-search.ts validates a complete one-to-one node mapping against documented pele-node groups and data-id, extracts displayed label text, normalizes search terms, and computes target viewport geometry. Unknown mappings disable search rather than returning a partial list.
DiagramFocusView.tsx uses a native HTML dialog and a namespaced SVG copy with explicit natural dimensions. Its viewport transforms the art container without rerendering Pele. Search and node inspection measure node bounds relative to that container; selected nodes and their incident edges receive transient classes in the view-only SVG copy. diagram-search.ts classifies direct edges from the same Pele source model and exact authored edge IDs; only explicit arrow styles determine flowchart direction. C4 relationship aliases map directly to rendered edge IDs, with BiRel and Rel_U classified as two-way and undirected. The inspector excludes flowchart subgraph endpoints and C4 boundaries; flowchart parallel edges and self-loops retain their existing support. Image export uses the original sanitized SVG. App dismisses the view on document/source/generation, pane mode, Connections, or guarded-action changes. All inspection state is transient. See plans 014 and 015 for validation evidence and limits.
The preview never changes the source. HTML is disabled. Pele loads lazily to render Mermaid syntax; diagram links and images are disabled, and SVG is sanitized with DOMPurify, excluding links, images, and foreignObject. CSP restricts remote resources. See SPEC for the exact product scope and limits.
src/c4/upstream contains a licensed, pinned C4 Hero parser dependency closure. adapter.ts validates the workspace envelope, normalizes diagnostics, identifies supported views, and projects declared and implied relationships. It calls the upstream parser and default-view generator directly. Its import closure contains the pure model and parsing helpers.
worker.ts parses and lays out derived architecture data off the UI thread. Requests and results carry a monotonically increasing per-document source version, and layout results also carry a view key. ArchitectureExplorer.tsx rejects outdated results, retains a labelled stale diagram for invalid edits, and keeps selection, viewport, search, and navigation history inside each mounted document session. The explorer loads lazily through App. Explicit text saves and pending-change guards continue through the existing App lifecycle.
layout.ts uses Dagre for independent sibling layouts, working outward through nested system, container, and group boundaries. Node identity and view membership remain independent of coordinates. React Flow renders read-only nodes and relationships with local visible controls and an accessible inspector. The adapter excludes external resources, unresolved includes, and executable directives from processing and exposes incomplete-coverage diagnostics. The runtime gains a same-origin bundled worker and no remote permissions.
Rust accepts .dsl files through the existing bounded reader, revision checks, atomic saver, and clean-tab session validation. Explorer enumeration recognizes Markdown and DSL. Connections supplies a separate Markdown-only enumeration predicate, and Markdown creation retains its original extension restriction. See plan 021 for validation evidence.
App.tsx and lib.rs currently coordinate the MVP. Split workspace, tab, or file-service responsibilities when an increment calls for it; avoid speculative layers. New disk rules belong in Rust, and text transformations must retain preservation tests.
.github/workflows/release.yml separates tag/version validation, read-only macOS builds, and a contents-write draft-release job. scripts/release/validate.py resolves an existing tag to a commit and reads version metadata from that commit. Both build jobs check out that SHA, run existing checks, and compile locked dependencies. package.py checks the bundle version and architecture, creates ZIPs, verifies extracted executables, and writes SHA-256 files.
draft.py verifies the complete asset set and the remote tag before release writes. It creates only drafts, preserves existing notes and unrelated assets, and replaces only workflow-labelled assets for the same source commit. Per-tag concurrency serializes workflow runs; draft-state checks guard individual API mutations. Human publication must wait for workflow completion because GitHub does not provide an atomic draft-only upload condition. The app has no dependency on this infrastructure and gains no remote permissions. Hosted verification remains pending; see plan 018.