Skip to content

Schema & Types

@life-manager/db has four distinct type and schema layers.

The offline database schema lives in packages/db/src/schema.ts and is exported as AppSchema from @life-manager/db/schema.

Relevant API pages:

The schema currently defines 20 tables.

  • profiles
  • settings
  • notification
  • appointment
  • work_project
  • work_project_tag
  • work_folder
  • work_time_entry
  • time_tracker
  • bank_account
  • tag
  • contact
  • finance_project
  • finance_project_adjustment
  • finance_project_tag
  • recurring_cashflow
  • recurring_cashflow_tag
  • single_cashflow
  • single_cashflow_tag
  • payout

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.

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:

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.

Choose the layer that matches your job:

  • use @life-manager/db/supabase for exact DB-level typing
  • use @life-manager/db/types/* for app/domain typing
  • use entity-local schema files or @life-manager/db/schemas for validation and deserialization
  • use AppSchema only when working on the runtime or collection bootstrap layer