Skip to content

User profile

Purpose

Private per-user preferences (locale, birth date, notification channel toggles), kept 1:1 with the User record. Preferences only — the public-facing profile (bio, specializations, links, slug) lives on User public profile.

Business-level purpose: TBD by human.

Identity & key fields

  • Primary key: id (uuid, default gen_random_uuid()).
  • userId (uuid, NOT NULL, UNIQUE, FK → users.users.id, on-delete cascade).
  • language (nullable text) — preferred locale code.
  • birthDate (nullable date).
  • notificationsEnabled (boolean, default true) — master toggle.
  • pushEnabled (boolean, default true).
  • emailEnabled (boolean, default false).
  • createdAt, updatedAt (timestamps, NOT NULL).

business meaning: TBD by human

Invariants

  • userId is UNIQUE → at most one profile row per user (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/users.schema.ts).
  • userId ON DELETE CASCADE (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/users.schema.ts).
  • All notification flags NOT NULL with explicit defaults (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/users.schema.ts).

business invariants: TBD by human

Lifecycle

No explicit lifecycle — created lazily on first preference update or via signup hook.

Relationships

  • User (ENT-021) — userIdusers.users.id, UNIQUE, on-delete cascade. 1:1.
  • User public profile (ENT-042) — sibling 1:1 extension of the same User. Distinct table because the two carry different responsibilities: this row is private preferences, the public profile is what other users see.

API surfaces

SurfaceExposedNotes
clientyes — /me/notification-preferences, /me (via UpdateMeDto, UpdateNotificationPrefsDto)Swagger UI
businessno
super-adminno

Known gotchas / open questions

  • emailEnabled defaults to false while the other two channel toggles default to true — a quiet UX choice. Confirm with product whether this is intentional.
  • language is free-form text — no enum / locale-validity check at DB level.