LifeMate — Personal, Family & Learning Companion
fix/study-duration-display
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
| 1 | # ADR-0006 — Provider-neutral PostgreSQL Backend |
| 2 | |
| 3 | - **Status:** Superseded hosting recommendation; PostgreSQL/adapter invariants retained |
| 4 | - **Superseded by:** [ADR-0009](0009-provider-neutral-hosting.md) for hosting |
| 5 | - **Date:** 2026-10-05 |
| 6 | - **Supersedes:** any Phase 2 assumption that Supabase is a mandatory backend platform |
| 7 | |
| 8 | ## Context |
| 9 | 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. |
| 10 | |
| 11 | ## Decision |
| 12 | LifeMate will use PostgreSQL as its durable relational source of truth while exposing infrastructure through explicit application ports/adapters. |
| 13 | |
| 14 | The managed PostgreSQL host is replaceable. The former Neon preference is historical. The active target is self-hosted PostgreSQL in the same provider-neutral Compose package as the API and PWA; managed database services are excluded by ADR-0009. |
| 15 | |
| 16 | Required ports: |
| 17 | - `IdentityProvider`: registration, email verification, login/session, password recovery/change. |
| 18 | - `LifeMateApi`: authenticated application boundary; clients do not receive privileged database credentials. |
| 19 | - `TransactionalEmail`: verification, password recovery and family invitation messages. |
| 20 | - `ObjectStorage`: future profile/media assets. |
| 21 | - `RealtimeTransport`: optional event delivery; business correctness cannot depend on it. |
| 22 | |
| 23 | 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. |
| 24 | |
| 25 | ## Consequences |
| 26 | ### Positive |
| 27 | - Staging/production can move between managed PostgreSQL providers. |
| 28 | - Auth can change without rewriting family/profile domain tables. |
| 29 | - Flutter clients stay independent of database vendor SDKs. |
| 30 | - Testing authorization through API/service contracts becomes straightforward. |
| 31 | - LifeMate is no longer blocked by Supabase project quotas. |
| 32 | |
| 33 | ### Cost |
| 34 | - We own a small backend/API layer instead of relying entirely on generated BaaS APIs. |
| 35 | - Email verification/recovery and session handling need an explicit identity adapter. |
| 36 | - Realtime/storage require separate adapters if/when introduced. |
| 37 | |
| 38 | ## Guardrails |
| 39 | - Never place database owner/service credentials in Flutter/Web clients. |
| 40 | - Never use client-side role checks as the security boundary. |
| 41 | - Never let Family Owner/Admin imply automatic access to private teen content. |
| 42 | - Migrations remain standard PostgreSQL SQL wherever practical. |