Skip to main content

Platform

users, organizations, profiles, members, invitations, feedback, audit, blobs, tags, and projects.
9 min read

Sources: 000001_platform_core.up.sql, 000003_platform.up.sql, 000073_profile_follows_nutrition_visibility.up.sql, 000081_organizations.up.sql, 000082_organization_teams.up.sql.

Identity and preferences#

users#

Product user (not Better Auth).

ColumnTypeNotes
idUUID PKDefault gen_random_uuid()
auth_user_idTEXTLink to "user".id; unique when active
emailTEXT NOT NULL
normalized_emailTEXT NOT NULLPartial unique when active
nameTEXT
avatar_urlTEXT
last_login_atTIMESTAMPTZ
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZSoft delete

Indexes: active email, active auth_user_id.

user_preferences#

ColumnTypeNotes
user_idUUID PK → users1:1
appearanceJSONBDefault {"theme":"system"}. May include localeMode, sidebarOpen, tasksCalendarPanelVisible, weekPlanHiddenDays (mon–sun hidden in the week-plan board/list/day), tasksKanbanHiddenColumns (status/priority columns hidden on the project Kanban), lastProfileId (last profile used for /users/me/session)
regionalJSONBDefault {"mode":"auto"}
created_at / updated_atTIMESTAMPTZ

Source of truth for preferences: Postgres. Upstash Redis (optional) caches hot paths — me:session:{userId}, identity:auth:{authUserId}, access:{userId}:{profileId}, profile:usage:{profileId} (HASH of plan counters) — and does not replace these tables.

Profiles and membership#

profiles#

ColumnTypeNotes
idUUID PK
nameTEXT NOT NULL
handleTEXT NOT NULLPublic slug; unique while not deleted. ^[a-z0-9_]{3,30}$
kindTEXT NOT NULLperson | organization. Default person
bioTEXTPublic blurb
descriptionTEXT
owner_idUUID → usersAccountable user (billing/session). Always set.
organization_idUUID → organizationsNull = personal Studio. Set = org-owned.
image_urlTEXT
settingsJSONBsections, guest access
profile_planTEXTbase | pro | business
entitlement_versionSMALLINT1 | 2. Default 2. Unknown versions fail closed
billing_providerTEXTnone | stripe
billing_subscription_statusTEXT
billing_current_period_start_at / billing_current_period_end_atTIMESTAMPTZStripe window
billing_intervalTEXTmonth | year
billing_extra_member_seatsINT0–100
billing_ai_credit_packsINT0–100; each pack adds 500 credits / month
billing_pending_extra_member_seats / billing_pending_ai_credit_packsINTScheduled reduction
billing_pending_planTEXTScheduled target plan (base | pro | business)
billing_pending_intervalTEXTScheduled target interval (month | year)
billing_pending_effective_atTIMESTAMPTZNext renewal
last_billing_event_atTIMESTAMPTZ
billing_past_due_grace_until_atTIMESTAMPTZ
seat_countINTEffective capacity: included + extras
member_countINTDefault 1
project_countINTCustom projects only (excludes default General); default 0. Operational counter, not a customer-facing plan limit.
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZSoft
permanently_deleted_atTIMESTAMPTZPurge

organizations#

Company account. Not a Studio. No handle, followers, or public page.

ColumnTypeNotes
idUUID PK
nameTEXT NOT NULL
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZSoft

organization_members#

People in an Organization. Unique active (organization_id, user_id).

ColumnTypeNotes
idUUID PK
organization_idUUID → organizations
user_idUUID → users
roleTEXTowner | admin | member
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZ

organization_teams#

Org-scoped permission group. Not a Studio. No handle, followers, or public page.

ColumnTypeNotes
idUUID PK
organization_idUUID → organizations
nameTEXT NOT NULL
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZSoft

organization_team_members#

People on a Team. Must already be organization_members. Unique active (team_id, user_id).

ColumnTypeNotes
idUUID PK
team_idUUID → organization_teams
user_idUUID → users
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZ

profile_team_assignments#

M:N assign Team → org-owned Studio. Writes profile_members with origin='team'. Unique active (profile_id, team_id).

ColumnTypeNotes
idUUID PK
profile_idUUID → profilesOrg-owned Studio
team_idUUID → organization_teamsSame Organization
roleTEXTadmin | member (not owner)
created_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZ

profile_members#

ColumnTypeNotes
idUUID PK
profile_idUUID → profiles
user_idUUID → usersUnique when active per profile
roleTEXTowner | admin | member
invited_byUUID → users
username / email / avatar_urlTEXTDenormalized snapshot
section_accessJSONB[{sectionId, role}] — role: admin | member (admin can delete in that section)
originTEXTdirect | team. Default direct. Team-granted rows unassign only when no other assigned Team covers the user
is_favoriteBOOLEANPer-user preference; default false. The star on /profiles is personal, not shared
joined_at / updated_atTIMESTAMPTZ
deleted_atTIMESTAMPTZ

