# rizz-vizz/kutumbh-care architecture

> Architecture diagram of the GitHub repository rizz-vizz/kutumbh-care, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rizz-vizz/kutumbh-care
- Repository: https://github.com/rizz-vizz/kutumbh-care

## Overview

#### Purpose and Runtime
Kutumbh Care is a Vite/React/TypeScript healthcare PWA concept serving patient/family, clinician, and maternity-care workflows. Browser startup is `src/main.tsx`, which mounts the application in `src/App.tsx`; production static output is under `build/`. The UI is component-driven rather than organized as a separate backend service.

#### Application Shell and Cross-Cutting State
`src/App.tsx` is the likely orchestration boundary for portal/screen selection. Context providers centralize session/demo behavior, language, theme, offline state, and speech support:
- `src/components/auth-context.tsx`
- `src/components/offline-context.tsx`
- `src/components/speech-recognition-context.tsx`

This layer separates shared browser/session capabilities from individual medical workflows.

#### Identity, Onboarding, and Environment Setup
Authentication and demo access are handled in the client-facing auth/onboarding flow, with database setup utilities for bootstrap or recovery:
- `src/components/auth-screen.tsx`
- `src/components/demo-auth-provider.tsx`
- `src/components/database-setup.tsx`

Supabase client connection and setup are isolated under `src/utils/supabase/client.tsx` and `src/utils/supabase/auto-setup.tsx`. The repository includes SQL schemas and fixes, indicating PostgreSQL/Supabase is the persistence and authorization boundary.

#### Patient and Family Care Portal
The patient-facing surface composes household management, records, vitals, consultations, prescription intake, health discovery, pharmacy, and emergency actions:
- `src/components/patient-dashboard.tsx`
- `src/components/family-card.tsx`
- `src/components/vitals-tracker.tsx`

Supporting flows include `teleconsultation.tsx`, `patient-records.tsx`, `prescription-upload.tsx`, `pharmacy-finder.tsx`, and `emergency-panel.tsx`. These components form the primary patient data-entry and care-navigation path.

#### Clinical and Maternal Workspaces
Clinician workflows are grouped around dashboard alerts, patient history, consultations, and prescription authoring:
- `src/components/doctor-dashboard.tsx`
- `src/components/doctor-alert-form.tsx`
- `src/components/prescription-pad.tsx`

Specialized reproductive-health workflows are represented separately by `src/components/pregnancy-dashboard.tsx`, `src/components/period-care.tsx`, and related restored/fixed variants. The component naming suggests iterative UI versions coexist, so consumers should identify which variants `App.tsx` actually mounts.

#### Voice, Accessibility, and Offline Boundaries
Voice-driven navigation and symptom capture are isolated from the core portals:
- `src/components/voice-interface.tsx`
- `src/components/voice-symptom-checker.tsx`
- `src/components/microphone-permission-guard.tsx`

Offline behavior is represented by `offline-context.tsx` and `offline-medical-records.tsx`. Browser APIs—microphone/speech recognition, local storage/IndexedDB as described by the README, and connectivity state—are a client-runtime boundary; synchronization requires Supabase-facing code.

#### Supabase Data and Server Functions
Database schema, migration/fix scripts, and edge/server functions are colocated in `src/supabase/`:
- `src/supabase/basic-schema.sql`
- `src/supabase/comprehensive-schema-fix.sql`
- `src/supabase/functions/server/index.tsx`

Dedicated functions serve survey submission, health checks, demo-user provisioning, and Supercoins administration/user queries. Survey calls are abstracted through `src/utils/survey-api.ts`. Material external infrastructure is Supabase/PostgreSQL with RLS; the README also claims WebRTC, wearable APIs, OCR/NLP, and TensorFlow-based predictive analysis, but corresponding Python/ML or integration source is not present in this tree.

