Architecture
memrynote is a pnpm + Turborepo monorepo with an Electron desktop app, a Cloudflare Workers sync server, and shared TypeScript packages.
Top-Level Map
| Path | Purpose |
|---|---|
apps/desktop | Electron 39 + React 19 + Vite. Main / renderer / preload. |
apps/sync-server | Cloudflare Workers + Hono. D1 + R2. |
apps/docs | This documentation site (VitePress). |
packages/contracts | IPC and API contracts (Zod). |
packages/db-schema | Drizzle ORM schemas. |
packages/shared | Shared utilities. |
Trust Boundary
The user's device is trusted. The server is not. Everything that leaves the device is encrypted; the server stores ciphertext and serves it back.
Local Storage
Two SQLite databases via better-sqlite3 + Drizzle:
- Data DB — notes, journals, tasks, projects, inbox, templates, settings.
- Index DB — full-text search, link graph, embedding vectors.
Sync
- D1: encrypted sync item metadata (vector clocks, blob keys, hashes).
- R2: encrypted payload blobs (avoids the 1 MB D1 row limit).
- Hybrid sync: bulk snapshots through
SyncItemHandlerplus incremental Yjs updates through/sync/crdt/updates.
→ Sync Protocol · CRDT & Notes Sync · Sync Item Handlers
Cryptography
XChaCha20-Poly1305 + Ed25519 + Argon2id, all via libsodium. Per-device sealing of the vault key. Constant-time comparisons.
IPC Boundary
Shared Zod contracts in packages/contracts. Validated at typecheck time via pnpm ipc:check.
Observability
Local logging via electron-log; switchable telemetry that ships only enums and surface names.
Verification Gates
bash
pnpm lint
pnpm typecheck
pnpm test
pnpm ipc:check