Skip to content

User activity favorite

Purpose

TBD by human

Identity & key fields

  • Primary key: id (uuid, default gen_random_uuid()).
  • userId (uuid, FK → users.users.id, on-delete cascade).
  • activityId (uuid, FK → activities.activities.id, on-delete cascade).
  • createdAt (timestamptz, default now()).

business meaning: TBD by human

Invariants

  • UNIQUE on (userId, activityId) via user_activity_favorites_user_activity_unique — a user cannot favorite the same activity twice (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/activities.schema.ts).
  • Both FKs ON DELETE CASCADE (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/activities.schema.ts).
  • Indexes: user_activity_favorites_user_id_created_at_idx on (userId, createdAt DESC); user_activity_favorites_activity_id_idx on (activityId) (enforced in tktspace-backend/libs/shared/data-access-db/src/lib/schema/activities.schema.ts).

business invariants: TBD by human

Lifecycle

No explicit lifecycle — added or removed.

Relationships

  • User (ENT-021) — userIdusers.users.id, on-delete cascade. N:1.
  • Activity (ENT-005) — activityIdactivities.activities.id, on-delete cascade. N:1.

API surfaces

SurfaceExposedNotes
clientyes — /favorites, /favorites/{activityId} (FavoriteListResponseDto, FavoriteRecordDto, FavoriteActivityDto, CreateFavoriteDto). Phase C (869dpxbj6): FavoriteActivityDto.type promoted from bare-string to a named ActivityType enum $ref (@ApiProperty({ enum: ActivityType, enumName: 'ActivityType' })). Enum domain narrows to [SLOT_BASED, SERVICE]. Generated mobile client now emits the named enum. See ADR activity-model-simplification §D5.Swagger UI
businessyes — /analytics/favorites (FavoriteActivityAnalyticsItemDto) — aggregated counts, not per-user rowsSwagger UI
super-adminno

The business surface exposes aggregated analytics only; per-user rows are not visible to the company.

Known gotchas / open questions

  • userId references the platform-wide users.users.id, not the per-company company_customer.id. Favourites are user-level, not per-company.