Mobile Data Layer
Shared DB Package
Section titled “Shared DB Package”All schema definitions, Supabase types, and domain types come from @life-manager/db:
import { AppSchema } from "@life-manager/db/schema";import { Tables } from "@life-manager/db/supabase";import { Profile, ProfileUpdate } from "@life-manager/db/types/profile.types";See the Data Flow page for the full schema reference and domain type listing.
Collections Pattern
Section titled “Collections Pattern”Same file pattern as the web app:
db/collections/[entity]/ [entity]-collection.ts # TanStack DB createCollection [entity]-schema.ts # Zod validation schema [entity]-mutations.ts # CRUD operations use-[entity]-query.ts # React hook for live queries use-[entity]-mutations.ts # React hook for mutationsCurrently implemented: profile/ collection only. Add more collections as features are built.
PowerSync Setup
Section titled “PowerSync Setup”| Component | Details |
|---|---|
| Schema | Shared from @life-manager/db/schema (platform-agnostic) |
| Connector | src/db/powersync/Connector.ts (mobile-specific, uses @supabase/ssr) |
| DB instance | src/db/powersync/db.ts (uses @powersync/op-sqlite for native SQLite) |
Supabase
Section titled “Supabase”- Client:
src/db/supabase.ts - Types regenerated via
bun run generate-typesfrom root