profile_invitations#

ColumnTypeNotes
idUUID PK
profile_idUUID → profiles
invited_emailTEXT NOT NULLUnique pending per profile
invited_user_idUUID → usersIf an account already exists
invited_byUUID → users
roleTEXTadmin | member
section_accessJSONBSame shape as in profile_members
statusTEXTpending / accepted / rejected / expired / canceled
expires_atTIMESTAMPTZ
accepted_at / rejected_at / revoked_at / responded_atTIMESTAMPTZ
created_at / updated_at / deleted_atTIMESTAMPTZ

Indexes: pending email unique; recipient; expiry; manager listing idx_profile_invitations_profile_created on (profile_id, created_at DESC) WHERE deleted_at IS NULL.

profile_follows#

One-way audience. Does not grant membership or a seat.

ColumnTypeNotes
idUUID PK
follower_user_idUUID → users
profile_idUUID → profiles
created_atTIMESTAMPTZ

Unique (follower_user_id, profile_id). Soft-delete keeps rows so restore is lossless. Permanent delete of the studio deletes these rows.

Connections (people)#

Person-to-person graph of the account — not third-party OAuth. Product: Connections.

user_connections#

Edge between two users (no self). Soft delete. Unique when active (user_id, connected_user_id).

user_connection_invitations#

Invitation by email; status pending/accepted/rejected/canceled.

Feedback#

feedback_submissions#

ColumnNotes
author_user_idWho submitted
source_profile_id / nameOrigin
domainProduct area
kindbug | idea | praise
message1–8000 chars
source_url / source_pathUI context

feedback_attachments#

Images ≤ 10MB (content_type LIKE 'image/%'), blob metadata, position.

Billing audit#

billing_webhook_events#

ColumnNotes
event_idTEXT PK (idempotency)
event_type / payloadStripe event etc.
profile_idNullable
outcomeHandler outcome
received_at

plan_change_audit_log#

Plan/status transitions with source, event_id, occurred_at.

Stripe sync also updates period, interval, and current/scheduled quantities. Agent grants and consumption are documented in Database → Agent.

Platform audit#

platform_audit_log#

ColumnNotes
profile_id / actor_user_idContext
domain / actionWhat happened
resource_type / resource_id / resource_nameTarget
metadataJSONB
created_at

Blobs (000003)#

Physical uploads and deletes live in Next (@vercel/blob in server actions). The API only persists metadata via POST /api/blob/.../attachments.

blob_upload_intents (legacy)#

Historical intents table; no longer written in the current flow.

blob_deletion_outbox (legacy)#

Historical deletion queue in the API; no longer written or processed. Next calls del() from the SDK after soft-delete/clear in Go.

Tags#

profile_tags#

ColumnNotes
name / normalized_nameUnique per profile + domain_scope
color / description
domain_scopeTag domain. Default general. Values: general, tasks, projects, finance, library, nutrition, health, notes, activities. A picker for domain X lists general + X.
is_favorite
link_countDenormalized
created_by

(tag_id, entity_type, entity_id) unique. Polymorphic link. Canonical entity types include task, project, activity, note, library_item, nutrition_recipe, health_checkin, finance_transaction, and finance_recurring_rule.

Projects#

profile_projects#

ColumnNotes
name / description / color
deadline / deadline_key
priorityDefault medium
is_pinned / is_defaultUnique default when active per profile
task_countMaintained by triggers on tasks
completedTaskCount (API)Not a column: computed when listing/reading a project by counting non-deleted tasks with status=done
edit_count
archived_at / deleted_at

Entity ↔ project (unique per entity). Canonical entity types include task, note, library_item, nutrition_recipe, health_checkin, finance_transaction, and pomodoro_timer. Activities are not linked to a project.

The link is polymorphic (entity_type + entity_id, no foreign key), so nothing in the database cascades. Two rules keep the project Profile links tab honest:

  • Delete side — a module that deletes a linkable entity clears its link rows in the same transaction (postgres.DeleteProjectLinks). Entities with a trash + restore flow (task, note, library_item) keep the row while in trash and clear it on permanent delete (hard delete, trash purge, retention cron). Entities without restore (nutrition_recipe, finance_transaction, pomodoro_timer, health_checkin) clear it on delete.
  • Read side — ListProjectLinks resolves every link against its entity and skips rows it cannot resolve (entity soft-deleted or gone), so a trashed entity disappears from the tab and comes back if it is restored. A new linkable entity type must be added to resolveProjectLinkTitles or its links stop showing.

project_comments#

Soft-deletable comments.

project_events#

Feed: event_type, feed_bucket, actor_user_id, payload, optional task_id / comment_id. Retention ~400 days: when writing an event, expired rows of the same profile are purged (small batch; no cron).

Who writes#

Go moduleTables
users / profilescore, including organizations, organization_members, organization_teams, organization_team_members, profile_team_assignments
feedbackfeedback_*
billingwebhooks + plan audit
blobintents / outbox
tags / projectstags + projects