Schema & Types
@life-manager/db has four distinct type and schema layers.
1. PowerSync Schema
Section titled “1. PowerSync Schema”The offline database schema lives in packages/db/src/schema.ts and is exported as AppSchema from @life-manager/db/schema.
Relevant API pages:
Current Tables
Section titled “Current Tables”The schema currently defines 20 tables.
System
Section titled “System”profilessettingsnotification
appointmentwork_projectwork_project_tagwork_folderwork_time_entrytime_tracker
Finance
Section titled “Finance”bank_accounttagcontactfinance_projectfinance_project_adjustmentfinance_project_tagrecurring_cashflowrecurring_cashflow_tagsingle_cashflowsingle_cashflow_tagpayout
2. Supabase-generated DB Types
Section titled “2. Supabase-generated DB Types”The generated database types live in packages/db/src/supabase.types.ts and are exposed through @life-manager/db/supabase.
Use these when you need exact table-level types such as:
Tables<"...">TablesInsert<"...">TablesUpdate<"...">Enums<"...">
This is the lowest-level typed interface to the underlying database model.
3. Domain Type Barrels
Section titled “3. Domain Type Barrels”The package exposes domain-oriented type barrels:
@life-manager/db/types/work@life-manager/db/types/finance@life-manager/db/types/system
These are mostly re-exports of entity-local types and are the preferred app-facing type layer.
Example API pages:
4. Validation / Deserialization Schemas
Section titled “4. Validation / Deserialization Schemas”Each entity owns local Zod schemas in <entity>.schema.ts.
Those schemas are used when building collections in createAllCollections() so the offline layer can:
- validate incoming records
- deserialize DB values into domain shapes
- reject malformed local or synced rows
The compatibility barrel @life-manager/db/schemas re-exports these schemas.
Practical Rule
Section titled “Practical Rule”Choose the layer that matches your job:
- use
@life-manager/db/supabasefor exact DB-level typing - use
@life-manager/db/types/*for app/domain typing - use entity-local schema files or
@life-manager/db/schemasfor validation and deserialization - use
AppSchemaonly when working on the runtime or collection bootstrap layer