Architecture Overview
This document provides a high-level view of the system architecture.
System Context Diagram
High-Level Architecture
Technology Stack
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React 19 | UI Components |
| Tauri 2 | Desktop runtime (Rust) | |
| WatermelonDB | Offline-first local database | |
| Lexical.js | Rich text editor | |
| Material UI | Component library | |
| Backend | Cloudflare Workers | Serverless runtime |
| Cloudflare D1 | SQLite database | |
| Hono | REST API framework | |
| tRPC | Type-safe RPC | |
| Sync | Custom Protocol | Pull/Push sync |
| Yjs | CRDT for text collaboration | |
| Communication | HTTP | REST & tRPC queries |
| WebSocket | Real-time tRPC |
Data Flow
Key Concepts
Offline-First
The app works completely offline. All data is stored locally in WatermelonDB (SQLite). When online, changes sync bidirectionally with the server.
Type Safety
tRPC provides end-to-end type safety. Types defined in the Worker are automatically available in the Tauri app via workspace linking.
CRDT Collaboration
Rich text fields use Yjs (CRDT) for conflict-free merging. Multiple users can edit the same document, and changes are merged on the server.
Next Steps
- Frontend Stack - React, Tauri, WatermelonDB, Lexical
- Backend Stack - Workers, D1, Hono, tRPC
- Communication - REST vs tRPC vs WebSocket
- Sync Protocol - Offline-first sync architecture
- CRDT Collaboration - Yjs and conflict resolution