Main entry points: [`src/App.tsx`](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/App.tsx) (Application shell), [`src/utils/supabase/client.tsx`](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/supabase/client.tsx) (Supabase client), [`src/components/auth-context.tsx`](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/auth-context.tsx) (Shared contexts), [`src/components/auth-screen.tsx`](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/auth-screen.tsx) (Auth and onboarding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser PWA"]
  node_startup(("Browser startup<br/>Vite entry<br/>[main.tsx]"))
  node_app["Application shell<br/>React orchestrator<br/>[App.tsx]"]
  node_shared_context["Shared contexts<br/>session and browser state<br/>[auth-context.tsx]"]
  node_auth_onboarding["Auth and onboarding<br/>client flow<br/>[auth-screen.tsx]"]
  node_demo_access["Demo access<br/>auth provider"]
  node_database_setup["Database setup<br/>bootstrap UI<br/>[database-setup.tsx]"]
  node_voice_accessibility["Voice interface<br/>browser accessibility"]
  node_offline_records["Offline medical records<br/>offline workflow"]
end

subgraph group_care["Care Workspaces"]
  node_patient_portal["Patient care portal<br/>patient workspace"]
  node_family_vitals["Family and vitals<br/>patient data entry<br/>[family-card.tsx]"]
  node_clinical_workspace["Clinician workspace<br/>doctor workflow"]
  node_clinical_authoring["Alerts and prescriptions<br/>clinical authoring"]
  node_maternal_workspace["Maternal care workspace<br/>reproductive health"]
end

subgraph group_supabase["Supabase Data Services"]
  node_supabase_client["Supabase client<br/>data client<br/>[client.tsx]"]
  node_setup_automation["Supabase auto-setup<br/>setup utility<br/>[auto-setup.tsx]"]
  node_survey_api["Survey API<br/>function client<br/>[survey-api.ts]"]
  node_edge_functions{{"Server functions<br/>Supabase Edge functions<br/>[index.tsx]"}}
  node_database[("PostgreSQL with RLS<br/>Supabase persistence<br/>[basic-schema.sql]")]
end

node_production_build["Production static output<br/>build artifact"]

node_startup -->|"mounts"| node_app
node_app -->|"uses"| node_shared_context
node_app -->|"routes to"| node_auth_onboarding
node_auth_onboarding -->|"supports"| node_demo_access
node_app -->|"selects"| node_patient_portal
node_patient_portal -->|"composes"| node_family_vitals
node_app -->|"selects"| node_clinical_workspace
node_clinical_workspace -->|"composes"| node_clinical_authoring
node_app -->|"selects"| node_maternal_workspace
node_shared_context -->|"provides speech state"| node_voice_accessibility
node_shared_context -->|"provides offline state"| node_offline_records
node_auth_onboarding -->|"authenticates through"| node_supabase_client
node_database_setup -->|"uses"| node_setup_automation
node_setup_automation -->|"configures"| node_supabase_client
node_patient_portal -->|"reads and writes care data"| node_supabase_client
node_clinical_workspace -->|"reads and writes clinical data"| node_supabase_client
node_offline_records -.->|"synchronizes with"| node_supabase_client
node_survey_api -->|"submits surveys"| node_edge_functions
node_supabase_client -->|"accesses under RLS"| node_database
node_edge_functions -->|"queries and administers"| node_database
node_app -->|"bundled into"| node_production_build

click node_startup "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/main.tsx"
click node_app "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/App.tsx"
click node_shared_context "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/auth-context.tsx"
click node_auth_onboarding "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/auth-screen.tsx"
click node_demo_access "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/demo-auth-provider.tsx"
click node_database_setup "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/database-setup.tsx"
click node_patient_portal "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/patient-dashboard.tsx"
click node_family_vitals "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/family-card.tsx"
click node_clinical_workspace "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/doctor-dashboard.tsx"
click node_clinical_authoring "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/prescription-pad.tsx"
click node_maternal_workspace "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/pregnancy-dashboard.tsx"
click node_voice_accessibility "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/voice-interface.tsx"
click node_offline_records "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/offline-medical-records.tsx"
click node_supabase_client "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/supabase/client.tsx"
click node_setup_automation "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/supabase/auto-setup.tsx"
click node_survey_api "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/survey-api.ts"
click node_edge_functions "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/supabase/functions/server/index.tsx"
click node_database "https://github.com/rizz-vizz/kutumbh-care/blob/main/src/supabase/basic-schema.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_app,node_shared_context,node_auth_onboarding,node_demo_access,node_database_setup,node_voice_accessibility,node_offline_records toneBlue
class node_patient_portal,node_family_vitals,node_clinical_workspace,node_clinical_authoring,node_maternal_workspace toneAmber
class node_supabase_client,node_setup_automation,node_survey_api,node_edge_functions,node_database toneMint
class node_production_build toneNeutral
```

## Components

### Browser PWA

- [Browser startup](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/main.tsx): Vite entry · `src/main.tsx`
- [Application shell](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/App.tsx): React orchestrator · Selects portal and screen flows. · `src/App.tsx`
- [Shared contexts](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/auth-context.tsx): session and browser state · Auth, offline, and speech capabilities are shared here. · `src/components/auth-context.tsx`
- [Auth and onboarding](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/auth-screen.tsx): client flow · `src/components/auth-screen.tsx`
- [Demo access](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/demo-auth-provider.tsx): auth provider · `src/components/demo-auth-provider.tsx`
- [Database setup](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/database-setup.tsx): bootstrap UI · `src/components/database-setup.tsx`
- [Voice interface](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/voice-interface.tsx): browser accessibility · Voice navigation and symptom capture are isolated from portals. · `src/components/voice-interface.tsx`
- [Offline medical records](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/offline-medical-records.tsx): offline workflow · `src/components/offline-medical-records.tsx`

### Care Workspaces

- [Patient care portal](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/patient-dashboard.tsx): patient workspace · Household, records, vitals, care navigation, and emergency actions. · `src/components/patient-dashboard.tsx`
- [Family and vitals](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/family-card.tsx): patient data entry · `src/components/family-card.tsx`
- [Clinician workspace](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/doctor-dashboard.tsx): doctor workflow · Patient history, alerts, consultations, and prescriptions. · `src/components/doctor-dashboard.tsx`
- [Alerts and prescriptions](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/prescription-pad.tsx): clinical authoring · `src/components/prescription-pad.tsx`
- [Maternal care workspace](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/components/pregnancy-dashboard.tsx): reproductive health · `src/components/pregnancy-dashboard.tsx`

### Supabase Data Services

- [Supabase client](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/supabase/client.tsx): data client · `src/utils/supabase/client.tsx`
- [Supabase auto-setup](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/supabase/auto-setup.tsx): setup utility · `src/utils/supabase/auto-setup.tsx`
- [Survey API](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/utils/survey-api.ts): function client · `src/utils/survey-api.ts`
- [Server functions](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/supabase/functions/server/index.tsx): Supabase Edge functions · Provides survey, health check, demo-user, and Supercoins operations. · `src/supabase/functions/server/index.tsx`
- [PostgreSQL with RLS](https://github.com/rizz-vizz/kutumbh-care/blob/main/src/supabase/basic-schema.sql): Supabase persistence · Schema and fixes define the data and authorization boundary. · `src/supabase/basic-schema.sql`

### Other components

- **Production static output**: build artifact

## Connections

- Browser startup → Application shell: mounts
- Application shell → Shared contexts: uses
- Application shell → Auth and onboarding: routes to
- Auth and onboarding → Demo access: supports
- Application shell → Patient care portal: selects
- Patient care portal → Family and vitals: composes
- Application shell → Clinician workspace: selects
- Clinician workspace → Alerts and prescriptions: composes
- Application shell → Maternal care workspace: selects
- Shared contexts → Voice interface: provides speech state
- Shared contexts → Offline medical records: provides offline state
- Auth and onboarding → Supabase client: authenticates through
- Database setup → Supabase auto-setup: uses
- Supabase auto-setup → Supabase client: configures
- Patient care portal → Supabase client: reads and writes care data
- Clinician workspace → Supabase client: reads and writes clinical data
- Offline medical records → Supabase client: synchronizes with
- Survey API → Server functions: submits surveys
- Supabase client → PostgreSQL with RLS: accesses under RLS
- Server functions → PostgreSQL with RLS: queries and administers
- Application shell → Production static output: bundled into
