Overview
Add cloud synchronization with offline-first architecture for Pro tier monetization.
Stack: Hono (API) + Neon (Postgres) + Stripe/Lemon Squeezy (payments)
New Packages
@readied/sync-core
Pure TypeScript sync logic:
src/
types.ts # SyncableEntity, SyncChange, SyncConflict
operations.ts # push(), pull(), merge()
conflict.ts # ConflictResolver (last-write-wins)
queue.ts # OfflineQueue
@readied/api
Hono backend:
src/
index.ts
routes/
auth.ts # Magic link authentication
notes.ts # GET/POST /sync
subscription.ts # Stripe webhooks
middleware/auth.ts # JWT verification
db/schema.ts # Drizzle schema
API Endpoints
| Method |
Path |
Description |
| POST |
/auth/magic-link |
Send magic link email |
| POST |
/auth/verify |
Verify token, return JWT |
| GET |
/notes/sync?cursor=X |
Pull changes since cursor |
| POST |
/notes/sync |
Push local changes |
| POST |
/subscription/webhook |
Stripe/Lemon Squeezy |
Local SQLite Migration
ALTER TABLE notes ADD COLUMN device_id TEXT;
ALTER TABLE notes ADD COLUMN sync_version INTEGER DEFAULT 0;
ALTER TABLE notes ADD COLUMN last_synced_at TEXT;
CREATE TABLE sync_queue (
id INTEGER PRIMARY KEY,
entity_type TEXT,
entity_id TEXT,
operation TEXT,
data TEXT,
timestamp TEXT,
synced INTEGER DEFAULT 0
);
CREATE TABLE sync_metadata (key TEXT PRIMARY KEY, value TEXT);
Desktop UI Components
syncStore.ts - Zustand store for sync state
SyncStatusIndicator.tsx - Cloud icon with status
ConflictResolutionModal.tsx - Resolve conflicts
LoginModal.tsx - Auth flow
Dependencies
"hono": "^4.0.0",
"@hono/zod-validator": "^0.2.0",
"drizzle-orm": "^0.29.0",
"@neondatabase/serverless": "^0.7.0",
"jose": "^5.2.0"
Estimate
~90 hours (11-12 days)
Pre-requisites
Acceptance Criteria
Overview
Add cloud synchronization with offline-first architecture for Pro tier monetization.
Stack: Hono (API) + Neon (Postgres) + Stripe/Lemon Squeezy (payments)
New Packages
@readied/sync-corePure TypeScript sync logic:
@readied/apiHono backend:
API Endpoints
/auth/magic-link/auth/verify/notes/sync?cursor=X/notes/sync/subscription/webhookLocal SQLite Migration
Desktop UI Components
syncStore.ts- Zustand store for sync stateSyncStatusIndicator.tsx- Cloud icon with statusConflictResolutionModal.tsx- Resolve conflictsLoginModal.tsx- Auth flowDependencies
Estimate
~90 hours (11-12 days)
Pre-requisites
Acceptance Criteria