How zarishsphere/zs-note works
Purpose and Runtime Topology
ZarishNote is a local-first desktop Markdown note editor: a Svelte WebView frontend communicates with a Rust Tauri v2 host for privileged operations. A separate Python CLI converts external documents to Markdown. Main runtime entry points are src/main.ts, src-tauri/src/main.rs, src-tauri/src/lib.rs, and ingestion/src/zarishnote_ingest/cli.py.
Frontend Application and Editor
The Svelte 5 UI root assembles the workspace, panels, and modal-driven workflows in src/lib/components/App.svelte. Editor orchestration supports WYSIWYG, source, and split modes through src/lib/components/Editor.svelte, src/lib/components/MilkdownEditor.svelte, and src/lib/components/SourceEditor.svelte. Milkdown/ProseMirror setup is isolated in src/lib/milkdown/setup.ts; frontend stores own reactive editor, file, AI, config, MCP, plugin, and collaboration state under src/lib/stores/.
Tauri Command Boundary
Frontend actions cross the WebView/native boundary through typed invoke wrappers in src/lib/commands/ and Rust Tauri handlers registered through src-tauri/src/commands/mod.rs. Command modules form the backend API for editor/file work, AI, import/ingestion, sandboxing, Git, MCP, search, publishing, voice, plugins, and configuration; representative paths are src-tauri/src/commands/editor.rs, src-tauri/src/commands/ai.rs, and src-tauri/src/commands/ingest.rs. Tauri capability permissions constrain exposed operations in src-tauri/capabilities/default.json.
Local Vault, Versioning, and Knowledge Flow
The editor and file tree operate on vault content through backend file CRUD, while Git services provide commits, history, and synchronization through src-tauri/src/git/mod.rs, src-tauri/src/git/history.rs, and src-tauri/src/git/sync.rs. Imported content flows from a frontend import action to the Rust ingestion command, launches the Python engine, then returns Markdown for vault/editor use. Local semantic retrieval indexes and queries content via src-tauri/src/vector/index.rs and src-tauri/src/vector/query.rs; the documented store is in-memory with fastembed.
AI, MCP, and Sandboxed Execution
AI chat is presented by src/lib/components/AIPanel.svelte and dispatched through the AI command layer to provider adapters: src-tauri/src/ai/openai.rs, src-tauri/src/ai/claude.rs, src-tauri/src/ai/gemini.rs, and local Ollama support. MCP integration separates protocol, transports, routing, and marketplace concerns in src-tauri/src/mcp/protocol.rs, src-tauri/src/mcp/transport.rs, and src-tauri/src/mcp/router.rs. AI tools, MCP servers, and plugins are intended to execute behind the Wasmtime boundary, whose executor, capability policy, network controls, state, and tool calls reside in src-tauri/src/sandbox/executor.rs, src-tauri/src/sandbox/capability.rs, and src-tauri/src/sandbox/network.rs.
Ingestion Pipeline
The Python package detects MIME/charset, chooses a converter, and normalizes supported inputs to Markdown. Its CLI and MarkItDown integration are in ingestion/src/zarishnote_ingest/cli.py and ingestion/src/zarishnote_ingest/markitdown.py; format-specific conversion implementations live under ingestion/src/zarishnote_ingest/converters/, including PDF, Office, HTML, notebooks, feeds, and web sources. This is a process boundary from Rust rather than an embedded library.
External Infrastructure and Delivery
Primary external services are configurable AI providers (OpenAI, Claude, Gemini, Ollama), MCP stdio/HTTP servers, Git/GitHub publishing, and optional Cloudflare real-time relay infrastructure at cloudflare/realtime-worker/src/index.ts and cloudflare/realtime-worker/src/relay.ts. Native desktop packaging is governed by src-tauri/tauri.conf.json; generated Android and Apple artifacts indicate mobile targets. GitHub Actions under .github/workflows/ builds, tests, releases, deploys Cloudflare, and publishes Pages.
Main entry points: mod.rs Command API · App.svelte Workspace UI · Editor.svelte Editor modes · router.rs MCP router
Components 22
Svelte WebView
- Workspace UI · Assembles workspace, panels, and modal workflows.
src/lib/components/App.svelte - Editor modes · Coordinates WYSIWYG, source, and split editing.
src/lib/components/Editor.svelte - Milkdown editor
src/lib/components/MilkdownEditor.svelte - Source editor
src/lib/components/SourceEditor.svelte - Reactive stores · Holds editor, file, AI, configuration, MCP, plugin, and collaboration state.
src/lib/stores/editor.svelte.ts - Typed invoke API
src/lib/commands/editor.ts - AI panel
src/lib/components/AIPanel.svelte
Tauri host
- Tauri application · Registers the native application and command handlers.
src-tauri/src/lib.rs - Command API · Backend API for files, AI, ingestion, Git, MCP, search, plugins, and configuration.
src-tauri/src/commands/mod.rs - Local vault · Local-first note content accessed through backend file CRUD.
- Git versioning
src-tauri/src/git/mod.rs - Semantic retrieval · Indexes and queries vault content with fastembed.
src-tauri/src/vector/index.rs - AI adapters · Dispatches requests to OpenAI, Claude, Gemini, or Ollama.
src-tauri/src/ai/openai.rs - MCP router · Connects protocol and transport handling to MCP servers.
src-tauri/src/mcp/router.rs - Wasmtime sandbox · Applies capabilities and network controls to tools, MCP servers, and plugins.
src-tauri/src/sandbox/executor.rs - Ingestion command · Launches the external converter and returns Markdown.
src-tauri/src/commands/ingest.rs
Python ingestion process
- Ingestion CLI · Detects inputs and selects a Markdown conversion path.
ingestion/src/zarishnote_ingest/cli.py - Format converters · Converts PDF, Office, HTML, notebooks, feeds, and web sources.
ingestion/src/zarishnote_ingest/markitdown.py
External services
- AI providers · OpenAI, Claude, Gemini, and Ollama.
- MCP servers
- Git and GitHub
- Realtime relay · Optional collaboration relay infrastructure.
cloudflare/realtime-worker/src/relay.ts
Connections 24
- Workspace UI → Editor modes: hosts
- Editor modes → Milkdown editor: WYSIWYG mode
- Editor modes → Source editor: source mode
- Workspace UI → Reactive stores: reads and updates
- Workspace UI → Typed invoke API: native actions
- AI panel → Typed invoke API: AI requests
- Typed invoke API → Command API: Tauri invoke
- Tauri application → Command API: registers
- Command API → Local vault: file CRUD
- Command API → Git versioning: history and sync
- Local vault → Semantic retrieval: indexed for retrieval
- Command API → Semantic retrieval: search queries
- Command API → AI adapters: AI dispatch
- AI adapters → AI providers: provider calls
- Command API → MCP router: MCP operations
- MCP router → MCP servers: stdio or HTTP
- MCP router → Wasmtime sandbox: tool execution
- Command API → Wasmtime sandbox: plugins and tools
- Command API → Ingestion command: import request
- Ingestion command → Ingestion CLI: spawns process · Python runs outside the Rust host process.
- Ingestion CLI → Format converters: selects converter
- Ingestion command → Local vault: Markdown result
- Git versioning → Git and GitHub: sync and publish
- Reactive stores → Realtime relay: optional collaboration