# kimroen121/hwalja architecture

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

- Interactive diagram: https://gitdiagram.com/kimroen121/hwalja
- Repository: https://github.com/kimroen121/hwalja

## Overview

Hwalja is a native macOS HWP document editor. The main workflow is opening a document in a window, editing it through the canvas and workspace controls, and delegating document operations to the Rust editing engine; the engine returns page displays for rendering. The README also highlights familiar menus and stable editing of large documents, and the tree includes a Finder Quick Look preview. Some workspace and engine modules were not sampled, so their internal wiring is shown only where the index or excerpts support it.

Main entry points: [`App/Document/HwpDocument.swift`](https://github.com/kimroen121/hwalja/blob/main/App/Document/HwpDocument.swift) (HWP document model), [`Engine/crates/hwp-engine-abi/src/editing/commands.rs`](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/commands.rs) (Edit commands), [`App/Workspace/DocumentWindow.swift`](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/DocumentWindow.swift) (Document window), [`App/Editing/EditSession.swift`](https://github.com/kimroen121/hwalja/blob/main/App/Editing/EditSession.swift) (Edit session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App lifecycle"]
  node_app["Hwalja app<br/>[HwaljaApp.swift]"]
  node_document["HWP document model<br/>[HwpDocument.swift]"]
  node_barrier["Work barrier"]
end

subgraph group_workspace["Editing workspace"]
  node_window["Document window"]
  node_canvas["Document canvas"]
  node_dialogs["Document dialogs<br/>[Dialogs.swift]"]
  node_ribbon["Ribbon controls<br/>[Ribbon.swift]"]
  node_menus["Menu commands<br/>[MenuCommands.swift]"]
  node_format["Format sheets<br/>[FormatSheets.swift]"]
  node_styles["Style sheets<br/>[StyleSheets.swift]"]
  node_objects["Object sheets<br/>[ObjectSheets.swift]"]
  node_codes["Code sheets<br/>[CodeSheets.swift]"]
  node_equation["Equation editor"]
end

subgraph group_engine["Document engine"]
  node_session["Edit session<br/>[EditSession.swift]"]
  node_ffi["Engine ABI<br/>[ffi.rs]"]
  node_commands["Edit commands<br/>[commands.rs]"]
  node_formatengine["Formatting operations<br/>[format.rs]"]
  node_sections["Sections and layout<br/>[sections.rs]"]
  node_preservation["Content preservation<br/>[preservation.rs]"]
  node_codesengine["Document codes<br/>[codes.rs]"]
  node_cells["Table cells<br/>[cells.rs]"]
  node_borders["Borders<br/>[borders.rs]"]
  node_objectsengine["Document objects<br/>[objects.rs]"]
  node_forms["Form objects<br/>[forms.rs]"]
end

subgraph group_render["Display and preview"]
  node_displayengine["Page display output<br/>[display.rs]"]
  node_pagedisplay["Page renderer<br/>[PageDisplay.swift]"]
  node_geometry["Page geometry<br/>[PageGeometry.swift]"]
  node_preview["Finder Quick Look"]
end

node_user(("Mac user"))
node_external["HWP file"]

node_user -->|"opens"| node_app
node_app -->|"creates window"| node_window
node_window -->|"hosts document"| node_document
node_window -->|"shows canvas"| node_canvas
node_window -->|"presents"| node_equation
node_canvas -->|"edits and queries"| node_document
node_ribbon -->|"invokes commands"| node_document
node_dialogs -->|"configures document"| node_document
node_menus -.->|"dispatches commands"| node_document
node_format -.->|"sets formatting"| node_document
node_styles -.->|"manages styles"| node_document
node_objects -.->|"edits objects"| node_document
node_codes -->|"edits document codes"| node_document
node_equation -->|"inserts equations"| node_document
node_document -->|"sends edits"| node_session
node_document -->|"tracks pending work"| node_barrier
node_external -.->|"opens or saves"| node_document
node_session -.->|"calls engine"| node_ffi
node_ffi -->|"dispatches requests"| node_commands
node_commands -->|"uses formatting"| node_formatengine
node_commands -->|"uses section logic"| node_sections
node_commands -->|"checks preservation"| node_preservation
node_commands -->|"uses code helpers"| node_codesengine
node_commands -->|"uses table helpers"| node_cells
node_commands -.->|"uses border helpers"| node_borders
node_commands -.->|"uses object helpers"| node_objectsengine
node_commands -.->|"uses form helpers"| node_forms
node_session -->|"produces page output"| node_displayengine
node_displayengine -.->|"returns display data"| node_pagedisplay
node_pagedisplay -->|"uses page coordinates"| node_geometry
node_preview -->|"opens document"| node_session
node_preview -->|"renders pages"| node_pagedisplay

click node_app "https://github.com/kimroen121/hwalja/blob/main/App/HwaljaApp.swift"
click node_window "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/DocumentWindow.swift"
click node_document "https://github.com/kimroen121/hwalja/blob/main/App/Document/HwpDocument.swift"
click node_barrier "https://github.com/kimroen121/hwalja/blob/main/App/Document/DocumentWorkBarrier.swift"
click node_canvas "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/DocumentCanvas.swift"
click node_dialogs "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/Dialogs.swift"
click node_ribbon "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/Ribbon.swift"
click node_menus "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/MenuCommands.swift"
click node_format "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/FormatSheets.swift"
click node_styles "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/StyleSheets.swift"
click node_objects "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/ObjectSheets.swift"
click node_codes "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/CodeSheets.swift"
click node_equation "https://github.com/kimroen121/hwalja/blob/main/App/Workspace/EquationEditor.swift"
click node_session "https://github.com/kimroen121/hwalja/blob/main/App/Editing/EditSession.swift"
click node_ffi "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/ffi.rs"
click node_commands "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/commands.rs"
click node_formatengine "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/format.rs"
click node_sections "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/sections.rs"
click node_preservation "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/preservation.rs"
click node_codesengine "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/codes.rs"
click node_cells "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/cells.rs"
click node_borders "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/borders.rs"
click node_objectsengine "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/objects.rs"
click node_forms "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/forms.rs"
click node_displayengine "https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/display.rs"
click node_pagedisplay "https://github.com/kimroen121/hwalja/blob/main/App/Editing/PageDisplay.swift"
click node_geometry "https://github.com/kimroen121/hwalja/blob/main/App/Editing/PageGeometry.swift"
click node_preview "https://github.com/kimroen121/hwalja/blob/main/Preview/PreviewProvider.swift"

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_app,node_document,node_barrier,node_user toneBlue
class node_window,node_canvas,node_dialogs,node_ribbon,node_menus,node_format,node_styles,node_objects,node_codes,node_equation toneAmber
class node_session,node_ffi,node_commands,node_formatengine,node_sections,node_preservation,node_codesengine,node_cells,node_borders,node_objectsengine,node_forms toneMint
class node_displayengine,node_pagedisplay,node_geometry,node_preview toneRose
class node_external toneIndigo
```

## Components

### App lifecycle

- [Hwalja app](https://github.com/kimroen121/hwalja/blob/main/App/HwaljaApp.swift): `App/HwaljaApp.swift`
- [HWP document model](https://github.com/kimroen121/hwalja/blob/main/App/Document/HwpDocument.swift): `App/Document/HwpDocument.swift`
- [Work barrier](https://github.com/kimroen121/hwalja/blob/main/App/Document/DocumentWorkBarrier.swift): `App/Document/DocumentWorkBarrier.swift`

### Editing workspace

- [Document window](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/DocumentWindow.swift): `App/Workspace/DocumentWindow.swift`
- [Document canvas](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/DocumentCanvas.swift): `App/Workspace/DocumentCanvas.swift`
- [Document dialogs](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/Dialogs.swift): `App/Workspace/Dialogs.swift`
- [Ribbon controls](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/Ribbon.swift): `App/Workspace/Ribbon.swift`
- [Menu commands](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/MenuCommands.swift): `App/Workspace/MenuCommands.swift`
- [Format sheets](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/FormatSheets.swift): `App/Workspace/FormatSheets.swift`
- [Style sheets](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/StyleSheets.swift): `App/Workspace/StyleSheets.swift`
- [Object sheets](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/ObjectSheets.swift): `App/Workspace/ObjectSheets.swift`
- [Code sheets](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/CodeSheets.swift): `App/Workspace/CodeSheets.swift`
- [Equation editor](https://github.com/kimroen121/hwalja/blob/main/App/Workspace/EquationEditor.swift): `App/Workspace/EquationEditor.swift`

### Document engine

- [Edit session](https://github.com/kimroen121/hwalja/blob/main/App/Editing/EditSession.swift): `App/Editing/EditSession.swift`
- [Engine ABI](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/ffi.rs): `Engine/crates/hwp-engine-abi/src/editing/ffi.rs`
- [Edit commands](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/commands.rs): `Engine/crates/hwp-engine-abi/src/editing/commands.rs`
- [Formatting operations](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/format.rs): `Engine/crates/hwp-engine-abi/src/editing/format.rs`
- [Sections and layout](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/sections.rs): `Engine/crates/hwp-engine-abi/src/editing/sections.rs`
- [Content preservation](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/preservation.rs): `Engine/crates/hwp-engine-abi/src/editing/preservation.rs`
- [Document codes](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/codes.rs): `Engine/crates/hwp-engine-abi/src/editing/codes.rs`
- [Table cells](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/cells.rs): `Engine/crates/hwp-engine-abi/src/editing/cells.rs`
- [Borders](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/borders.rs): `Engine/crates/hwp-engine-abi/src/editing/borders.rs`
- [Document objects](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/objects.rs): `Engine/crates/hwp-engine-abi/src/editing/objects.rs`
- [Form objects](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/forms.rs): `Engine/crates/hwp-engine-abi/src/editing/forms.rs`

### Display and preview

- [Page display output](https://github.com/kimroen121/hwalja/blob/main/Engine/crates/hwp-engine-abi/src/editing/display.rs): `Engine/crates/hwp-engine-abi/src/editing/display.rs`
- [Page renderer](https://github.com/kimroen121/hwalja/blob/main/App/Editing/PageDisplay.swift): `App/Editing/PageDisplay.swift`
- [Page geometry](https://github.com/kimroen121/hwalja/blob/main/App/Editing/PageGeometry.swift): `App/Editing/PageGeometry.swift`
- [Finder Quick Look](https://github.com/kimroen121/hwalja/blob/main/Preview/PreviewProvider.swift): `Preview/PreviewProvider.swift`

### Other components

- **Mac user**
- **HWP file**

## Connections

- Mac user → Hwalja app: opens (evidence: `App/HwaljaApp.swift`)
- Hwalja app → Document window: creates window (evidence: `App/HwaljaApp.swift`)
- Document window → HWP document model: hosts document (evidence: `App/Workspace/DocumentWindow.swift`)
- Document window → Document canvas: shows canvas (evidence: `App/Workspace/DocumentWindow.swift`)
- Document window → Equation editor: presents (evidence: `App/Workspace/DocumentWindow.swift`)
- Document canvas → HWP document model: edits and queries (evidence: `App/Workspace/DocumentCanvas.swift`)
- Ribbon controls → HWP document model: invokes commands (evidence: `App/Workspace/Ribbon.swift`)
- Document dialogs → HWP document model: configures document (evidence: `App/Workspace/Dialogs.swift`)
- Menu commands → HWP document model: dispatches commands
- Format sheets → HWP document model: sets formatting
- Style sheets → HWP document model: manages styles
- Object sheets → HWP document model: edits objects
- Code sheets → HWP document model: edits document codes (evidence: `App/Workspace/CodeSheets.swift`)
- Equation editor → HWP document model: inserts equations (evidence: `App/Workspace/EquationEditor.swift`)
- HWP document model → Edit session: sends edits (evidence: `App/Document/HwpDocument.swift`)
- HWP document model → Work barrier: tracks pending work (evidence: `App/Document/HwpDocument.swift`)
- HWP file → HWP document model: opens or saves
- Edit session → Engine ABI: calls engine
- Engine ABI → Edit commands: dispatches requests (evidence: `Engine/crates/hwp-engine-abi/src/editing/mod.rs`)
- Edit commands → Formatting operations: uses formatting (evidence: `Engine/crates/hwp-engine-abi/src/editing/commands.rs`)
- Edit commands → Sections and layout: uses section logic (evidence: `Engine/crates/hwp-engine-abi/src/editing/commands.rs`)
- Edit commands → Content preservation: checks preservation (evidence: `Engine/crates/hwp-engine-abi/src/editing/commands.rs`)
- Edit commands → Document codes: uses code helpers (evidence: `Engine/crates/hwp-engine-abi/src/editing/mod.rs`)
- Edit commands → Table cells: uses table helpers (evidence: `Engine/crates/hwp-engine-abi/src/editing/mod.rs`)
- Edit commands → Borders: uses border helpers
- Edit commands → Document objects: uses object helpers
- Edit commands → Form objects: uses form helpers
- Edit session → Page display output: produces page output
- Page display output → Page renderer: returns display data
- Page renderer → Page geometry: uses page coordinates (evidence: `App/Editing/PageDisplay.swift`)
- Finder Quick Look → Edit session: opens document (evidence: `Preview/PreviewProvider.swift`)
- Finder Quick Look → Page renderer: renders pages (evidence: `Preview/PreviewProvider.swift`)
