# stffnb/edentext architecture

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

- Interactive diagram: https://gitdiagram.com/stffnb/edentext
- Repository: https://github.com/stffnb/edentext

## Overview

EdenText is a local-first word processor delivered as a browser app, with an optional Electron desktop shell. The main workflow is to open or create a document, edit its structured content in the page-layout editor, keep it locally, and save or export it. Review, proofing, templates, and optional AI add distinct capabilities around that workflow. The README and sampled imports establish the broad architecture; several feature modules were not excerpted, so their internal connections are shown only where documented.

Main entry points: [`src/App.svelte`](https://github.com/stffnb/edentext/blob/main/src/App.svelte) (App shell), [`src/lib/components/Editor.svelte`](https://github.com/stffnb/edentext/blob/main/src/lib/components/Editor.svelte) (TipTap editor), [`src/lib/editor/extensions`](https://github.com/stffnb/edentext/tree/main/src/lib/editor/extensions) (Document extensions), [`src/lib/import`](https://github.com/stffnb/edentext/tree/main/src/lib/import) (ODT/DOCX import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["App shell<br/>[App.svelte]"]
  node_desktop["Desktop shell<br/>[main.mjs]"]
  node_offline["Offline worker<br/>[sw.js]"]
  node_i18n["Localization<br/>[i18n.svelte.ts]"]
end

subgraph group_editing["Editing and layout"]
  node_editor["TipTap editor<br/>[Editor.svelte]"]
  node_extensions["Document extensions"]
  node_styles["Styles and layout<br/>[styleSheet.ts]"]
  node_styleui["Style manager"]
end

subgraph group_documents["Document lifecycle"]
  node_import["ODT/DOCX import"]
  node_export["File export"]
  node_files["Browser file APIs"]
  node_storage[("Local document storage<br/>[docScope.ts]")]
  node_crypto["Protected documents<br/>[protect.ts]"]
  node_templates["Templates<br/>[registry.ts]"]
end

subgraph group_features["Writing features"]
  node_review["Review tools<br/>[trackChanges.ts]"]
  node_reviewui["Review interface"]
  node_spell["Proofing tools<br/>[controller.ts]"]
  node_grammar["Grammar checking<br/>[grammar.svelte.ts]"]
  node_ai["AI assistant<br/>[client.ts]"]
end

node_user(("Writer"))
node_browser["Browser runtime"]
node_provider{{"Chosen AI provider"}}

node_user -->|"opens app"| node_browser
node_browser -->|"mounts"| node_app
node_user -.->|"launches"| node_desktop
node_app -->|"composes"| node_editor
node_editor -->|"edits with"| node_extensions
node_extensions -->|"uses styles"| node_styles
node_app -->|"opens documents"| node_import
node_import -->|"loads content"| node_editor
node_app -->|"exports documents"| node_export
node_export -->|"writes files"| node_files
node_app -->|"opens and saves"| node_files
node_editor -->|"persists locally"| node_storage
node_app -->|"manages document state"| node_storage
node_app -->|"protects files"| node_crypto
node_app -->|"offers templates"| node_templates
node_styleui -->|"updates styles"| node_styles
node_editor -->|"records revisions"| node_review
node_reviewui -->|"displays markup"| node_review
node_editor -->|"checks spelling"| node_spell
node_editor -->|"checks grammar"| node_grammar
node_app -.->|"offers assistant"| node_ai
node_ai -->|"sends requests"| node_provider
node_browser -->|"registers worker"| node_offline
node_app -->|"localizes interface"| node_i18n

click node_app "https://github.com/stffnb/edentext/blob/main/src/App.svelte"
click node_desktop "https://github.com/stffnb/edentext/blob/main/desktop/main.mjs"
click node_offline "https://github.com/stffnb/edentext/blob/main/public/sw.js"
click node_editor "https://github.com/stffnb/edentext/blob/main/src/lib/components/Editor.svelte"
click node_extensions "https://github.com/stffnb/edentext/tree/main/src/lib/editor/extensions"
click node_styles "https://github.com/stffnb/edentext/blob/main/src/lib/styles/styleSheet.ts"
click node_styleui "https://github.com/stffnb/edentext/blob/main/src/lib/components/StyleManagerDialog.svelte"
click node_import "https://github.com/stffnb/edentext/tree/main/src/lib/import"
click node_export "https://github.com/stffnb/edentext/tree/main/src/lib/export"
click node_storage "https://github.com/stffnb/edentext/blob/main/src/lib/storage/docScope.ts"
click node_crypto "https://github.com/stffnb/edentext/blob/main/src/lib/crypto/protect.ts"
click node_templates "https://github.com/stffnb/edentext/blob/main/src/lib/templates/registry.ts"
click node_review "https://github.com/stffnb/edentext/blob/main/src/lib/editor/extensions/trackChanges.ts"
click node_reviewui "https://github.com/stffnb/edentext/blob/main/src/lib/components/ReviewMarginLayer.svelte"
click node_spell "https://github.com/stffnb/edentext/blob/main/src/lib/spell/controller.ts"
click node_grammar "https://github.com/stffnb/edentext/blob/main/src/lib/spell/grammar.svelte.ts"
click node_ai "https://github.com/stffnb/edentext/blob/main/src/lib/ai/client.ts"
click node_i18n "https://github.com/stffnb/edentext/blob/main/src/lib/i18n/i18n.svelte.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_app,node_desktop,node_offline,node_i18n,node_browser toneBlue
class node_editor,node_extensions,node_styles,node_styleui toneAmber
class node_import,node_export,node_files,node_storage,node_crypto,node_templates toneMint
class node_review,node_reviewui,node_spell,node_grammar,node_ai toneRose
class node_user,node_provider toneIndigo
```

## Components

### Application

- [App shell](https://github.com/stffnb/edentext/blob/main/src/App.svelte): `src/App.svelte`
- [Desktop shell](https://github.com/stffnb/edentext/blob/main/desktop/main.mjs): `desktop/main.mjs`
- [Offline worker](https://github.com/stffnb/edentext/blob/main/public/sw.js): `public/sw.js`
- [Localization](https://github.com/stffnb/edentext/blob/main/src/lib/i18n/i18n.svelte.ts): `src/lib/i18n/i18n.svelte.ts`

### Editing and layout

- [TipTap editor](https://github.com/stffnb/edentext/blob/main/src/lib/components/Editor.svelte): `src/lib/components/Editor.svelte`
- [Document extensions](https://github.com/stffnb/edentext/tree/main/src/lib/editor/extensions): `src/lib/editor/extensions`
- [Styles and layout](https://github.com/stffnb/edentext/blob/main/src/lib/styles/styleSheet.ts): `src/lib/styles/styleSheet.ts`
- [Style manager](https://github.com/stffnb/edentext/blob/main/src/lib/components/StyleManagerDialog.svelte): `src/lib/components/StyleManagerDialog.svelte`

### Document lifecycle

- [ODT/DOCX import](https://github.com/stffnb/edentext/tree/main/src/lib/import): `src/lib/import`
- [File export](https://github.com/stffnb/edentext/tree/main/src/lib/export): `src/lib/export`
- **Browser file APIs**
- [Local document storage](https://github.com/stffnb/edentext/blob/main/src/lib/storage/docScope.ts): `src/lib/storage/docScope.ts`
- [Protected documents](https://github.com/stffnb/edentext/blob/main/src/lib/crypto/protect.ts): `src/lib/crypto/protect.ts`
- [Templates](https://github.com/stffnb/edentext/blob/main/src/lib/templates/registry.ts): `src/lib/templates/registry.ts`

### Writing features

- [Review tools](https://github.com/stffnb/edentext/blob/main/src/lib/editor/extensions/trackChanges.ts): `src/lib/editor/extensions/trackChanges.ts`
- [Review interface](https://github.com/stffnb/edentext/blob/main/src/lib/components/ReviewMarginLayer.svelte): `src/lib/components/ReviewMarginLayer.svelte`
- [Proofing tools](https://github.com/stffnb/edentext/blob/main/src/lib/spell/controller.ts): `src/lib/spell/controller.ts`
- [Grammar checking](https://github.com/stffnb/edentext/blob/main/src/lib/spell/grammar.svelte.ts): `src/lib/spell/grammar.svelte.ts`
- [AI assistant](https://github.com/stffnb/edentext/blob/main/src/lib/ai/client.ts): `src/lib/ai/client.ts`

### Other components

- **Writer**
- **Browser runtime**
- **Chosen AI provider**

## Connections

- Writer → Browser runtime: opens app (evidence: `README.md`)
- Browser runtime → App shell: mounts
- Writer → Desktop shell: launches
- App shell → TipTap editor: composes (evidence: `src/App.svelte`)
- TipTap editor → Document extensions: edits with (evidence: `README.md`)
- Document extensions → Styles and layout: uses styles (evidence: `src/lib/styles/styleSheet.ts`)
- App shell → ODT/DOCX import: opens documents (evidence: `src/App.svelte`)
- ODT/DOCX import → TipTap editor: loads content (evidence: `README.md`)
- App shell → File export: exports documents (evidence: `src/App.svelte`)
- File export → Browser file APIs: writes files (evidence: `README.md`)
- App shell → Browser file APIs: opens and saves (evidence: `README.md`)
- TipTap editor → Local document storage: persists locally (evidence: `README.md`)
- App shell → Local document storage: manages document state (evidence: `src/App.svelte`)
- App shell → Protected documents: protects files (evidence: `src/App.svelte`)
- App shell → Templates: offers templates (evidence: `README.md`)
- Style manager → Styles and layout: updates styles (evidence: `src/lib/components/StyleManagerDialog.svelte`)
- TipTap editor → Review tools: records revisions (evidence: `README.md`)
- Review interface → Review tools: displays markup (evidence: `src/lib/components/ReviewMarginLayer.svelte`)
- TipTap editor → Proofing tools: checks spelling (evidence: `README.md`)
- TipTap editor → Grammar checking: checks grammar (evidence: `README.md`)
- App shell → AI assistant: offers assistant
- AI assistant → Chosen AI provider: sends requests (evidence: `README.md`)
- Browser runtime → Offline worker: registers worker
- App shell → Localization: localizes interface (evidence: `src/lib/i18n/i18n.svelte.ts`)
