# ptsfdtz/litemark architecture

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

- Interactive diagram: https://gitdiagram.com/ptsfdtz/litemark
- Repository: https://github.com/ptsfdtz/litemark

## Overview

LiteMark is a Tauri desktop Markdown editor. The main workflow is opening or creating a workspace document, editing Markdown, previewing it live, and saving it safely; workspace browsing, export, settings, themes, and an optional AI agent are additional capabilities. The graph preserves the agent’s UI-to-runtime stages and document persistence boundaries. Some links are grounded only in README or SOURCE INDEX references; unsampled modules are not treated as inspected.

Main entry points: [`src/components/Layout/Layout.tsx`](https://github.com/ptsfdtz/litemark/blob/main/src/components/Layout/Layout.tsx) (Workspace layout), [`src/components/Editor/Editor.tsx`](https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/Editor.tsx) (Markdown editor), [`src-tauri/src/agent/run.rs`](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/run.rs) (Agent orchestration), [`src-tauri/src/lib.rs`](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/lib.rs) (Tauri runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_app["Application shell<br/>[App.tsx]"]
  node_layout["Workspace layout<br/>[Layout.tsx]"]
  node_toolbar["Editing toolbar<br/>[Toolbar.tsx]"]
  node_settings["Settings &amp; themes<br/>[Settings.tsx]"]
  node_theme_store[("Theme persistence<br/>[themeStore.ts]")]
end

subgraph group_documents["Documents &amp; workspace"]
  node_doc_session["Document session"]
  node_session_adapter["Tauri document adapter"]
  node_explorer["File explorer<br/>[FileExplorer.tsx]"]
  node_directory["Directory operations<br/>[directoryTree.ts]"]
  node_recent[("Recent documents<br/>[recentStore.ts]")]
end

subgraph group_writing["Writing &amp; preview"]
  node_editor["Markdown editor<br/>[Editor.tsx]"]
  node_markdown["Markdown editing rules"]
  node_preview["Live preview<br/>[Preview.tsx]"]
  node_export["Document export<br/>[exportDocument.ts]"]
  node_image_preview["Image preview<br/>[ImagePreview.tsx]"]
  node_pdf_preview["PDF preview<br/>[PdfPreview.tsx]"]
end

subgraph group_agent["AI agent"]
  node_agent_panel["Agent panel<br/>[AgentPanel.tsx]"]
  node_agent_session["Agent session<br/>[useAgentSession.ts]"]
  node_conversations["Conversation history"]
  node_agent_client["Agent client<br/>[agentClient.ts]"]
  node_agent_protocol["Agent protocol<br/>[protocol.rs]"]
  node_agent_run["Agent orchestration<br/>[run.rs]"]
  node_agent_tools["Agent tools<br/>[mod.rs]"]
  node_agent_filesystem["Filesystem tools<br/>[filesystem.rs]"]
  node_agent_search["Workspace search<br/>[search.rs]"]
  node_agent_repository[("Change checkpoints<br/>[repository.rs]")]
end

subgraph group_native["Tauri services"]
  node_storage[("Document storage")]
  node_tauri["Tauri runtime<br/>[lib.rs]"]
end

node_user(("Writer"))

node_user -->|"opens app"| node_app
node_app -->|"renders"| node_layout
node_layout -->|"renders"| node_toolbar
node_layout -->|"renders"| node_settings
node_layout -.->|"manages documents"| node_doc_session
node_layout -->|"renders"| node_explorer
node_layout -->|"lists workspace"| node_directory
node_layout -->|"saves theme"| node_theme_store
node_doc_session -.->|"uses storage adapter"| node_session_adapter
node_session_adapter -->|"updates recents"| node_recent
node_session_adapter -.->|"invokes native storage"| node_tauri
node_tauri -->|"uses storage"| node_storage
node_layout -->|"renders"| node_editor
node_editor -.->|"applies transforms"| node_markdown
node_layout -.->|"renders"| node_preview
node_layout -->|"exports document"| node_export
node_editor -.->|"shows images"| node_image_preview
node_editor -.->|"shows PDFs"| node_pdf_preview
node_layout -.->|"hosts agent"| node_agent_panel
node_agent_panel -->|"drives session"| node_agent_session
node_agent_panel -->|"manages conversations"| node_conversations
node_agent_session -->|"runs turns"| node_agent_client
node_agent_client -.->|"invokes agent commands"| node_tauri
node_tauri -->|"registers agent runtime"| node_agent_run
node_agent_run -.->|"uses event protocol"| node_agent_protocol
node_agent_run -.->|"dispatches tools"| node_agent_tools
node_agent_tools -.->|"dispatches filesystem"| node_agent_filesystem
node_agent_tools -.->|"dispatches search"| node_agent_search
node_agent_filesystem -->|"uses document storage"| node_storage
node_agent_search -->|"uses document storage"| node_storage
node_agent_run -.->|"records changes"| node_agent_repository
node_agent_repository -->|"reads and restores files"| node_storage

click node_app "https://github.com/ptsfdtz/litemark/blob/main/src/App.tsx"
click node_layout "https://github.com/ptsfdtz/litemark/blob/main/src/components/Layout/Layout.tsx"
click node_toolbar "https://github.com/ptsfdtz/litemark/blob/main/src/components/Toolbar/Toolbar.tsx"
click node_settings "https://github.com/ptsfdtz/litemark/blob/main/src/components/Settings/Settings.tsx"
click node_doc_session "https://github.com/ptsfdtz/litemark/blob/main/src/modules/documentSession/useDocumentSession.ts"
click node_session_adapter "https://github.com/ptsfdtz/litemark/blob/main/src/modules/documentSession/tauriDocumentSession.ts"
click node_storage "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/document_storage.rs"
click node_explorer "https://github.com/ptsfdtz/litemark/blob/main/src/components/FileExplorer/FileExplorer.tsx"
click node_directory "https://github.com/ptsfdtz/litemark/blob/main/src/modules/directoryTree.ts"
click node_recent "https://github.com/ptsfdtz/litemark/blob/main/src/utils/recentStore.ts"
click node_editor "https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/Editor.tsx"
click node_markdown "https://github.com/ptsfdtz/litemark/blob/main/src/modules/markdownEditing/markdownTransforms.ts"
click node_preview "https://github.com/ptsfdtz/litemark/blob/main/src/components/Preview/Preview.tsx"
click node_export "https://github.com/ptsfdtz/litemark/blob/main/src/modules/exportDocument.ts"
click node_agent_panel "https://github.com/ptsfdtz/litemark/blob/main/src/components/AgentPanel/AgentPanel.tsx"
click node_agent_session "https://github.com/ptsfdtz/litemark/blob/main/src/modules/agent/useAgentSession.ts"
click node_conversations "https://github.com/ptsfdtz/litemark/blob/main/src/modules/agent/useAgentConversations.ts"
click node_agent_client "https://github.com/ptsfdtz/litemark/blob/main/src/modules/agent/agentClient.ts"
click node_agent_protocol "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/protocol.rs"
click node_agent_run "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/run.rs"
click node_agent_tools "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/tools/mod.rs"
click node_agent_filesystem "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/tools/filesystem.rs"
click node_agent_search "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/tools/search.rs"
click node_agent_repository "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/repository.rs"
click node_tauri "https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/lib.rs"
click node_image_preview "https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/ImagePreview.tsx"
click node_pdf_preview "https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/PdfPreview.tsx"
click node_theme_store "https://github.com/ptsfdtz/litemark/blob/main/src/utils/themeStore.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_layout,node_toolbar,node_settings,node_theme_store toneBlue
class node_doc_session,node_session_adapter,node_explorer,node_directory,node_recent toneAmber
class node_editor,node_markdown,node_preview,node_export,node_image_preview,node_pdf_preview toneMint
class node_agent_panel,node_agent_session,node_conversations,node_agent_client,node_agent_protocol,node_agent_run,node_agent_tools,node_agent_filesystem,node_agent_search,node_agent_repository toneRose
class node_storage,node_tauri,node_user toneIndigo
```

## Components

### App shell

- [Application shell](https://github.com/ptsfdtz/litemark/blob/main/src/App.tsx): `src/App.tsx`
- [Workspace layout](https://github.com/ptsfdtz/litemark/blob/main/src/components/Layout/Layout.tsx): `src/components/Layout/Layout.tsx`
- [Editing toolbar](https://github.com/ptsfdtz/litemark/blob/main/src/components/Toolbar/Toolbar.tsx): `src/components/Toolbar/Toolbar.tsx`
- [Settings & themes](https://github.com/ptsfdtz/litemark/blob/main/src/components/Settings/Settings.tsx): `src/components/Settings/Settings.tsx`
- [Theme persistence](https://github.com/ptsfdtz/litemark/blob/main/src/utils/themeStore.ts): `src/utils/themeStore.ts`

### Documents & workspace

- [Document session](https://github.com/ptsfdtz/litemark/blob/main/src/modules/documentSession/useDocumentSession.ts): `src/modules/documentSession/useDocumentSession.ts`
- [Tauri document adapter](https://github.com/ptsfdtz/litemark/blob/main/src/modules/documentSession/tauriDocumentSession.ts): `src/modules/documentSession/tauriDocumentSession.ts`
- [File explorer](https://github.com/ptsfdtz/litemark/blob/main/src/components/FileExplorer/FileExplorer.tsx): `src/components/FileExplorer/FileExplorer.tsx`
- [Directory operations](https://github.com/ptsfdtz/litemark/blob/main/src/modules/directoryTree.ts): `src/modules/directoryTree.ts`
- [Recent documents](https://github.com/ptsfdtz/litemark/blob/main/src/utils/recentStore.ts): `src/utils/recentStore.ts`

### Writing & preview

- [Markdown editor](https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/Editor.tsx): `src/components/Editor/Editor.tsx`
- [Markdown editing rules](https://github.com/ptsfdtz/litemark/blob/main/src/modules/markdownEditing/markdownTransforms.ts): `src/modules/markdownEditing/markdownTransforms.ts`
- [Live preview](https://github.com/ptsfdtz/litemark/blob/main/src/components/Preview/Preview.tsx): `src/components/Preview/Preview.tsx`
- [Document export](https://github.com/ptsfdtz/litemark/blob/main/src/modules/exportDocument.ts): `src/modules/exportDocument.ts`
- [Image preview](https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/ImagePreview.tsx): `src/components/Editor/ImagePreview.tsx`
- [PDF preview](https://github.com/ptsfdtz/litemark/blob/main/src/components/Editor/PdfPreview.tsx): `src/components/Editor/PdfPreview.tsx`

### AI agent

- [Agent panel](https://github.com/ptsfdtz/litemark/blob/main/src/components/AgentPanel/AgentPanel.tsx): `src/components/AgentPanel/AgentPanel.tsx`
- [Agent session](https://github.com/ptsfdtz/litemark/blob/main/src/modules/agent/useAgentSession.ts): `src/modules/agent/useAgentSession.ts`
- [Conversation history](https://github.com/ptsfdtz/litemark/blob/main/src/modules/agent/useAgentConversations.ts): `src/modules/agent/useAgentConversations.ts`
- [Agent client](https://github.com/ptsfdtz/litemark/blob/main/src/modules/agent/agentClient.ts): `src/modules/agent/agentClient.ts`
- [Agent protocol](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/protocol.rs): `src-tauri/src/agent/protocol.rs`
- [Agent orchestration](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/run.rs): `src-tauri/src/agent/run.rs`
- [Agent tools](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/tools/mod.rs): `src-tauri/src/agent/tools/mod.rs`
- [Filesystem tools](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/tools/filesystem.rs): `src-tauri/src/agent/tools/filesystem.rs`
- [Workspace search](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/tools/search.rs): `src-tauri/src/agent/tools/search.rs`
- [Change checkpoints](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/agent/repository.rs): `src-tauri/src/agent/repository.rs`

### Tauri services

- [Document storage](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/document_storage.rs): `src-tauri/src/document_storage.rs`
- [Tauri runtime](https://github.com/ptsfdtz/litemark/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`

### Other components

- **Writer**

## Connections

- Writer → Application shell: opens app (evidence: `README.md`)
- Application shell → Workspace layout: renders (evidence: `src/App.tsx`)
- Workspace layout → Editing toolbar: renders (evidence: `src/components/Layout/Layout.tsx`)
- Workspace layout → Settings & themes: renders (evidence: `src/components/Layout/Layout.tsx`)
- Workspace layout → Document session: manages documents (evidence: `src/components/Layout/Layout.tsx`)
- Workspace layout → File explorer: renders (evidence: `src/components/Layout/Layout.tsx`)
- Workspace layout → Directory operations: lists workspace (evidence: `src/components/Layout/Layout.tsx`)
- Workspace layout → Theme persistence: saves theme (evidence: `src/components/Layout/Layout.tsx`)
- Document session → Tauri document adapter: uses storage adapter (evidence: `src/modules/documentSession/tauriDocumentSession.ts`)
- Tauri document adapter → Recent documents: updates recents (evidence: `src/modules/documentSession/tauriDocumentSession.ts`)
- Tauri document adapter → Tauri runtime: invokes native storage
- Tauri runtime → Document storage: uses storage (evidence: `src-tauri/src/lib.rs`)
- Workspace layout → Markdown editor: renders (evidence: `src/components/Layout/Layout.tsx`)
- Markdown editor → Markdown editing rules: applies transforms
- Workspace layout → Live preview: renders (evidence: `src/components/Layout/Layout.tsx`)
- Workspace layout → Document export: exports document (evidence: `src/components/Layout/Layout.tsx`)
- Markdown editor → Image preview: shows images
- Markdown editor → PDF preview: shows PDFs
- Workspace layout → Agent panel: hosts agent (evidence: `src/components/Layout/Layout.tsx`)
- Agent panel → Agent session: drives session (evidence: `src/components/AgentPanel/AgentPanel.tsx`)
- Agent panel → Conversation history: manages conversations (evidence: `src/components/AgentPanel/AgentPanel.tsx`)
- Agent session → Agent client: runs turns (evidence: `src/modules/agent/useAgentSession.ts`)
- Agent client → Tauri runtime: invokes agent commands
- Tauri runtime → Agent orchestration: registers agent runtime (evidence: `src-tauri/src/lib.rs`)
- Agent orchestration → Agent protocol: uses event protocol
- Agent orchestration → Agent tools: dispatches tools
- Agent tools → Filesystem tools: dispatches filesystem
- Agent tools → Workspace search: dispatches search
- Filesystem tools → Document storage: uses document storage (evidence: `src-tauri/src/agent/tools/filesystem.rs`)
- Workspace search → Document storage: uses document storage (evidence: `src-tauri/src/agent/tools/search.rs`)
- Agent orchestration → Change checkpoints: records changes
- Change checkpoints → Document storage: reads and restores files (evidence: `src-tauri/src/agent/repository.rs`)
