Architecture

Technical Specifications

Screens, models, services, and end-to-end workflows.

Flutter client + Supabase backend. Key modules, data contracts, and async flows are summarized below.

Architecture Overview

The app is a Flutter client backed by Supabase (auth + Postgres + edge functions). Practice tracking, profiles, and calendar data flow through Supabase, with local notifications for reminders. Below is a high-level architecture diagram:

App Architecture Diagram

Release requirements (from current code)

Flutter UI
  ├─ Screens (stateful widgets)
  │    ├─ Onboarding, Contact, Mentor/Children
  │    ├─ Home (Practice/Overview/Calendar)
  │    └─ Settings (MFA, notifications)
  ├─ Widgets (practice rows, cards, pickers)
  └─ State mgmt: local setState + async calls

Domain/Models
  ├─ Devotee, DevoteeContext, DevoteeDraft
  ├─ DailyTargets (target catalog)
  └─ DailyTracking (per-day saved entries)

Services
  ├─ Supabase (auth, db, functions, MFA)
  ├─ NotificationService (local notifications)
  └─ StatisticsRepository (charts/stats)

Backend (Supabase)
  ├─ Tables: devotees, daily_tracking, mentors, seva_services
  ├─ MFA via Supabase Auth (GoTrue)
  └─ Edge functions: vaishnava_calendar
        

Screens

Onboarding

Contact/Profile

Mentor & Children

Home

Settings

Models & Targets

Target Resolution

Services & Data

Workflows

Profile & Target Workflow

Onboarding → Contact/University → Mentor/Children → Credentials
  ↓ builds DevoteeDraft (status, age, appGroup, family JSON)
Save to Supabase (devotees.familyMembers JSON, mentor/guide IDs)
Home init:
  - Load devotee by auth_id/email
  - If family JSON empty, load dependents by parent_id
  - Build DevoteeContext per profile → getTargetsForPerson
  - Render Practice/Overview with resolved targets
        

Practice Save Workflow

User updates practice rows (rounds/time, reading/hearing, kirtan, seva, arati)
  → setState (per profile) → _saveTracking()
  → upsert daily_tracking (profile_key, date, rounds, japa_time, reading_minutes, hearing_minutes, kirtan_minutes, service_hours, seva_breakdown, flags)
Overview progress:
  roundsProgress: rounds / targetRounds
  associationProgress: (read+hear+kirtan) / targetAssoc (capped for OR profiles)
  sevaProgress: serviceHours / (targetSeva/30)
  overall: average of three
        

MFA TOTP Workflow

Start setup:
  - listFactors → unenroll unverified TOTP
  - enroll totp (unique friendly name) → receive secret + uri + factorId
  - show QR + URI + secret + copy/share buttons
Verify:
  - challenge(factorId) → challengeId
  - verify(factorId, challengeId, code) → enable MFA
Disable:
  - unenroll(factorId)
        

Calendar Workflow

On init:
  - call edge function vaishnava_calendar
  - if fail/empty → fallback sample
  - schedule notifications for days
Mounted checks guard setState after navigation
        

Seva Services Workflow

On init:
  - select * from seva_services where active = true order by sort_order
  - replace default list; rebuild breakdown keys
  - on failure, retain defaults
User edits breakdown → save in daily_tracking for the selected profile