LifeMate — Personal, Family & Learning Companion

fix/local-task-persistence
chore/phase1-repository-cleanup deploy/stable-web-apk deployment-static design/mobile-accessibility-v2 design/mobile-navigation-review docs/child-education-access-decision docs/offline-data-rescue-options docs/owner-guide-and-delivery-plan docs/phase1-policy-options docs/public-review-live-2026-10-15 feat/aparat-learning-library feat/child-device-safety feat/child-identity-schema feat/flutter-mobile-navigation feat/learning-content-operations feat/local-signing-preflight feat/online-family-stage0 feat/personal-encrypted-recovery feat/private-planner-series-api feat/public-review-page feat/standalone-weekly-planner feat/weekly-planner-android final-feature-1/iran-family-school fix/auth-abuse-expiry-safety fix/auth-expiry-after-lock fix/backend-request-safety fix/lifeguide-bootstrap-naming-ci fix/lifeguide-pages-qa-base-preflight fix/lifeguide-qa-pages-env-deployment fix/local-task-persistence fix/managed-child-session-boundary fix/personal-jalali-dates fix/personal-notification-controls fix/personal-upgrade-delivery-guard fix/sms-approval-gates fix/study-duration-display infra/cloudflare-neon-migration infra/lifeguide-cloudflare-qa infra/lifeguide-github-pages-qa infra/lifeguide-supabase-qa main phase-1/foundation-completion phase-2/product-foundation-identity phase-3/planner-school-family-core phase-4/ai-learning-wellbeing phase-5/hardening-observability-release test/android-reminder-acceptance test/personal-notification-settings test/personal-recovery-acceptance test/role-entry-apk
md 41 lines 2.51 KB
Rendered Raw
1 # ADR-0006 — Provider-neutral PostgreSQL Backend
2
3 - **Status:** Accepted
4 - **Date:** 2026-10-05
5 - **Supersedes:** any Phase 2 assumption that Supabase is a mandatory backend platform
6
7 ## Context
8 Phase 2 originally treated Supabase as the likely combined database/auth/backend provider. Creation of an isolated LifeMate staging project was blocked by account-level project limits. More importantly, tying identity, authorization, storage, realtime and database behavior to one BaaS creates unnecessary platform coupling for a long-lived family product.
9
10 ## Decision
11 LifeMate will use PostgreSQL as its durable relational source of truth while exposing infrastructure through explicit application ports/adapters.
12
13 The managed PostgreSQL host is replaceable. Neon is the preferred current target when available, but no domain entity, authorization rule, migration or client contract may require Neon-specific semantics.
14
15 Required ports:
16 - `IdentityProvider`: registration, email verification, login/session, password recovery/change.
17 - `LifeMateApi`: authenticated application boundary; clients do not receive privileged database credentials.
18 - `TransactionalEmail`: verification, password recovery and family invitation messages.
19 - `ObjectStorage`: future profile/media assets.
20 - `RealtimeTransport`: optional event delivery; business correctness cannot depend on it.
21
22 PostgreSQL owns profiles, family workspaces, memberships, guardian relationships, invitations and authorization-relevant state. Authorization is enforced server-side. Database constraints and, where operationally suitable, RLS are defense-in-depth rather than the only authorization boundary.
23
24 ## Consequences
25 ### Positive
26 - Staging/production can move between managed PostgreSQL providers.
27 - Auth can change without rewriting family/profile domain tables.
28 - Flutter clients stay independent of database vendor SDKs.
29 - Testing authorization through API/service contracts becomes straightforward.
30 - LifeMate is no longer blocked by Supabase project quotas.
31
32 ### Cost
33 - We own a small backend/API layer instead of relying entirely on generated BaaS APIs.
34 - Email verification/recovery and session handling need an explicit identity adapter.
35 - Realtime/storage require separate adapters if/when introduced.
36
37 ## Guardrails
38 - Never place database owner/service credentials in Flutter/Web clients.
39 - Never use client-side role checks as the security boundary.
40 - Never let Family Owner/Admin imply automatic access to private teen content.
41 - Migrations remain standard PostgreSQL SQL wherever practical.