diff --git a/.claude/plans/local-first-architecture-migration.md b/.claude/plans/local-first-architecture-migration.md index b56d1bd4a..6605defd6 100644 --- a/.claude/plans/local-first-architecture-migration.md +++ b/.claude/plans/local-first-architecture-migration.md @@ -1,7 +1,8 @@ # Local-First Architektur & Stack-Migration -> **Status**: πŸ”΅ In Planung +> **Status**: 🟒 In Umsetzung (Phase 1-3 abgeschlossen) > **Erstellt**: 2026-03-26 +> **Zuletzt aktualisiert**: 2026-03-27 > **Autor**: Claude Code + Till Schneider > **Ziel**: Alle ManaCore-Apps auf Local-First umstellen, Backend-Stack modernisieren @@ -72,7 +73,7 @@ Dieser Plan beschreibt den Umbau der gesamten ManaCore-Architektur von einem kla --- -## Phase 1: Foundation (2-3 Wochen) +## Phase 1: Foundation (2-3 Wochen) β€” DONE 2026-03-27 ### 1.1 `@manacore/local-store` Package @@ -264,7 +265,7 @@ Die Todo-App wird als erste auf Local-First umgebaut: --- -## Phase 2: Todo komplett auf Hono/Bun (2-3 Wochen) +## Phase 2: Todo komplett auf Hono/Bun (2-3 Wochen) β€” DONE 2026-03-27 ### 2.1 Todo Backend: NestJS β†’ Hono/Bun @@ -312,7 +313,7 @@ apps/todo/apps/backend/ # Oder: services/todo/ (umstrukturieren?) --- -## Phase 3: Rollout auf alle Apps (4-6 Wochen) +## Phase 3: Rollout auf alle Apps (4-6 Wochen) β€” 6/8 DONE 2026-03-27 Reihenfolge nach KomplexitΓ€t: diff --git a/CLAUDE.md b/CLAUDE.md index 45d220244..665ba4102 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -502,10 +502,67 @@ let count = 0; $: doubled = count * 2; ``` +## Local-First Architecture + +All web apps use a **local-first** data layer: reads/writes go to IndexedDB (Dexie.js) first, sync to server in the background. This enables guest mode, offline CRUD, and instant UI. + +### Key Components + +| Component | Location | Purpose | +|-----------|----------|---------| +| `@manacore/local-store` | `packages/local-store/` | Dexie.js collections, sync engine, Svelte 5 reactive queries | +| `mana-sync` | `services/mana-sync/` | Go sync server (WebSocket push, field-level LWW conflict resolution) | +| Todo Hono Server | `apps/todo/apps/server/` | Lightweight compute server (RRULE, reminders, admin) on Bun | + +### Data Flow + +``` +Guest: App β†’ IndexedDB (Dexie.js) β†’ UI (no sync) +Logged in: App β†’ IndexedDB β†’ UI β†’ SyncEngine β†’ mana-sync (Go) β†’ PostgreSQL + ← WebSocket push ← +``` + +### Migrated Apps + +| App | Collections | Status | +|-----|------------|--------| +| Todo | tasks, projects, labels, taskLabels, reminders | Done | +| Zitare | favorites, lists | Done | +| Calendar | calendars, events | Done | +| Clock | alarms, timers, worldClocks | Done | +| Contacts | contacts | Done | +| ManaDeck | decks, cards | Done | +| Picture | β€” | Not yet | +| Presi | β€” | Not yet | + +### Dev Commands (Local-First Stack) + +```bash +pnpm dev:sync # Go sync server (port 3050) +pnpm dev:sync:build # Compile Go binary +pnpm dev:todo:server # Hono/Bun compute server (port 3019) +pnpm dev:todo:local # Web + sync + Hono (no auth/NestJS needed) +pnpm dev:todo:full # Everything incl. auth + NestJS legacy +``` + +### Adding Local-First to a New App + +1. Create `apps/{app}/apps/web/src/lib/data/local-store.ts` β€” define collections with `createLocalStore()` +2. Create `apps/{app}/apps/web/src/lib/data/guest-seed.ts` β€” onboarding data +3. Rewrite stores to use `collection.getAll()` / `collection.insert()` instead of API calls +4. In layout: `await store.initialize()`, `store.startSync()` on login, `allowGuest={true}` on AuthGate +5. Set `userEmail = ''` for guests so PillNav shows login button +6. Add `GuestWelcomeModal` for first-visit experience + +### Architecture Plan + +Full migration plan: `.claude/plans/local-first-architecture-migration.md` + ## Shared Packages (`packages/`) | Package | Purpose | | ------------------------------- | ----------------------------------------------- | +| `@manacore/local-store` | Local-first data layer (Dexie.js + sync engine) | | `@manacore/shared-nestjs-auth` | NestJS JWT validation guards via mana-core-auth | | `@mana-core/nestjs-integration` | NestJS module with auth guards + credit client | | `@manacore/shared-auth` | Client-side auth service for web/mobile apps |