# chettyv/sandhya architecture

> Architecture diagram of the GitHub repository chettyv/sandhya, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chettyv/sandhya
- Repository: https://github.com/chettyv/sandhya

## Overview

Sandhya is an offline-capable daily Hindu learning and practice app. The main user journey starts with onboarding and leads into daily verses and reflections, scripture reading, practices, and supporting features such as saved items, a private journal, and festival guides. The mobile app is the current product; AI answering and challenge purchases are deferred and default off. The graph includes the documented backend and corpus pipeline, but source evidence is incomplete, so uncertain runtime connections are omitted.

Main entry points: [`packages/rag-pipeline/src/index.ts`](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/index.ts) (RAG runtime), [`supabase/functions/ask/index.ts`](https://github.com/chettyv/sandhya/blob/main/supabase/functions/ask/index.ts) (AI answer endpoint), [`packages/rag-pipeline/src/ingest-prepared.ts`](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/ingest-prepared.ts) (Prepared ingestion), [`apps/mobile/src/features/onboarding/engine.ts`](https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/features/onboarding/engine.ts) (Onboarding flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile experience"]
  node_onboarding["Onboarding flow<br/>[engine.ts]"]
  node_onboarding_steps["Onboarding steps<br/>[steps.ts]"]
  node_daily["Daily learning<br/>[index.tsx]"]
  node_scripture["Scripture reading<br/>[&#91;chapter&#93;.tsx]"]
  node_practice["Practices<br/>[&#91;id&#93;.tsx]"]
  node_festivals["Festival guides<br/>[&#91;id&#93;.tsx]"]
end

subgraph group_personal["Personal practice"]
  node_saved["Saved items<br/>[saved.tsx]"]
  node_journal["Private journal"]
  node_secure_storage[("Secure storage<br/>[secureStorage.ts]")]
  node_chunked_storage["Chunked storage<br/>[chunkedStorage.ts]"]
end

subgraph group_backend["Backend services"]
  node_account["Account service<br/>[index.ts]"]
  node_push_registration["Push registration<br/>[index.ts]"]
  node_daily_reflections["Reflection delivery<br/>[index.ts]"]
  node_ask["AI answer endpoint<br/>[index.ts]"]
  node_retrieval_policy["Retrieval policy<br/>[retrieval.ts]"]
  node_classifier["Question classifier<br/>[classifier.ts]"]
end

subgraph group_corpus["Corpus and retrieval"]
  node_rag_engine["RAG runtime<br/>[index.ts]"]
  node_rag_classifier["RAG classifier<br/>[classifier.ts]"]
  node_rag_providers["Model providers<br/>[providers.ts]"]
  node_rag_safety["Answer safety<br/>[safety.ts]"]
  node_rag_ingest["Prepared ingestion<br/>[ingest-prepared.ts]"]
  node_source_rights["Source rights<br/>[source-rights.ts]"]
  node_rag_rest["Supabase REST<br/>[supabase-rest.ts]"]
end

node_learner(("Learner"))

node_learner -->|"starts setup"| node_onboarding
node_learner -->|"views daily content"| node_daily
node_learner -->|"reads scripture"| node_scripture
node_learner -->|"uses practices"| node_practice
node_learner -->|"views guides"| node_festivals
node_learner -->|"saves items"| node_saved
node_learner -->|"writes privately"| node_journal
node_onboarding -->|"uses steps"| node_onboarding_steps
node_chunked_storage -->|"stores chunks"| node_secure_storage
node_journal -->|"reads and writes"| node_secure_storage
node_ask -->|"classifies questions"| node_classifier
node_ask -.->|"uses retrieval policy"| node_retrieval_policy
node_rag_engine -->|"checks cacheability"| node_rag_classifier
node_rag_engine -->|"validates answers"| node_rag_providers
node_rag_engine -->|"applies safety gate"| node_rag_safety
node_rag_ingest -->|"checks rights"| node_source_rights
node_rag_ingest -.->|"writes corpus"| node_rag_rest

click node_onboarding "https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/features/onboarding/engine.ts"
click node_onboarding_steps "https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/features/onboarding/steps.ts"
click node_daily "https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/(tabs)/index.tsx"
click node_scripture "https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/read/%5Bchapter%5D.tsx"
click node_practice "https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/practice/%5Bid%5D.tsx"
click node_festivals "https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/festival/%5Bid%5D.tsx"
click node_saved "https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/saved.tsx"
click node_journal "https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/lib/localJournalStorage.ts"
click node_secure_storage "https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/lib/secureStorage.ts"
click node_chunked_storage "https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/lib/chunkedStorage.ts"
click node_account "https://github.com/chettyv/sandhya/blob/main/supabase/functions/account/index.ts"
click node_push_registration "https://github.com/chettyv/sandhya/blob/main/supabase/functions/register-push-token/index.ts"
click node_daily_reflections "https://github.com/chettyv/sandhya/blob/main/supabase/functions/send-daily-reflections/index.ts"
click node_ask "https://github.com/chettyv/sandhya/blob/main/supabase/functions/ask/index.ts"
click node_retrieval_policy "https://github.com/chettyv/sandhya/blob/main/supabase/functions/_shared/retrieval.ts"
click node_classifier "https://github.com/chettyv/sandhya/blob/main/supabase/functions/_shared/classifier.ts"
click node_rag_engine "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/index.ts"
click node_rag_classifier "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/classifier.ts"
click node_rag_providers "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/providers.ts"
click node_rag_safety "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/safety.ts"
click node_rag_ingest "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/ingest-prepared.ts"
click node_source_rights "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/source-rights.ts"
click node_rag_rest "https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/supabase-rest.ts"

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_onboarding,node_onboarding_steps,node_daily,node_scripture,node_practice,node_festivals toneBlue
class node_saved,node_journal,node_secure_storage,node_chunked_storage toneAmber
class node_account,node_push_registration,node_daily_reflections,node_ask,node_retrieval_policy,node_classifier toneMint
class node_rag_engine,node_rag_classifier,node_rag_providers,node_rag_safety,node_rag_ingest,node_source_rights,node_rag_rest toneRose
class node_learner toneIndigo
```

## Components

### Mobile experience

- [Onboarding flow](https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/features/onboarding/engine.ts): `apps/mobile/src/features/onboarding/engine.ts`
- [Onboarding steps](https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/features/onboarding/steps.ts): `apps/mobile/src/features/onboarding/steps.ts`
- [Daily learning](https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/(tabs)/index.tsx): `apps/mobile/app/(tabs)/index.tsx`
- [Scripture reading](https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/read/%5Bchapter%5D.tsx): `apps/mobile/app/read/[chapter].tsx`
- [Practices](https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/practice/%5Bid%5D.tsx): `apps/mobile/app/practice/[id].tsx`
- [Festival guides](https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/festival/%5Bid%5D.tsx): `apps/mobile/app/festival/[id].tsx`

### Personal practice

- [Saved items](https://github.com/chettyv/sandhya/blob/main/apps/mobile/app/saved.tsx): `apps/mobile/app/saved.tsx`
- [Private journal](https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/lib/localJournalStorage.ts): `apps/mobile/src/lib/localJournalStorage.ts`
- [Secure storage](https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/lib/secureStorage.ts): `apps/mobile/src/lib/secureStorage.ts`
- [Chunked storage](https://github.com/chettyv/sandhya/blob/main/apps/mobile/src/lib/chunkedStorage.ts): `apps/mobile/src/lib/chunkedStorage.ts`

### Backend services

- [Account service](https://github.com/chettyv/sandhya/blob/main/supabase/functions/account/index.ts): `supabase/functions/account/index.ts`
- [Push registration](https://github.com/chettyv/sandhya/blob/main/supabase/functions/register-push-token/index.ts): `supabase/functions/register-push-token/index.ts`
- [Reflection delivery](https://github.com/chettyv/sandhya/blob/main/supabase/functions/send-daily-reflections/index.ts): `supabase/functions/send-daily-reflections/index.ts`
- [AI answer endpoint](https://github.com/chettyv/sandhya/blob/main/supabase/functions/ask/index.ts): `supabase/functions/ask/index.ts`
- [Retrieval policy](https://github.com/chettyv/sandhya/blob/main/supabase/functions/_shared/retrieval.ts): `supabase/functions/_shared/retrieval.ts`
- [Question classifier](https://github.com/chettyv/sandhya/blob/main/supabase/functions/_shared/classifier.ts): `supabase/functions/_shared/classifier.ts`

### Corpus and retrieval

- [RAG runtime](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/index.ts): `packages/rag-pipeline/src/index.ts`
- [RAG classifier](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/classifier.ts): `packages/rag-pipeline/src/classifier.ts`
- [Model providers](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/providers.ts): `packages/rag-pipeline/src/providers.ts`
- [Answer safety](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/safety.ts): `packages/rag-pipeline/src/safety.ts`
- [Prepared ingestion](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/ingest-prepared.ts): `packages/rag-pipeline/src/ingest-prepared.ts`
- [Source rights](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/source-rights.ts): `packages/rag-pipeline/src/source-rights.ts`
- [Supabase REST](https://github.com/chettyv/sandhya/blob/main/packages/rag-pipeline/src/supabase-rest.ts): `packages/rag-pipeline/src/supabase-rest.ts`

### Other components

- **Learner**

## Connections

- Learner → Onboarding flow: starts setup (evidence: `README.md`)
- Learner → Daily learning: views daily content (evidence: `README.md`)
- Learner → Scripture reading: reads scripture (evidence: `README.md`)
- Learner → Practices: uses practices (evidence: `README.md`)
- Learner → Festival guides: views guides (evidence: `README.md`)
- Learner → Saved items: saves items (evidence: `README.md`)
- Learner → Private journal: writes privately (evidence: `README.md`)
- Onboarding flow → Onboarding steps: uses steps (evidence: `apps/mobile/src/features/onboarding/engine.ts`)
- Chunked storage → Secure storage: stores chunks (evidence: `apps/mobile/src/lib/chunkedStorage.ts`)
- Private journal → Secure storage: reads and writes (evidence: `apps/mobile/src/lib/localJournalStorage.ts`)
- AI answer endpoint → Question classifier: classifies questions (evidence: `supabase/functions/ask/index.ts`)
- AI answer endpoint → Retrieval policy: uses retrieval policy (evidence: `supabase/functions/ask/index.ts`)
- RAG runtime → RAG classifier: checks cacheability (evidence: `packages/rag-pipeline/src/index.ts`)
- RAG runtime → Model providers: validates answers (evidence: `packages/rag-pipeline/src/index.ts`)
- RAG runtime → Answer safety: applies safety gate (evidence: `packages/rag-pipeline/src/index.ts`)
- Prepared ingestion → Source rights: checks rights (evidence: `packages/rag-pipeline/src/ingest-prepared.ts`)
- Prepared ingestion → Supabase REST: writes corpus
