LifeMate — Personal, Family & Learning Companion

fix/lifeguide-pages-qa-base-preflight
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 46 lines 5.56 KB
Rendered Raw
1 # ADR 0013 — LifeGuide: GitHub + Cloudflare Pages + Supabase PostgreSQL + Kavenegar
2
3 Date: 2026-10-15
4 Status: **OWNER DIRECTED, QA PREPARATION — public production cutover NOT approved**
5
6 ## User decision
7
8 Owner explicitly directs **remove Railway from the active LifeGuide deployment architecture** due to inaccessible regional connectivity and 504 at `app.lifeguide.ir`. Focus active development and operations on **GitHub, Supabase, Cloudflare, Kavenegar OTP**. This supersedes the prior self-hosted-only active provider selection of ADR 0009 *for online QA exploration*, without deleting historical decisions or changing the Node/Express security contract.
9
10 ## Existing verified inventory
11
12 - Main repository: `davoodmehraban89/LifeMate`, product **LifeGuide**.
13 - App v0.7.1 development baseline and connected Supabase QA branch: `infra/lifeguide-supabase-qa`; related draft PR #14. No merge into `main`.
14 - Supabase Free organization `DM Studio`, isolated `LifeGuide-QA` database `iqkrwxeprxvdiubdfcrb`, Frankfurt, PG17.11; 20 original application SQL migrations succeeded in locked-down **private `lifeguide_qa` schema**. DB fixture verified two parents, one child, an outsider, private data, revocation and 4 seconds duration, all ROLLED BACK. No client DB grants; browser must **never** connect directly with a privileged key.
15 - Existing Cloudflare account `ace6f7219be1e7d9ac5bacd59c05fbe2` has a previously-created GitHub-integrated Pages project `lifemate-staging.pages.dev`, production branch `deployment-static`. Its latest successful production deploy dates to Oct 6 and contains an older static Flutter build; NOT the integrated QA 0.7.1 app.
16 - `app.lifeguide.ir` returned Arvan 504 on owner LTE. Authoritative DNS for `lifeguide.ir` is **Arvan DNS** (`d.ns.arvancdn.ir`). `app` A answers currently resolve Arvan network addresses. Connected Cloudflare account does **NOT** contain the `lifeguide.ir` zone. No DNS change executed.
17 - Kavenegar OTP `lifeguideotp` pattern submitted but **rejected**; support ticket says application link unreachable. Existing opt-in Node adapter has synthetic tests, no API secret added, no real/paid SMS sent.
18
19 ## Chosen QA layout
20
21 1. **GitHub**: source of truth, build/quality gates, independent reviewable PRs; immutable build evidence. Do not overwrite live `main` or stale `deployment-static`.
22 2. **Cloudflare Pages**: host QA Flutter PWA as **static assets**, without Railway. Existing Pages project stays unchanged. Use isolated `lifeguide-qa` Pages site sourced from dedicated QA branch, with no domain attached pending real functional acceptance. QA build script pinned to Flutter 3.47.6, no external CanvasKit CDN.
23 3. **Supabase**: managed PostgreSQL and server-side Edge Functions for supported **bounded server logic**, but not as an automatic drop-in replacement for Express5/native Argon2/custom JWTs. Preserve authorization semantics before activating user-facing API. No service-role/DB secret in PWA/Android, API responses, logs or Git.
24 4. **Kavenegar**: server-side OTP transport using approved `lifeguideotp` template. Pattern rejected because app domain 504; resubmit/support after independent reachable application URL is demonstrably functional and user agrees. No paid SMS without approval.
25 5. **QA safety**: Until authenticated task APIs are ready, Cloudflare Pages `/api` and `/api/*` return **503 JSON** (fail closed), `/ready` returns degraded, `/health` confirms gateway only. Do NOT count a static 200 as healthy family sync.
26
27 ## Domain strategy without transferring DNS zone
28
29 Per https://developers.cloudflare.com/pages/configuration/custom-domains/ **Cloudflare Pages can attach a custom subdomain even when the apex DNS remains at an external provider**: *first* add `app.lifeguide.ir` in the Pages **Custom Domains** page, *then* add a CNAME for `app` to the assigned `<pages-project>.pages.dev` within **Arvan DNS**, and review any Arvan CDN/proxy and certificates. Do **NOT** simply point CNAME without Pages ownership setup (Cloudflare says it may return HTTP 522). This is a user-visible switch and requires separate approval and access; **none is performed in this QA workstream**. Back up existing DNS records and use validated rollback.
30
31 ## Non-negotiable acceptance gates
32
33 - Static PWA must build, load, install and persist from Cloudflare Pages on iOS Safari and Android without VPN inside Iran. Merely 200 on Pages is insufficient.
34 - QA provider API must have real authenticated user-family access, verified negative-role tests, short-lived OTP, 6-digit code, adequate server-side abuse throttling and session revocation.
35 - Kavenegar verification template approved by provider and one owner-approved charged test SMS successfully received, never expose API key.
36 - QA child writes to Supabase -> authorized mother/father see correctly -> outsider denied -> private child information denied -> family member revoked immediately -> 4 seconds accurate -> offline resend deduplicated. No false assurance based on DB-only tests.
37 - Real-data migration, domain cutover, signed APK publication, adding paid services and DNS/permissions change are distinct owner approvals.
38
39 ## Work ledger
40
41 - [x] Existing Cloudflare Pages GitHub integration / DNS authority / Supabase QA infrastructure audited.
42 - [x] QA Cloudflare static build script and fail-closed Pages Functions authored on isolated GitHub branch.
43 - [ ] Independent Cloudflare QA site build/deploy, validated HTTP content type and status.
44 - [ ] Supabase authenticated family endpoints; no rewrite with privileged client keys.
45 - [ ] Approved Kavenegar OTP and live QA delivery.
46 - [ ] Owner-approved Arvan CNAME domain cutover and post-change LTE verification.