Work / Plan-Kid / Wiki / Entities
data-model
Entitycanonicalverified 2026-07-27
DATA.MODELData model
Summary
Core entities in the pattaya data model. Household is the billing + org unit; Partners belong to it; content and logs belong to Partners with a Household-scope filter.
Canonical values
Entities
| Entity | Owner | Purpose |
|---|---|---|
Household |
itself | Billing + org unit. One per couple (or per solo user pre-pair). |
Partner |
Household | User account. 1–2 per Household. |
StageProfile |
Household | Current stage + sub-stage (pregnancy week etc.) + region + Indian-context toggle. |
KnowledgeCard |
(global) | Content, static. Not user-scoped. |
CardRead |
Partner | Bookmark / read / dismissed state per Partner per Card. |
AIConversation |
Partner | AI chat thread. Per-partner (private). |
JournalEntry |
Partner | Per-partner. visibility: private | shared. Encrypted (see journal-encryption). |
TrackingLog |
Partner | Per-partner logs (cycle, mood, sleep, symptoms). |
Milestone |
Household | Shared milestones (positive test, first heartbeat, etc.). |
RitualSession |
Household | Weekly ritual sessions, both partners' answers. |
AuditLog |
Household | Every server-side journal decryption is logged here. |
Household ↔ Partner
- A Household has 1–2 Partners.
- The Household holds the paid subscription (via RevenueCat entitlement).
- If a Household splits, a new Household is created; entries follow the author; shared entries duplicate.
RLS (Supabase, Phase 3)
- All Partner-scoped rows have RLS:
household_id = auth.jwt() -> household_id AND (author_id = auth.uid() OR visibility = 'shared') - Journal
privatevisibility:author_id = auth.uid()regardless of Household membership - Milestones + RitualSessions:
household_id = auth.jwt() -> household_id
Encryption at rest
- Every
JournalEntry.body_ciphertextis encrypted with a per-entry DEK; the DEK is wrapped by the Household's KEK stored in KMS. - Server-side decryption for AI summarization is possible; each decryption writes an
AuditLogrow. - User-visible: surface-mobile-settings-privacy shows the audit log.
Related
Sources
- Design decision
Every project of mine is written down like this.
Read the résumé