Skip to content

Open source personal finance application

docs(claude): update client data-layer notes for lazy powersync modules

Ilya Komichev25b2ed0c3396
diff --git a/CLAUDE.md b/CLAUDE.md
index fa5eb0b8..b78a86e9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -37,7 +37,7 @@ Personal finance app. Nuxt 4, Vue 3, Pinia, @nuxt/ui v4 (Tailwind CSS v4), Supab
### Client data layer
-- `app/services/powersync/` - `AppSchema.ts` (client SQLite schema), `db.ts` (the `PowerSyncDatabase` singleton + `connectPowerSync` / `watchTable` / `waitForFirstSync`), `connector.ts` (`SupabaseConnector`: `fetchCredentials` + `uploadData`), `transforms.ts` (row↔item: booleans 0/1, `parentId` null↔0, `rates` JSON), `mutations.ts` (`upsertRow` / `deleteRow` - INSERT/UPDATE, never `ON CONFLICT`, since PowerSync tables are views).
+- `app/services/powersync/` - `AppSchema.ts` (client SQLite schema), `db.ts` (lazy `getPowerSyncDb()` singleton - dynamically imports `@powersync/web` to keep it out of the entry chunk - plus `connectPowerSync` / `watchTable` / `waitForFirstSync`), `connector.ts` (`SupabaseConnector`: `fetchCredentials` + `uploadData`; reachable only via the dynamic import in db.ts), `uploadReconcile.ts` + `uploadErrorHandler.ts` (auto-reconcile of fatally rejected uploads), `transforms.ts` (row↔item: booleans 0/1, `parentId` null↔0, `rates` JSON), `mutations.ts` (`upsertRow` / `deleteRow` / `deleteTrnsReferencing` - INSERT/UPDATE, never `ON CONFLICT`, since PowerSync tables are views).
- `app/app/composables/useSupabase.ts` - the supabase-js client + `useSupabaseAuth()` (reactive session, `signInWithPassword` / `signUp` / `signInWithGoogle` / `signOut`). `detectSessionInUrl: true` so the Google OAuth PKCE `?code=` is exchanged on return to `/login` (handled in `login.vue`).
- `app/app/plugins/powersync.client.ts` - eagerly opens local SQLite for an already-logged-in user, then connects/disconnects PowerSync as the auth session (`uid`) resolves. The synchronous route-guard gate is `hasPersistedSession()` (`app/app/composables/useAuthSession.ts`), which reads the persisted Supabase session from localStorage directly - no cookie.
- Stores hydrate via `db.watch('SELECT * FROM ...')` (one subscription handles both initial load and realtime, local + synced) and write via `upsertRow`/`deleteRow`. Demo mode bypasses PowerSync and uses in-memory + localforage.