# prajubs7/schemesarthi architecture

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

- Interactive diagram: https://gitdiagram.com/prajubs7/schemesarthi
- Repository: https://github.com/prajubs7/schemesarthi

## Overview

SchemeSarthi is a mobile app for discovering public-benefit schemes. Users authenticate, provide an eligibility profile, receive personalized matches, browse scheme listings and details, and save bookmarks; a separate Q&A feature is also present in the source tree. The sampled code confirms profile submission and the matching function’s profile-read, embedding, eligibility-match, and result-write stages. Other screen/service wiring is inferred only at the subsystem level from filenames; the README is React Native boilerplate and documents no product-specific capabilities.

Main entry points: [`supabase/functions/match-schemes/index.ts`](https://github.com/prajubs7/schemesarthi/blob/main/supabase/functions/match-schemes/index.ts) (Scheme matching function), [`src/services/supabase.ts`](https://github.com/prajubs7/schemesarthi/blob/main/src/services/supabase.ts) (Supabase client), [`src/services/schemesApi.ts`](https://github.com/prajubs7/schemesarthi/blob/main/src/services/schemesApi.ts) (Scheme service), [`src/hooks/useSchemeMatches.ts`](https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useSchemeMatches.ts) (Scheme query hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App navigation"]
  node_root["Root navigator<br/>[RootNavigator.tsx]"]
  node_authnav["Authentication stack<br/>[AuthStack.tsx]"]
  node_homenav["Home navigation<br/>[HomeStack.tsx]"]
  node_tabs["Main tabs"]
end

subgraph group_profile["Identity and profile"]
  node_login["Login and signup<br/>[LoginScreen.tsx]"]
  node_otp["OTP verification"]
  node_profileform["Profile setup"]
  node_profileview["Profile screen<br/>[ProfileScreen.tsx]"]
  node_authhook["Auth session hook<br/>[useAuth.ts]"]
end

subgraph group_discovery["Scheme discovery"]
  node_home["Personalized home<br/>[HomeScreen.tsx]"]
  node_matched["Matched schemes"]
  node_browse["Scheme browsing<br/>[SchemesScreen.tsx]"]
  node_detail["Scheme details"]
  node_bookmarks["Saved schemes"]
  node_qa["Scheme Q&amp;A<br/>[SchemeQAScreen.tsx]"]
  node_matchhook["Scheme query hooks"]
  node_bookmarkhook["Bookmark query hook<br/>[useBookmarks.ts]"]
end

subgraph group_data["Backend and matching"]
  node_profileapi["Profile service<br/>[profileApi.ts]"]
  node_schemeapi["Scheme service<br/>[schemesApi.ts]"]
  node_bookmarkapi["Bookmark service<br/>[bookmarksApi.ts]"]
  node_qaapi["Q&amp;A service<br/>[qaApi.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_matchfn["Scheme matching function<br/>[index.ts]"]
  node_database[("Supabase data store")]
end

node_person(("App user"))
node_gemini["Gemini embeddings"]

node_person -->|"opens app"| node_root
node_root -->|"routes unauthenticated"| node_authnav
node_root -->|"routes app"| node_tabs
node_authnav -->|"presents auth"| node_login
node_authnav -->|"presents verification"| node_otp
node_person -->|"submits profile"| node_profileform
node_profileform -->|"saves profile"| node_profileapi
node_profileform -->|"starts matching"| node_schemeapi
node_authhook -->|"reads session"| node_supabase
node_tabs -->|"routes home"| node_homenav
node_homenav -->|"presents home"| node_home
node_home -->|"loads matches"| node_matchhook
node_matched -->|"loads matches"| node_matchhook
node_browse -->|"loads schemes"| node_matchhook
node_home -->|"loads bookmarks"| node_bookmarkhook
node_bookmarks -->|"manages bookmarks"| node_bookmarkhook
node_detail -.->|"manages saved scheme"| node_bookmarkhook
node_qa -->|"requests answers"| node_qaapi
node_matchhook -->|"requests schemes"| node_schemeapi
node_bookmarkhook -->|"requests bookmarks"| node_bookmarkapi
node_profileapi -->|"accesses backend"| node_supabase
node_schemeapi -->|"accesses backend"| node_supabase
node_schemeapi -->|"invokes matching"| node_matchfn
node_bookmarkapi -->|"accesses backend"| node_supabase
node_qaapi -.->|"accesses backend"| node_supabase
node_matchfn -->|"reads profile"| node_database
node_matchfn -->|"embeds profile text"| node_gemini
node_matchfn -->|"queries eligible schemes"| node_database
node_matchfn -->|"upserts matches"| node_database

click node_root "https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/RootNavigator.tsx"
click node_authnav "https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/AuthStack.tsx"
click node_homenav "https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/HomeStack.tsx"
click node_tabs "https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/MainTabNavigator.tsx"
click node_login "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/auth/LoginScreen.tsx"
click node_otp "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/auth/OtpVerifyScreen.tsx"
click node_profileform "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/profile/ProfileSetupScreen.tsx"
click node_profileview "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/profile/ProfileScreen.tsx"
click node_home "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/home/HomeScreen.tsx"
click node_matched "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/home/MatchedSchemesScreen.tsx"
click node_browse "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/schemes/SchemesScreen.tsx"
click node_detail "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/home/SchemeDetailScreen.tsx"
click node_bookmarks "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/bookmarks/BookmarksScreen.tsx"
click node_qa "https://github.com/prajubs7/schemesarthi/blob/main/src/screens/qa/SchemeQAScreen.tsx"
click node_authhook "https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useAuth.ts"
click node_profileapi "https://github.com/prajubs7/schemesarthi/blob/main/src/services/profileApi.ts"
click node_matchhook "https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useSchemeMatches.ts"
click node_schemeapi "https://github.com/prajubs7/schemesarthi/blob/main/src/services/schemesApi.ts"
click node_bookmarkhook "https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useBookmarks.ts"
click node_bookmarkapi "https://github.com/prajubs7/schemesarthi/blob/main/src/services/bookmarksApi.ts"
click node_qaapi "https://github.com/prajubs7/schemesarthi/blob/main/src/services/qaApi.ts"
click node_supabase "https://github.com/prajubs7/schemesarthi/blob/main/src/services/supabase.ts"
click node_matchfn "https://github.com/prajubs7/schemesarthi/blob/main/supabase/functions/match-schemes/index.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_root,node_authnav,node_homenav,node_tabs,node_person toneBlue
class node_login,node_otp,node_profileform,node_profileview,node_authhook toneAmber
class node_home,node_matched,node_browse,node_detail,node_bookmarks,node_qa,node_matchhook,node_bookmarkhook toneMint
class node_profileapi,node_schemeapi,node_bookmarkapi,node_qaapi,node_supabase,node_matchfn,node_database toneRose
class node_gemini toneIndigo
```

## Components

### App navigation

- [Root navigator](https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/RootNavigator.tsx): `src/navigation/RootNavigator.tsx`
- [Authentication stack](https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/AuthStack.tsx): `src/navigation/AuthStack.tsx`
- [Home navigation](https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/HomeStack.tsx): `src/navigation/HomeStack.tsx`
- [Main tabs](https://github.com/prajubs7/schemesarthi/blob/main/src/navigation/MainTabNavigator.tsx): `src/navigation/MainTabNavigator.tsx`

### Identity and profile

- [Login and signup](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/auth/LoginScreen.tsx): `src/screens/auth/LoginScreen.tsx`
- [OTP verification](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/auth/OtpVerifyScreen.tsx): `src/screens/auth/OtpVerifyScreen.tsx`
- [Profile setup](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/profile/ProfileSetupScreen.tsx): `src/screens/profile/ProfileSetupScreen.tsx`
- [Profile screen](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/profile/ProfileScreen.tsx): `src/screens/profile/ProfileScreen.tsx`
- [Auth session hook](https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useAuth.ts): `src/hooks/useAuth.ts`

### Scheme discovery

- [Personalized home](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/home/HomeScreen.tsx): `src/screens/home/HomeScreen.tsx`
- [Matched schemes](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/home/MatchedSchemesScreen.tsx): `src/screens/home/MatchedSchemesScreen.tsx`
- [Scheme browsing](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/schemes/SchemesScreen.tsx): `src/screens/schemes/SchemesScreen.tsx`
- [Scheme details](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/home/SchemeDetailScreen.tsx): `src/screens/home/SchemeDetailScreen.tsx`
- [Saved schemes](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/bookmarks/BookmarksScreen.tsx): `src/screens/bookmarks/BookmarksScreen.tsx`
- [Scheme Q&A](https://github.com/prajubs7/schemesarthi/blob/main/src/screens/qa/SchemeQAScreen.tsx): `src/screens/qa/SchemeQAScreen.tsx`
- [Scheme query hooks](https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useSchemeMatches.ts): `src/hooks/useSchemeMatches.ts`
- [Bookmark query hook](https://github.com/prajubs7/schemesarthi/blob/main/src/hooks/useBookmarks.ts): `src/hooks/useBookmarks.ts`

### Backend and matching

- [Profile service](https://github.com/prajubs7/schemesarthi/blob/main/src/services/profileApi.ts): `src/services/profileApi.ts`
- [Scheme service](https://github.com/prajubs7/schemesarthi/blob/main/src/services/schemesApi.ts): `src/services/schemesApi.ts`
- [Bookmark service](https://github.com/prajubs7/schemesarthi/blob/main/src/services/bookmarksApi.ts): `src/services/bookmarksApi.ts`
- [Q&A service](https://github.com/prajubs7/schemesarthi/blob/main/src/services/qaApi.ts): `src/services/qaApi.ts`
- [Supabase client](https://github.com/prajubs7/schemesarthi/blob/main/src/services/supabase.ts): `src/services/supabase.ts`
- [Scheme matching function](https://github.com/prajubs7/schemesarthi/blob/main/supabase/functions/match-schemes/index.ts): `supabase/functions/match-schemes/index.ts`
- **Supabase data store**

### Other components

- **App user**
- **Gemini embeddings**

## Connections

- App user → Root navigator: opens app
- Root navigator → Authentication stack: routes unauthenticated
- Root navigator → Main tabs: routes app
- Authentication stack → Login and signup: presents auth
- Authentication stack → OTP verification: presents verification
- App user → Profile setup: submits profile
- Profile setup → Profile service: saves profile
- Profile setup → Scheme service: starts matching
- Auth session hook → Supabase client: reads session
- Main tabs → Home navigation: routes home
- Home navigation → Personalized home: presents home
- Personalized home → Scheme query hooks: loads matches
- Matched schemes → Scheme query hooks: loads matches
- Scheme browsing → Scheme query hooks: loads schemes
- Personalized home → Bookmark query hook: loads bookmarks
- Saved schemes → Bookmark query hook: manages bookmarks
- Scheme details → Bookmark query hook: manages saved scheme
- Scheme Q&A → Q&A service: requests answers
- Scheme query hooks → Scheme service: requests schemes
- Bookmark query hook → Bookmark service: requests bookmarks
- Profile service → Supabase client: accesses backend
- Scheme service → Supabase client: accesses backend
- Scheme service → Scheme matching function: invokes matching
- Bookmark service → Supabase client: accesses backend
- Q&A service → Supabase client: accesses backend
- Scheme matching function → Supabase data store: reads profile
- Scheme matching function → Gemini embeddings: embeds profile text
- Scheme matching function → Supabase data store: queries eligible schemes
- Scheme matching function → Supabase data store: upserts matches
