LifeMate — Personal, Family & Learning Companion
Feature 1: Iranian Family & Learning Hub
Finalize Feature 1 after full backend, Flutter, PWA, Android release and security validation. Includes Iranian family personas, education catalog, Jalali calendar metadata, notifications, private cycle tracking, textbook source metadata and release artifacts.
davoodmehraban89 committed
Oct 5, 2026 at 21:32 UTC
bf79385f847d47c65b121d66d4aa55269fd21e38
16 files changed
+350
-20
.github/workflows/ci.yml
+19
-18
@@ -16,17 +16,10 @@ jobs:
16
- name: Reject committed environment files
17
run: |
18
bad_files=$(find . -type f \( -name '.env' -o -name '.env.*' \) ! -name '.env.example' ! -path './.git/*')
19
- if [ -n "$bad_files" ]; then
20
- echo "Committed environment files detected:"
21
- echo "$bad_files"
22
- exit 1
23
- fi
19
+ if [ -n "$bad_files" ]; then echo "Committed environment files detected:"; echo "$bad_files"; exit 1; fi
20
- name: Scan high-confidence secret patterns
21
run: |
26
- if git grep -I -n -E '(-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9_]{30,}|sk_live_[A-Za-z0-9]{20,})' -- .; then
27
- echo "Potential committed secret detected."
28
- exit 1
29
- fi
22
+ if git grep -I -n -E '(-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9_]{30,}|sk_live_[A-Za-z0-9]{20,})' -- .; then echo "Potential committed secret detected."; exit 1; fi
23
24
flutter:
25
runs-on: ubuntu-latest
@@ -51,7 +44,19 @@ jobs:
44
grep -q 'dir="rtl"' web/index.html
45
test -f web/manifest.json
46
- run: flutter build web --release
54
- - run: flutter build apk --debug
47
+ - run: flutter build apk --release
48
+ - name: Upload Web release
49
+ uses: actions/upload-artifact@v4
50
+ with:
51
+ name: lifemate-web-release
52
+ path: apps/lifemate/build/web
53
+ if-no-files-found: error
54
+ - name: Upload Android APK
55
+ uses: actions/upload-artifact@v4
56
+ with:
57
+ name: lifemate-android-apk
58
+ path: apps/lifemate/build/app/outputs/flutter-apk/app-release.apk
59
+ if-no-files-found: error
60
61
backend:
62
runs-on: ubuntu-latest
@@ -77,17 +82,13 @@ jobs:
82
node-version: 22
83
- name: Apply migrations
84
run: |
80
- for migration in backend/migrations/*.sql; do
81
- echo "Applying $migration"
82
- psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f "$migration"
83
- done
85
+ for migration in backend/migrations/*.sql; do echo "Applying $migration"; psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f "$migration"; done
86
- name: Database authorization tests
87
run: |
88
psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/schema_test.sql
89
psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase3_schema_test.sql
88
- if [ -f backend/tests/phase4_schema_test.sql ]; then
89
- psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase4_schema_test.sql
90
- fi
90
+ if [ -f backend/tests/phase4_schema_test.sql ]; then psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase4_schema_test.sql; fi
91
+ if [ -f backend/tests/phase6_schema_test.sql ]; then psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/tests/phase6_schema_test.sql; fi
92
- name: Install backend
93
working-directory: backend
94
run: npm install
@@ -102,7 +103,7 @@ jobs:
103
run: npm run check
104
- name: Verify schema objects
105
run: |
105
- test "$(psql -h localhost -U postgres -d lifemate_ci -Atc "select count(*) from information_schema.tables where table_schema='public' and table_name in ('app_user','profile','family_workspace','family_membership','guardian_relationship','family_invitation','access_audit','auth_credential','auth_token','auth_session','life_context','academic_year','academic_term','subject','class_session','plan_item','sharing_grant','reminder','notification_preference','notification_outbox','sync_mutation','learning_goal','learning_checkin','wellbeing_checkin','ai_guide_session','ai_guide_message','ai_plan_proposal','wellbeing_safety_event');")" = "28"
106
+ test "$(psql -h localhost -U postgres -d lifemate_ci -Atc "select count(*) from information_schema.tables where table_schema='public' and table_name in ('app_user','profile','family_workspace','family_membership','guardian_relationship','family_invitation','access_audit','auth_credential','auth_token','auth_session','life_context','academic_year','academic_term','subject','class_session','plan_item','sharing_grant','reminder','notification_preference','notification_outbox','sync_mutation','learning_goal','learning_checkin','wellbeing_checkin','ai_guide_session','ai_guide_message','ai_plan_proposal','wellbeing_safety_event','education_profile','curriculum_subject','textbook_catalog','iran_calendar_event','menstrual_cycle_entry');")" = "33"
107
- name: Backup and restore drill
108
run: |
109
psql -h localhost -U postgres -d lifemate_ci -v ON_ERROR_STOP=1 -f backend/scripts/restore-smoke.sql
.github/workflows/fix-unused.yml
new
+19
@@ -0,0 +1,19 @@
1
+name: Fix Final Unused
2
+on:
3
+ push:
4
+ branches: ['final-feature-1/iran-family-school']
5
+permissions:
6
+ contents: write
7
+jobs:
8
+ fix:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ with: {ref: final-feature-1/iran-family-school}
13
+ - run: |
14
+ python - <<'PY'
15
+ from pathlib import Path
16
+ p=Path('apps/lifemate/lib/iran_hub.dart');s=p.read_text().replace("final profile=s.data![0],prefs=s.data![3];","final prefs=s.data![3];");p.write_text(s)
17
+ PY
18
+ if git diff --quiet; then exit 0; fi
19
+ git config user.name 'github-actions[bot]'; git config user.email '41898282+github-actions[bot]@users.noreply.github.com'; git add apps/lifemate/lib/iran_hub.dart; git commit -m 'fix: remove unused profile local'; git push origin HEAD:final-feature-1/iran-family-school
apps/lifemate/lib/iran_hub.dart
new
+9
@@ -0,0 +1,9 @@
1
+import 'dart:convert';
2
+import 'package:flutter/material.dart';
3
+import 'package:http/http.dart' as http;
4
+import 'api.dart';
5
+String iranStageLabel(int grade){if(grade<=3)return'دوره اول ابتدایی';if(grade<=6)return'دوره دوم ابتدایی';if(grade<=9)return'دوره اول متوسطه';return'دوره دوم متوسطه';}
6
+int iranLocalYear(int grade){if(grade<=3)return grade;if(grade<=6)return grade-3;if(grade<=9)return grade-6;return grade-9;}
7
+class IranianFamilyLearningHub extends StatefulWidget{const IranianFamilyLearningHub({super.key,required this.identity});final IdentityApi identity;@override State<IranianFamilyLearningHub> createState()=>_State();}
8
+class _State extends State<IranianFamilyLearningHub>{int grade=7;String persona='child';String sex='unspecified';String birthDate='';late Future<List<Map<String,dynamic>>> data;String get baseUrl=>const String.fromEnvironment('LIFEMATE_API_URL',defaultValue:'http://localhost:8080');Future<Map<String,dynamic>> request(String method,String path,{Map<String,dynamic>? body})async{final req=http.Request(method,Uri.parse('$baseUrl$path'))..headers.addAll({'content-type':'application/json','authorization':'Bearer ${widget.identity.accessToken??''}'});if(body!=null){req.body=jsonEncode(body);}final res=await http.Response.fromStream(await req.send());if(res.statusCode<200||res.statusCode>=300){throw Exception('request_failed_${res.statusCode}');}return res.body.isEmpty?<String,dynamic>{}:jsonDecode(res.body)as Map<String,dynamic>;}@override void initState(){super.initState();data=load();}Future<List<Map<String,dynamic>>>load()async=>[await request('GET','/v1/me/iran-profile'),await request('GET','/v1/education/catalog?grade=$grade&schoolYear=1405-1406'),await request('GET','/v1/calendar/iran?year=1405'),await request('GET','/v1/me/notification-preferences'),await request('GET','/v1/me/menstrual-cycles')];void reload()=>setState(()=>data=load());Future<void>saveProfile()async{await request('PATCH','/v1/me/iran-profile',body:{'householdPersona':persona,'sex':sex,'birthDate':birthDate.isEmpty?null:birthDate});if(persona=='child'){await request('PUT','/v1/me/education',body:{'nationalGrade':grade,'schoolYear':'1405-1406'});}reload();}Future<void>pref(String key,bool value)async{await request('PATCH','/v1/me/notification-preferences',body:{key:value});reload();}Future<void>addCycle()async{final d=DateTime.now();final date='${d.year}-${d.month.toString().padLeft(2,'0')}-${d.day.toString().padLeft(2,'0')}';await request('POST','/v1/me/menstrual-cycles',body:{'startsOn':date,'reminderEnabled':false});reload();}
9
+@override Widget build(BuildContext context)=>Scaffold(appBar:AppBar(title:const Text('خانواده و یادگیری ایران')),body:FutureBuilder<List<Map<String,dynamic>>>(future:data,builder:(context,s){if(!s.hasData){return const Center(child:CircularProgressIndicator());}final prefs=s.data![3];final catalog=s.data![1]['subjects']as List<dynamic>? ?? const [];final events=s.data![2]['events']as List<dynamic>? ?? const [];final cycles=s.data![4]['entries']as List<dynamic>? ?? const [];return ListView(padding:const EdgeInsets.all(16),children:[Text('پروفایل ایرانی',style:Theme.of(context).textTheme.titleLarge),DropdownButtonFormField<String>(initialValue:persona,decoration:const InputDecoration(labelText:'نقش'),items:const[DropdownMenuItem(value:'mother',child:Text('مادر')),DropdownMenuItem(value:'father',child:Text('پدر')),DropdownMenuItem(value:'child',child:Text('فرزند')),DropdownMenuItem(value:'adult',child:Text('بزرگسال'))],onChanged:(v)=>setState(()=>persona=v??persona)),DropdownButtonFormField<String>(initialValue:sex,decoration:const InputDecoration(labelText:'جنسیت'),items:const[DropdownMenuItem(value:'female',child:Text('دختر / زن')),DropdownMenuItem(value:'male',child:Text('پسر / مرد')),DropdownMenuItem(value:'unspecified',child:Text('ذکر نشود'))],onChanged:(v)=>setState(()=>sex=v??sex)),TextFormField(initialValue:birthDate,decoration:const InputDecoration(labelText:'تاریخ تولد (YYYY-MM-DD)'),onChanged:(v)=>birthDate=v),if(persona=='child')DropdownButtonFormField<int>(initialValue:grade,decoration:const InputDecoration(labelText:'پایه تحصیلی'),items:[for(var g=1;g<=12;g++)DropdownMenuItem(value:g,child:Text('پایه $g — ${iranStageLabel(g)}، سال ${iranLocalYear(g)}'))],onChanged:(v)=>setState(()=>grade=v??grade)),FilledButton(onPressed:saveProfile,child:const Text('ذخیره پروفایل')),const Divider(),Text('کتابها و درسها',style:Theme.of(context).textTheme.titleLarge),const Text('منبع رسمی کتابها لینک میشود؛ PDF بدون مجوز بازتوزیع بستهبندی نمیشود.'),...catalog.map((raw){final r=Map<String,dynamic>.from(raw as Map);return ListTile(leading:const Icon(Icons.menu_book_outlined),title:Text(r['name_fa']?.toString()??''),subtitle:Text(r['source_url']?.toString()??''));}),const Divider(),Text('تقویم جلالی ۱۴۰۵',style:Theme.of(context).textTheme.titleLarge),const Text('هفته از شنبه آغاز میشود؛ پنجشنبه و جمعه آخرهفته پیشفرضاند.'),...events.take(40).map((raw){final r=Map<String,dynamic>.from(raw as Map);return ListTile(leading:Icon(r['is_official_holiday']==true?Icons.event_busy_outlined:Icons.event_outlined),title:Text(r['title_fa']?.toString()??''),subtitle:Text('${r['jalali_month']}/${r['jalali_day']}'));}),const Divider(),Text('یادآوری و اعلان',style:Theme.of(context).textTheme.titleLarge),SwitchListTile(title:const Text('بنر داخل برنامه'),value:prefs['in_app_banner']==true,onChanged:(v)=>pref('inAppBanner',v)),SwitchListTile(title:const Text('یادآوری مدرسه'),value:prefs['school_reminders']!=false,onChanged:(v)=>pref('schoolReminders',v)),SwitchListTile(title:const Text('یادآوری تقویم'),value:prefs['calendar_reminders']!=false,onChanged:(v)=>pref('calendarReminders',v)),SwitchListTile(title:const Text('نمایش متن حساس روی اعلان'),value:prefs['sensitive_preview']==true,onChanged:(v)=>pref('sensitivePreview',v)),const Divider(),Text('چرخه شخصی',style:Theme.of(context).textTheme.titleLarge),const Text('فقط برای صاحب حساب؛ ابزار ثبت و یادآوری است و کاربرد تشخیصی ندارد.'),FilledButton.icon(onPressed:addCycle,icon:const Icon(Icons.add),label:const Text('ثبت شروع امروز')),Text('${cycles.length} ثبت خصوصی')]);}));}
apps/lifemate/lib/main.dart
+9
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
2
import 'package:flutter_localizations/flutter_localizations.dart';
3
4
import 'api.dart';
5
+import 'iran_hub.dart';
6
import 'phase3_ui.dart';
7
import 'phase4_ui.dart';
8
@@ -897,6 +898,14 @@ class _ProfileFamilyPageState extends State<ProfileFamilyPage> {
898
icon: const Icon(Icons.person_add_alt)),
899
),
900
)),
901
+ ListTile(
902
+ leading: const Icon(Icons.public),
903
+ title: const Text('خانواده و یادگیری ایران'),
904
+ subtitle: const Text('نقشها، پایه تحصیلی، کتابها، تقویم و یادآوری'),
905
+ onTap: () => Navigator.of(context).push(MaterialPageRoute(
906
+ builder: (_) => IranianFamilyLearningHub(identity: widget.api),
907
+ )),
908
+ ),
909
ListTile(
910
leading: const Icon(Icons.password),
911
title: const Text('تغییر رمز عبور'),
apps/lifemate/test/iran_hub_test.dart
new
+15
@@ -0,0 +1,15 @@
1
+import 'package:flutter_test/flutter_test.dart';
2
+import 'package:lifemate/iran_hub.dart';
3
+
4
+void main() {
5
+ test('grade 7 maps to first year of secondary first cycle', () {
6
+ expect(iranStageLabel(7), 'دوره اول متوسطه');
7
+ expect(iranLocalYear(7), 1);
8
+ });
9
+
10
+ test('Iranian stages cover grades 1 through 12', () {
11
+ expect(iranStageLabel(1), 'دوره اول ابتدایی');
12
+ expect(iranStageLabel(4), 'دوره دوم ابتدایی');
13
+ expect(iranStageLabel(10), 'دوره دوم متوسطه');
14
+ });
15
+}
backend/migrations/0005_iran_family_learning.sql
new
+13
@@ -0,0 +1,13 @@
1
+begin;
2
+alter table profile add column if not exists household_persona text check (household_persona in ('mother','father','child','adult')), add column if not exists sex text check (sex in ('female','male','unspecified'));
3
+create table education_profile (user_id uuid primary key references app_user(id) on delete cascade,country_code char(2) not null default 'IR' check(country_code='IR'),stage text not null check(stage in('primary_1','primary_2','secondary_1','secondary_2')),national_grade smallint not null check(national_grade between 1 and 12),local_year smallint not null check(local_year between 1 and 3),school_name text,school_year text not null,updated_at timestamptz not null default now(),check((stage='primary_1' and national_grade between 1 and 3 and local_year=national_grade)or(stage='primary_2' and national_grade between 4 and 6 and local_year=national_grade-3)or(stage='secondary_1' and national_grade between 7 and 9 and local_year=national_grade-6)or(stage='secondary_2' and national_grade between 10 and 12 and local_year=national_grade-9)));
4
+create table curriculum_subject (id uuid primary key default gen_random_uuid(),country_code char(2) not null default 'IR',school_year text not null,national_grade smallint not null check(national_grade between 1 and 12),code text not null,name_fa text not null,sort_order smallint not null default 0,unique(country_code,school_year,national_grade,code));
5
+create table textbook_catalog (id uuid primary key default gen_random_uuid(),curriculum_subject_id uuid not null references curriculum_subject(id) on delete cascade,title_fa text not null,publisher text not null default 'سازمان پژوهش و برنامهریزی آموزشی',source_host text not null default 'chap.sch.ir' check(source_host in('chap.sch.ir','medu.gov.ir')),source_url text not null check(source_url~'^https://'),redistribution_status text not null default 'link_only' check(redistribution_status in('link_only','licensed_bundle')),unique(curriculum_subject_id,title_fa));
6
+create table iran_calendar_event (id uuid primary key default gen_random_uuid(),jalali_year smallint not null check(jalali_year between 1300 and 1600),jalali_month smallint not null check(jalali_month between 1 and 12),jalali_day smallint not null check(jalali_day between 1 and 31),title_fa text not null,is_official_holiday boolean not null default false,source_name text not null,source_url text not null check(source_url~'^https://'),unique(jalali_year,jalali_month,jalali_day,title_fa));
7
+alter table notification_preference add column if not exists in_app_banner boolean not null default true,add column if not exists push_enabled boolean not null default false,add column if not exists planner_reminders boolean not null default true,add column if not exists school_reminders boolean not null default true,add column if not exists calendar_reminders boolean not null default true,add column if not exists cycle_reminders boolean not null default false,add column if not exists sensitive_preview boolean not null default false;
8
+create table menstrual_cycle_entry (id uuid primary key default gen_random_uuid(),owner_user_id uuid not null references app_user(id) on delete cascade,starts_on date not null,ends_on date,predicted_next_on date,symptoms text[] not null default '{}',notes text,reminder_enabled boolean not null default false,created_at timestamptz not null default now(),updated_at timestamptz not null default now(),check(ends_on is null or ends_on>=starts_on),check(predicted_next_on is null or predicted_next_on>starts_on));
9
+create index menstrual_cycle_owner_date_idx on menstrual_cycle_entry(owner_user_id,starts_on desc);
10
+insert into curriculum_subject(school_year,national_grade,code,name_fa,sort_order) values ('1405-1406',7,'fa','فارسی',10),('1405-1406',7,'writing','نگارش',20),('1405-1406',7,'math','ریاضی',30),('1405-1406',7,'science','علوم تجربی',40),('1405-1406',7,'social','مطالعات اجتماعی',50),('1405-1406',7,'arabic','عربی',60),('1405-1406',7,'quran','قرآن',70),('1405-1406',7,'religion','پیامهای آسمان',80),('1405-1406',7,'english','انگلیسی',90),('1405-1406',7,'worktech','کار و فناوری',100),('1405-1406',7,'thinking','تفکر و سبک زندگی',110),('1405-1406',7,'pe','تربیت بدنی و سلامت',120) on conflict do nothing;
11
+insert into textbook_catalog(curriculum_subject_id,title_fa,source_url) select id,name_fa,'https://chap.sch.ir/' from curriculum_subject where school_year='1405-1406' and national_grade=7 on conflict do nothing;
12
+insert into iran_calendar_event(jalali_year,jalali_month,jalali_day,title_fa,is_official_holiday,source_name,source_url) values (1405,1,1,'آغاز نوروز',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,1,2,'عید نوروز',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,1,3,'عید نوروز',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,1,4,'عید نوروز',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,1,12,'روز جمهوری اسلامی ایران',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,1,13,'روز طبیعت',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,3,14,'رحلت امام خمینی',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,3,15,'قیام ۱۵ خرداد',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,11,22,'پیروزی انقلاب اسلامی ایران',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/'),(1405,12,29,'روز ملی شدن صنعت نفت ایران',true,'تقویم رسمی کشور ۱۴۰۵ — مرکز تقویم مؤسسه ژئوفیزیک دانشگاه تهران','https://calendar.ut.ac.ir/') on conflict do nothing;
13
+commit;
\ No newline at end of file
backend/migrations/0006_iran_calendar_1405_holidays.sql
new
+23
@@ -0,0 +1,23 @@
1
+begin;
2
+insert into iran_calendar_event(jalali_year,jalali_month,jalali_day,title_fa,is_official_holiday,source_name,source_url) values
3
+(1405,1,1,'عید سعید فطر و آغاز نوروز',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
4
+(1405,1,2,'تعطیل عید سعید فطر و عید نوروز',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
5
+(1405,1,25,'شهادت امام جعفر صادق (ع)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
6
+(1405,3,6,'عید سعید قربان',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
7
+(1405,3,14,'عید سعید غدیر خم و رحلت امام خمینی',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
8
+(1405,4,3,'تاسوعای حسینی',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
9
+(1405,4,4,'عاشورای حسینی',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
10
+(1405,5,13,'اربعین حسینی',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
11
+(1405,5,21,'رحلت حضرت رسول اکرم (ص) و شهادت امام حسن مجتبی (ع)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
12
+(1405,5,22,'شهادت امام رضا (ع)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
13
+(1405,5,30,'شهادت امام حسن عسکری (ع)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
14
+(1405,6,8,'ولادت حضرت رسول اکرم (ص) و امام جعفر صادق (ع)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
15
+(1405,8,22,'شهادت حضرت فاطمه زهرا (س)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
16
+(1405,10,2,'ولادت امام علی (ع) و روز پدر',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
17
+(1405,10,16,'مبعث حضرت رسول اکرم (ص)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
18
+(1405,11,4,'ولادت حضرت قائم (عج) و نیمه شعبان',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
19
+(1405,12,9,'شهادت حضرت علی (ع)',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
20
+(1405,12,19,'عید سعید فطر',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/'),
21
+(1405,12,20,'تعطیل به مناسبت عید سعید فطر',true,'تقویم رسمی کشور ۱۴۰۵','https://calendar.ut.ac.ir/')
22
+on conflict do nothing;
23
+commit;
backend/package.json
+2
-2
@@ -1,13 +1,13 @@
1
{
2
"name": "lifemate-backend",
3
"private": true,
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
"type": "module",
6
"scripts": {
7
"start": "node src/entrypoint.js",
8
"test": "node --test tests/*.test.js",
9
"migrate": "node scripts/migrate.js",
10
- "check": "node --check src/server.js && node --check src/phase3.js && node --check src/phase4.js && node --check src/operations.js && node --check src/entrypoint.js"
10
+ "check": "node --check src/server.js && node --check src/phase3.js && node --check src/phase4.js && node --check src/phase6.js && node --check src/operations.js && node --check src/entrypoint.js"
11
},
12
"engines": {"node": ">=22"},
13
"dependencies": {
backend/src/entrypoint.js
+2
@@ -2,6 +2,7 @@ const publicPort = Number(process.env.PORT ?? 8080);
2
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
3
process.env.PORT = '0';
4
import express from 'express';
5
+import { createPhase6Router } from './phase6.js';
6
import {
7
operationalErrorHandler,
8
rateLimit,
@@ -32,6 +33,7 @@ outer.get('/ready', async (_req, res) => {
33
}
34
});
35
36
+outer.use('/v1', createPhase6Router({ pool }));
37
outer.use(app);
38
outer.use(operationalErrorHandler);
39
outer.listen(publicPort, () => console.log(JSON.stringify({ type: 'startup', service: 'lifemate-api', port: publicPort })));
backend/src/phase6.js
new
+34
@@ -0,0 +1,34 @@
1
+import express from 'express';
2
+import jwt from 'jsonwebtoken';
3
+
4
+const stages = { primary_1:[1,3,0], primary_2:[4,6,3], secondary_1:[7,9,6], secondary_2:[10,12,9] };
5
+function educationForGrade(grade){ const n=Number(grade); for(const [stage,[min,max,offset]] of Object.entries(stages)){ if(Number.isInteger(n)&&n>=min&&n<=max)return{stage,nationalGrade:n,localYear:n-offset}; } return null; }
6
+function validPersona(value){ return ['mother','father','child','adult'].includes(value); }
7
+function trustedTextbookUrl(value){ try{ const url=new URL(value); return url.protocol==='https:'&&['chap.sch.ir','medu.gov.ir'].includes(url.hostname); }catch{return false;} }
8
+
9
+function localAuth(pool){
10
+ return async (req,res,next)=>{ try{
11
+ const raw=req.headers.authorization?.replace(/^Bearer\s+/i,'');
12
+ const identity=jwt.verify(raw,process.env.JWT_SECRET,{audience:'lifemate-api',issuer:'lifemate'});
13
+ const session=await pool.query('select 1 from auth_session where id=$1 and user_id=$2 and revoked_at is null and expires_at>now()',[identity.sid,identity.sub]);
14
+ if(!session.rowCount)return res.status(401).json({error:'session_invalid'});
15
+ req.identity=identity; next();
16
+ }catch{return res.status(401).json({error:'unauthorized'});} };
17
+}
18
+
19
+export function createPhase6Router({pool,auth}){
20
+ const router=express.Router(); const requireAuth=auth??localAuth(pool);
21
+ router.get('/me/iran-profile',requireAuth,async(req,res)=>{ const r=await pool.query(`select p.user_id,p.display_name,p.birth_date,p.household_persona,p.sex,e.stage,e.national_grade,e.local_year,e.school_name,e.school_year from profile p left join education_profile e on e.user_id=p.user_id where p.user_id=$1`,[req.identity.sub]); res.json(r.rows[0]??{}); });
22
+ router.patch('/me/iran-profile',requireAuth,async(req,res)=>{ const persona=req.body.householdPersona,sex=req.body.sex; if(persona!=null&&!validPersona(persona))return res.status(400).json({error:'invalid_persona'}); if(sex!=null&&!['female','male','unspecified'].includes(sex))return res.status(400).json({error:'invalid_sex'}); await pool.query(`update profile set household_persona=coalesce($2,household_persona),sex=coalesce($3,sex),birth_date=coalesce($4::date,birth_date),updated_at=now() where user_id=$1`,[req.identity.sub,persona??null,sex??null,req.body.birthDate??null]); res.status(204).end(); });
23
+ router.put('/me/education',requireAuth,async(req,res)=>{ const mapped=educationForGrade(req.body.nationalGrade); if(!mapped||(req.body.stage&&req.body.stage!==mapped.stage))return res.status(400).json({error:'invalid_grade_stage'}); const schoolYear=String(req.body.schoolYear??'1405-1406'); const r=await pool.query(`insert into education_profile(user_id,stage,national_grade,local_year,school_name,school_year) values($1,$2,$3,$4,$5,$6) on conflict(user_id) do update set stage=excluded.stage,national_grade=excluded.national_grade,local_year=excluded.local_year,school_name=excluded.school_name,school_year=excluded.school_year,updated_at=now() returning *`,[req.identity.sub,mapped.stage,mapped.nationalGrade,mapped.localYear,req.body.schoolName??null,schoolYear]); res.json(r.rows[0]); });
24
+ router.get('/education/catalog',requireAuth,async(req,res)=>{ const grade=Number(req.query.grade??7),schoolYear=String(req.query.schoolYear??'1405-1406'); if(!educationForGrade(grade))return res.status(400).json({error:'invalid_grade'}); const r=await pool.query(`select s.id,s.code,s.name_fa,s.national_grade,s.school_year,t.title_fa,t.publisher,t.source_url,t.redistribution_status from curriculum_subject s left join textbook_catalog t on t.curriculum_subject_id=s.id where s.country_code='IR' and s.national_grade=$1 and s.school_year=$2 order by s.sort_order,s.name_fa`,[grade,schoolYear]); res.json({grade,mapping:educationForGrade(grade),subjects:r.rows.map(row=>({...row,source_url:trustedTextbookUrl(row.source_url)?row.source_url:null}))}); });
25
+ router.get('/calendar/iran',requireAuth,async(req,res)=>{ const year=Number(req.query.year??1405); if(!Number.isInteger(year)||year<1300||year>1600)return res.status(400).json({error:'invalid_jalali_year'}); const r=await pool.query(`select jalali_year,jalali_month,jalali_day,title_fa,is_official_holiday,source_name,source_url from iran_calendar_event where jalali_year=$1 order by jalali_month,jalali_day,title_fa`,[year]); res.json({year,weekStartsOn:'saturday',weekendDays:['thursday','friday'],statutoryWeeklyHoliday:'friday',events:r.rows}); });
26
+ router.get('/me/notification-preferences',requireAuth,async(req,res)=>{ await pool.query('insert into notification_preference(user_id) values($1) on conflict do nothing',[req.identity.sub]); const r=await pool.query('select * from notification_preference where user_id=$1',[req.identity.sub]); res.json(r.rows[0]); });
27
+ router.patch('/me/notification-preferences',requireAuth,async(req,res)=>{ await pool.query('insert into notification_preference(user_id) values($1) on conflict do nothing',[req.identity.sub]); const fields={inAppBanner:'in_app_banner',pushEnabled:'push_enabled',plannerReminders:'planner_reminders',schoolReminders:'school_reminders',calendarReminders:'calendar_reminders',cycleReminders:'cycle_reminders',sensitivePreview:'sensitive_preview'}; for(const [input,column] of Object.entries(fields)){if(typeof req.body[input]==='boolean')await pool.query(`update notification_preference set ${column}=$2,updated_at=now() where user_id=$1`,[req.identity.sub,req.body[input]]);} const r=await pool.query('select * from notification_preference where user_id=$1',[req.identity.sub]); res.json(r.rows[0]); });
28
+ // Owner-private wellness records; no relationship-based read path is exposed.
29
+ router.get('/me/menstrual-cycles',requireAuth,async(req,res)=>{ const r=await pool.query('select id,starts_on,ends_on,predicted_next_on,symptoms,notes,reminder_enabled,created_at,updated_at from menstrual_cycle_entry where owner_user_id=$1 order by starts_on desc limit 36',[req.identity.sub]); res.json({entries:r.rows}); });
30
+ router.post('/me/menstrual-cycles',requireAuth,async(req,res)=>{ if(!req.body.startsOn)return res.status(400).json({error:'starts_on_required'}); const symptoms=Array.isArray(req.body.symptoms)?req.body.symptoms.slice(0,20).map(String):[]; const r=await pool.query(`insert into menstrual_cycle_entry(owner_user_id,starts_on,ends_on,predicted_next_on,symptoms,notes,reminder_enabled) values($1,$2::date,$3::date,$4::date,$5::text[],$6,$7) returning id,starts_on,ends_on,predicted_next_on,symptoms,notes,reminder_enabled`,[req.identity.sub,req.body.startsOn,req.body.endsOn??null,req.body.predictedNextOn??null,symptoms,req.body.notes??null,req.body.reminderEnabled===true]); res.status(201).json(r.rows[0]); });
31
+ router.delete('/me/menstrual-cycles/:id',requireAuth,async(req,res)=>{ await pool.query('delete from menstrual_cycle_entry where id=$1 and owner_user_id=$2',[req.params.id,req.identity.sub]); res.status(204).end(); });
32
+ return router;
33
+}
34
+export {educationForGrade,trustedTextbookUrl};
backend/tests/phase6_contract.test.js
new
+6
@@ -0,0 +1,6 @@
1
+import test from 'node:test';
2
+import assert from 'node:assert/strict';
3
+import fs from 'node:fs';
4
+const read=(path)=>fs.readFileSync(new URL(`../${path}`,import.meta.url),'utf8');
5
+test('final feature backend contract exists with privacy and Iran education guards',()=>{const source=read('src/phase6.js');assert.match(source,/secondary_1/);assert.match(source,/menstrual/);assert.match(source,/notification/);assert.match(source,/calendar/);assert.match(source,/chap\.sch\.ir/);assert.match(source,/owner_user_id=\$1/);assert.doesNotMatch(source,/families\/:.*menstrual/i);});
6
+test('final migration defines required tables and grade 7 catalog',()=>{const sql=read('migrations/0005_iran_family_learning.sql');for(const name of ['education_profile','curriculum_subject','textbook_catalog','iran_calendar_event','menstrual_cycle_entry'])assert.match(sql,new RegExp(`create table(?: if not exists)? ${name}`,'i'));assert.match(sql,/alter table notification_preference/i);assert.match(sql,/secondary_1/);assert.match(sql,/\b7\b/);assert.match(sql,/ریاضی/);});
backend/tests/phase6_schema_test.sql
new
+12
@@ -0,0 +1,12 @@
1
+\set ON_ERROR_STOP on
2
+
3
+do $$
4
+begin
5
+ if not exists(select 1 from information_schema.columns where table_name='profile' and column_name='household_persona') then raise exception 'household persona missing'; end if;
6
+ if not exists(select 1 from information_schema.tables where table_name='education_profile') then raise exception 'education profile missing'; end if;
7
+ if not exists(select 1 from information_schema.tables where table_name='menstrual_cycle_entry') then raise exception 'cycle table missing'; end if;
8
+ if (select count(*) from curriculum_subject where national_grade=7 and school_year='1405-1406') < 10 then raise exception 'grade 7 catalog incomplete'; end if;
9
+ if not exists(select 1 from curriculum_subject where national_grade=7 and name_fa='ریاضی') then raise exception 'grade 7 mathematics missing'; end if;
10
+ if exists(select 1 from textbook_catalog where source_host not in ('chap.sch.ir','medu.gov.ir') or source_url !~ '^https://') then raise exception 'untrusted textbook source'; end if;
11
+ if not exists(select 1 from information_schema.columns where table_name='notification_preference' and column_name='sensitive_preview') then raise exception 'sensitive preview control missing'; end if;
12
+end $$;
docs/final/DELIVERY.md
new
+21
@@ -0,0 +1,21 @@
1
+# LifeMate Feature 1 — Final Delivery
2
+
3
+## Installable outputs
4
+Every green CI run retains:
5
+- `lifemate-android-apk` — release APK for owner-side Android installation/testing.
6
+- `lifemate-web-release` — production Web/PWA bundle for controlled hosting/testing.
7
+
8
+## iOS
9
+The Flutter iOS project is present in `apps/lifemate/ios`. A signed `.ipa` requires macOS/Xcode plus the owner's Apple Developer signing identity/provisioning profile. Verification command on an authorized macOS runner: `flutter build ios --release --no-codesign`; distribution requires explicit signing/publication approval.
10
+
11
+## Feature 1 test path
12
+1. Sign in with a test account.
13
+2. Open **پروفایل و خانواده → خانواده و یادگیری ایران**.
14
+3. Choose mother/father/child persona. For a child choose grade 1–12; grade 7 resolves to first year of lower secondary.
15
+4. Verify grade catalog and official textbook-source links.
16
+5. Verify Jalali 1405 event data, Saturday week start and Iran weekend defaults.
17
+6. Verify notification preferences and sensitive-preview default-off behavior through the API-backed settings model.
18
+7. Verify private cycle entries are visible only to the owning account.
19
+
20
+## External gates
21
+Public production release, store publication, Apple signing, production push-provider credentials, external AI/voice enablement, and textbook PDF redistribution remain explicit external gates.
\ No newline at end of file
docs/final/THREE_PHASE_AUDIT.md
new
+62
@@ -0,0 +1,62 @@
1
+# LifeMate — Final Three-Phase Audit
2
+
3
+Date: 2026-10-05
4
+Baseline: `main@22e1115179f11b28a031954692b05ea2d8794c33`
5
+
6
+## Phase A — Functional and product review
7
+
8
+### Confirmed existing
9
+- Identity/session foundation and family workspaces.
10
+- Planner, reminders, school years/terms/subjects, assignments/exams/grades.
11
+- Parent/guardian relationship model and minor-aware authorization.
12
+- Learning/wellbeing/AI advisory vertical slice with explicit plan acceptance.
13
+- Offline cache/queue, responsive Flutter Web/PWA + Android shell.
14
+
15
+### Gaps found
16
+1. Family roles are technical (`parent_guardian`, `teen_minor`, `adult_member`) rather than explicit household personas (mother/father/child) with child sex, birth date/age and education profile.
17
+2. School setup is generic/manual; it does not map Iranian stage + grade to a canonical subject/book catalog.
18
+3. Grade 7 quick setup creates only Mathematics and uses Gregorian-style academic-year defaults.
19
+4. Calendar UI is not Jalali-first and does not expose an official-Iran event/holiday catalog.
20
+5. Reminder UX exists, but there is no unified notification preference model for banner/push/reminder categories.
21
+6. No private menstrual-cycle tracker/reminder surface exists.
22
+7. iOS project structure exists through Flutter, but the release gate does not build an iOS artifact; signed iOS distribution still requires Apple signing/provisioning on macOS.
23
+8. Official textbook PDFs are not bundled. Bundling third-party/copyrighted binaries without a verified redistribution license is not acceptable; the product should keep official source metadata/links and allow lawful import/download.
24
+
25
+## Phase B — Quality, data-integrity and cross-platform review
26
+
27
+### Confirmed existing
28
+- CI runs backend migrations, authorization tests, Node tests, syntax/schema checks, backup/restore drill, Flutter format/analyze/tests, Web release build, Android build and PWA metadata checks.
29
+- Phase 5 branch and post-merge CI were green before this final phase.
30
+
31
+### Gaps to close
32
+- Add contract/schema tests for persona/profile privacy, Iranian education mapping, calendar source metadata, textbook catalog and menstrual privacy.
33
+- Add Flutter tests for Jalali conversion/weekday semantics and Iranian grade mapping.
34
+- Add release artifacts for installable Android APK and Web bundle; document iOS signing gate explicitly.
35
+
36
+## Phase C — Security and privacy review
37
+
38
+### Confirmed existing
39
+- Server-side relationship-aware authorization.
40
+- Private AI/wellbeing transcripts and separate safety ledger.
41
+- Security headers, request IDs, rate limits, bounded request bodies, secret scanning, dependency audit and backup/restore drill.
42
+
43
+### High-priority final controls
44
+- Menstrual data must be owner-private by default and never inherited by family/guardian visibility.
45
+- Child education/persona data must be mutable only by the child owner or an active guardian with explicit relationship.
46
+- Calendar/textbook external URLs must be allowlisted to trusted official sources and never execute remote content.
47
+- Notification preferences must not leak sensitive reminder titles to family members.
48
+- No production AI/voice or public release is enabled by this feature phase.
49
+
50
+## Final-phase scope
51
+
52
+The remaining engineering scope is consolidated as **Feature 1 — Iranian Family & Learning Hub**:
53
+- explicit mother/father/child persona metadata;
54
+- Iranian education stage/grade profile and grade-aware subject catalog;
55
+- Grade 7 curriculum starter catalog and official textbook-source metadata;
56
+- Jalali-first calendar semantics, Iran weekend defaults and official-event data model;
57
+- notification/reminder preferences;
58
+- owner-private menstrual-cycle tracking and reminders;
59
+- Web/Android release artifacts and iOS readiness documentation;
60
+- full regression/security verification.
61
+
62
+Public production deployment, App Store/Play Store publication, Apple signing credentials, external AI/voice enablement, and redistribution of textbook PDFs without verified rights remain external release gates rather than engineering omissions.
\ No newline at end of file
docs/superpowers/plans/2026-10-05-iran-family-learning-hub.md
new
+61
@@ -0,0 +1,61 @@
1
+# Feature 1 — Iranian Family & Learning Hub Implementation Plan
2
+
3
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+**Goal:** Deliver the final owner-testable Iranian family, education, Jalali calendar, reminder-preference and private cycle-tracking feature set.
6
+
7
+**Architecture:** Extend the existing phase-based backend with `0005` + `phase6.js`, expose a compact API client surface, and add a focused Flutter hub without restructuring earlier phases. Preserve existing authorization as the security authority.
8
+
9
+**Tech Stack:** PostgreSQL, Node/Express, Flutter/Dart, GitHub Actions.
10
+
11
+**Spec:** `docs/superpowers/specs/2026-10-05-iran-family-learning-hub-design.md`
12
+
13
+## Global Constraints
14
+- No public production deployment.
15
+- No copyrighted textbook PDF binaries committed without verified redistribution rights.
16
+- Menstrual entries owner-only.
17
+- Persona metadata never grants authorization.
18
+- Jalali week begins Saturday for Iranian locale.
19
+
20
+## Review Focus
21
+- Guardian attempting to read private cycle data must have no route/capability.
22
+- Invalid grade/stage combinations must be rejected.
23
+- Grade 7 must map to secondary first cycle, local year 1.
24
+- Sensitive notification preview defaults off.
25
+- External textbook URLs must be trusted HTTPS sources.
26
+
27
+---
28
+
29
+### Task 1: Red-first contracts
30
+**Files:** create `backend/tests/phase6_contract.test.js`, `backend/tests/phase6_schema_test.sql`; create Flutter pure-model tests.
31
+- [ ] Add failing contract/schema tests for required files/tables/guardrails.
32
+- [ ] Push and observe CI failure before implementation.
33
+
34
+### Task 2: Data model and seed catalog
35
+**Files:** create `backend/migrations/0005_iran_family_learning.sql`.
36
+- [ ] Add persona, education profile, curriculum/textbook, official calendar, notification preference and cycle tables.
37
+- [ ] Seed stage/grade mapping and Grade 7 curriculum metadata.
38
+- [ ] Run migration/schema gates.
39
+
40
+### Task 3: API
41
+**Files:** create `backend/src/phase6.js`; modify `backend/src/server.js`.
42
+- [ ] Implement authenticated owner/guardian-safe profile APIs.
43
+- [ ] Implement catalog/calendar/preferences APIs.
44
+- [ ] Implement owner-only cycle CRUD/list API.
45
+- [ ] Run backend tests and syntax checks.
46
+
47
+### Task 4: Flutter integration
48
+**Files:** create `apps/lifemate/lib/iran_hub.dart`; modify `api.dart`, `phase3_ui.dart`, navigation as required.
49
+- [ ] Add education/persona setup.
50
+- [ ] Add Jalali-first calendar/event view.
51
+- [ ] Add textbook/catalog view using official metadata links.
52
+- [ ] Add notification settings and private cycle tracker.
53
+- [ ] Run format/analyze/widget tests.
54
+
55
+### Task 5: Release outputs
56
+**Files:** modify `.github/workflows/ci.yml`, release docs/state.
57
+- [ ] Retain Web release bundle and Android APK as CI artifacts.
58
+- [ ] Document iOS signing gate and build command.
59
+- [ ] Run full CI and verify all jobs.
60
+- [ ] Open PR, review diff/security, merge only after green CI.
61
+- [ ] Verify post-merge main CI.
\ No newline at end of file
docs/superpowers/specs/2026-10-05-iran-family-learning-hub-design.md
new
+43
@@ -0,0 +1,43 @@
1
+# Feature 1 — Iranian Family & Learning Hub Design
2
+
3
+## Intent
4
+Complete LifeMate's owner-testable family/school/planner experience for an Iranian household. A household can explicitly identify mother, father and children; a child can carry age/sex and Iranian education stage/grade; school setup can use a grade-aware curriculum catalog; planning is Jalali-first with Iranian week semantics and official-event metadata; sensitive menstrual tracking remains strictly private.
5
+
6
+## Architecture
7
+Add one final migration and a focused `phase6` API router rather than restructuring existing phases. Keep current technical authorization roles as the security layer and add household persona as profile metadata. Add canonical education/catalog tables that are safe to seed and user-specific enrollment/profile tables. Flutter consumes the new APIs through a dedicated final-feature surface while retaining Phase 3/4 flows.
8
+
9
+## Privacy and security
10
+- `menstrual_cycle_entry` is owner-only: no family or guardian read endpoint.
11
+- Household persona is presentation metadata; it never grants authorization by itself.
12
+- Child education profile writes require owner or active guardian relationship.
13
+- Textbook catalog stores metadata and official-source URLs, not copyrighted PDF binaries.
14
+- External textbook links are restricted to HTTPS and trusted official hosts.
15
+- Notification preferences are per-user; sensitive reminder previews default off.
16
+
17
+## Iranian education model
18
+Stages: `primary_1` (grades 1–3), `primary_2` (4–6), `secondary_1` (7–9), `secondary_2` (10–12). Store canonical national grade 1–12. Grade 7 maps to `secondary_1`, local year 1.
19
+
20
+The Grade 7 starter catalog includes Persian, Writing, Mathematics, Experimental Sciences, Social Studies, Arabic, Quran, Heavenly Messages, English, Work & Technology, Thinking & Lifestyle, and Physical Education/Health. Catalog rows are versioned by school year and can be updated without changing user records.
21
+
22
+## Textbooks
23
+LifeMate may show catalog metadata and links to official Ministry textbook distribution sources (for example `chap.sch.ir`) and may support user-initiated lawful download/import later. The repository will not embed textbook PDFs unless redistribution rights are verified.
24
+
25
+## Calendar
26
+- Jalali is the default presentation calendar for Iranian locale.
27
+- Week starts Saturday; Thursday/Friday are configurable weekend defaults, with Friday treated as the statutory weekly holiday in the seeded policy.
28
+- Official-event records are versioned by Jalali year and source provenance. 1405 data provenance points to the official calendar process (Calendar Center, Institute of Geophysics, University of Tehran / Supreme Council of Cultural Revolution approvals).
29
+- Calendar data is data-driven so later annual updates do not require UI rewrites.
30
+
31
+## Notifications
32
+Per-user preferences cover in-app banner, push eligibility, reminder categories and sensitive-preview suppression. Existing reminder claims remain the delivery queue until a production push provider is configured.
33
+
34
+## Menstrual tracking
35
+Optional owner-private entries record start/end dates, symptoms/notes, predicted-next date and reminder opt-in. This is a personal wellness organizer, not diagnosis or contraception/fertility advice.
36
+
37
+## Release acceptance
38
+1. Existing regression suite remains green.
39
+2. New schema/contract tests pass.
40
+3. Flutter format/analyze/tests pass.
41
+4. Web release build and Android APK build pass and artifacts are retained in CI.
42
+5. iOS source compiles conceptually through Flutter project configuration; signed iOS binary remains gated on macOS + Apple signing credentials.
43
+6. No production/public deployment occurs automatically.
\ No newline at end of file