Monorepo Overview
This monorepo manages multiple applications using pnpm workspaces.
Project Structure
test-learn/
├── apps/
│ ├── tauri-app/ # Desktop application
│ │ ├── src/ # React frontend
│ │ │ ├── components/ # Reusable components (LexicalEditor, etc.)
│ │ │ ├── model/ # WatermelonDB models
│ │ │ ├── pages/ # Route pages
│ │ │ └── utils/ # Utilities (trpc, sync)
│ │ └── src-tauri/ # Rust backend
│ ├── cloudflare-d1-worker/ # Backend API
│ │ └── src/
│ │ ├── index.ts # Hono + tRPC entry
│ │ ├── trpc.ts # tRPC router
│ │ ├── db.ts # D1 helpers
│ │ └── ws-adapter.ts # WebSocket adapter
│ └── docs/ # This documentation
├── pnpm-workspace.yaml # Workspace config
└── package.json # Root scripts
Applications
1. Tauri App (apps/tauri-app)
A cross-platform desktop application.
| Technology | Purpose |
|---|---|
| Tauri 2 | Desktop runtime (Rust) |
| React 19 | UI framework |
| WatermelonDB | Offline-first database |
| Lexical.js | Rich text editor |
| Material UI | Component library |
Key Files:
src/model/db.ts- Database initializationsrc/model/Customer.ts- Data modelsrc/utils/sync.ts- Sync enginesrc/components/LexicalEditor.tsx- Rich text editor
2. Cloudflare D1 Worker (apps/cloudflare-d1-worker)
Serverless backend API.
| Technology | Purpose |
|---|---|
| Cloudflare Workers | Serverless runtime |
| Cloudflare D1 | SQLite database |
| Hono | REST API framework |
| tRPC | Type-safe RPC |
| Yjs | CRDT merging |
Key Files:
src/index.ts- Entry point (REST + tRPC + WebSocket)src/trpc.ts- tRPC router with sync endpointssrc/db.ts- Database operations with Yjs mergesrc/ws-adapter.ts- tRPC over WebSocket
3. Documentation (apps/docs)
This documentation site built with Docusaurus.
Workspace Commands
# Install all dependencies
pnpm install
# Run Tauri app
pnpm --filter tauri-app tauri dev
# Run Worker locally
pnpm --filter cloudflare-d1-worker dev
# Run docs
pnpm --filter apps-docs start
# Build all
pnpm -r build
Package Linking
The Tauri app imports types from the Worker for type-safe tRPC:
// apps/tauri-app/package.json
{
"dependencies": {
"cloudflare-d1-worker": "workspace:*"
}
}
This enables:
import type { AppRouter } from 'cloudflare-d1-worker';
Learn More
- Getting Started - Installation guide
- Architecture Overview - System design
- Sync Protocol - Offline-first sync