# naresh-svg/app architecture

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

- Interactive diagram: https://gitdiagram.com/naresh-svg/app
- Repository: https://github.com/naresh-svg/app

## Overview

Rx Clear is a medication-management app for patients and caregivers. Patients onboard, add prescriptions, manage medication schedules and doses, and review wellness, adherence, savings, and medication guidance; caregivers link to a patient and monitor adherence. The frontend calls a FastAPI backend that handles authentication and the medication-related workflows. The backend excerpt shows MongoDB access, dose-event publishing, and an LLM-backed assistant; the README provides no additional capability documentation. Several feature screens and backend routes were not sampled, so their internal relationships are not inferred.

Main entry points: [`frontend/src/api.ts`](https://github.com/naresh-svg/app/blob/main/frontend/src/api.ts) (HTTP API client), [`frontend/app/index.tsx`](https://github.com/naresh-svg/app/blob/main/frontend/app/index.tsx) (App entry routing), [`backend/server.py`](https://github.com/naresh-svg/app/blob/main/backend/server.py) (Dose and schedule API), [`frontend/app/(patient)/dashboard.tsx`](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/dashboard.tsx) (Patient dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Patient and caregiver app"]
  node_entry["App entry routing<br/>[index.tsx]"]
  node_onboarding["Patient onboarding<br/>[onboarding.tsx]"]
  node_settings["Settings and subscription<br/>[settings.tsx]"]
  node_paywall["Subscription paywall<br/>[paywall.tsx]"]
  node_revenuecat["Purchase management<br/>[revenuecat.tsx]"]
  node_api["HTTP API client<br/>[api.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authscreens["Login and signup<br/>[login.tsx]"]
  node_auth["Authentication state<br/>[authContext.tsx]"]
end

subgraph group_meds["Medication management"]
  node_dashboard["Patient dashboard<br/>[dashboard.tsx]"]
  node_prescription["Prescription upload"]
  node_medsview["Medication schedules<br/>[meds.tsx]"]
end

subgraph group_care["Care and insights"]
  node_savingsview["Savings view<br/>[savings.tsx]"]
  node_insights["Insights<br/>[insights.tsx]"]
  node_wellness["Wellness check-in"]
  node_ask["Medication assistant<br/>[ask.tsx]"]
  node_caregiverfeed["Caregiver adherence feed<br/>[feed.tsx]"]
  node_link["Patient linking<br/>[link.tsx]"]
end

subgraph group_backend["Backend services"]
  node_doseapi["Dose and schedule API<br/>[server.py]"]
  node_pricebands["Price estimates<br/>[price_bands.py]"]
end

node_patient(("Patient"))
node_caregiver(("Caregiver"))
node_llm["LLM service"]
node_database[("MongoDB")]
node_realtime["Supabase Realtime"]

node_patient -->|"opens"| node_entry
node_caregiver -->|"opens"| node_entry
node_entry -->|"routes unauthenticated"| node_authscreens
node_entry -->|"routes new patients"| node_onboarding
node_entry -->|"routes returning patients"| node_dashboard
node_entry -->|"routes caregivers"| node_caregiverfeed
node_authscreens -->|"uses"| node_auth
node_auth -->|"calls auth endpoints"| node_api
node_dashboard -->|"renders"| node_prescription
node_prescription -->|"uploads image"| node_api
node_dashboard -->|"renders"| node_wellness
node_medsview -->|"requests medication data"| node_api
node_savingsview -->|"requests savings data"| node_api
node_insights -->|"requests insights data"| node_api
node_wellness -->|"submits check-ins"| node_api
node_ask -.->|"sends questions"| node_api
node_caregiverfeed -->|"loads adherence feed"| node_api
node_caregiverfeed -->|"subscribes to events"| node_realtime
node_link -->|"uses linking endpoints"| node_api
node_settings -->|"uses subscription state"| node_revenuecat
node_paywall -->|"uses purchase flows"| node_revenuecat
node_api -->|"calls backend over HTTP"| node_doseapi
node_doseapi -->|"reads and writes"| node_database
node_doseapi -->|"looks up price bands"| node_pricebands
node_doseapi -->|"requests assistant response"| node_llm

click node_entry "https://github.com/naresh-svg/app/blob/main/frontend/app/index.tsx"
click node_authscreens "https://github.com/naresh-svg/app/blob/main/frontend/app/auth/login.tsx"
click node_auth "https://github.com/naresh-svg/app/blob/main/frontend/src/authContext.tsx"
click node_onboarding "https://github.com/naresh-svg/app/blob/main/frontend/app/onboarding.tsx"
click node_dashboard "https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/dashboard.tsx"
click node_prescription "https://github.com/naresh-svg/app/blob/main/frontend/src/components/UploadPrescriptionModal.tsx"
click node_medsview "https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/meds.tsx"
click node_doseapi "https://github.com/naresh-svg/app/blob/main/backend/server.py"
click node_savingsview "https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/savings.tsx"
click node_pricebands "https://github.com/naresh-svg/app/blob/main/backend/price_bands.py"
click node_insights "https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/insights.tsx"
click node_wellness "https://github.com/naresh-svg/app/blob/main/frontend/src/components/WellnessCheckin.tsx"
click node_ask "https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/ask.tsx"
click node_caregiverfeed "https://github.com/naresh-svg/app/blob/main/frontend/app/(caregiver)/feed.tsx"
click node_link "https://github.com/naresh-svg/app/blob/main/frontend/app/(caregiver)/link.tsx"
click node_settings "https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/settings.tsx"
click node_paywall "https://github.com/naresh-svg/app/blob/main/frontend/app/paywall.tsx"
click node_revenuecat "https://github.com/naresh-svg/app/blob/main/frontend/src/revenuecat.tsx"
click node_api "https://github.com/naresh-svg/app/blob/main/frontend/src/api.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_entry,node_onboarding,node_settings,node_paywall,node_revenuecat,node_api toneBlue
class node_authscreens,node_auth,node_database toneAmber
class node_dashboard,node_prescription,node_medsview toneMint
class node_savingsview,node_insights,node_wellness,node_ask,node_caregiverfeed,node_link toneRose
class node_doseapi,node_pricebands,node_patient,node_caregiver,node_llm,node_realtime toneIndigo
```

## Components

### Patient and caregiver app

- [App entry routing](https://github.com/naresh-svg/app/blob/main/frontend/app/index.tsx): `frontend/app/index.tsx`
- [Patient onboarding](https://github.com/naresh-svg/app/blob/main/frontend/app/onboarding.tsx): `frontend/app/onboarding.tsx`
- [Settings and subscription](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/settings.tsx): `frontend/app/(patient)/settings.tsx`
- [Subscription paywall](https://github.com/naresh-svg/app/blob/main/frontend/app/paywall.tsx): `frontend/app/paywall.tsx`
- [Purchase management](https://github.com/naresh-svg/app/blob/main/frontend/src/revenuecat.tsx): `frontend/src/revenuecat.tsx`
- [HTTP API client](https://github.com/naresh-svg/app/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### Identity and access

- [Login and signup](https://github.com/naresh-svg/app/blob/main/frontend/app/auth/login.tsx): `frontend/app/auth/login.tsx`
- [Authentication state](https://github.com/naresh-svg/app/blob/main/frontend/src/authContext.tsx): `frontend/src/authContext.tsx`

### Medication management

- [Patient dashboard](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/dashboard.tsx): `frontend/app/(patient)/dashboard.tsx`
- [Prescription upload](https://github.com/naresh-svg/app/blob/main/frontend/src/components/UploadPrescriptionModal.tsx): `frontend/src/components/UploadPrescriptionModal.tsx`
- [Medication schedules](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/meds.tsx): `frontend/app/(patient)/meds.tsx`

### Care and insights

- [Savings view](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/savings.tsx): `frontend/app/(patient)/savings.tsx`
- [Insights](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/insights.tsx): `frontend/app/(patient)/insights.tsx`
- [Wellness check-in](https://github.com/naresh-svg/app/blob/main/frontend/src/components/WellnessCheckin.tsx): `frontend/src/components/WellnessCheckin.tsx`
- [Medication assistant](https://github.com/naresh-svg/app/blob/main/frontend/app/(patient)/ask.tsx): `frontend/app/(patient)/ask.tsx`
- [Caregiver adherence feed](https://github.com/naresh-svg/app/blob/main/frontend/app/(caregiver)/feed.tsx): `frontend/app/(caregiver)/feed.tsx`
- [Patient linking](https://github.com/naresh-svg/app/blob/main/frontend/app/(caregiver)/link.tsx): `frontend/app/(caregiver)/link.tsx`

### Backend services

- [Dose and schedule API](https://github.com/naresh-svg/app/blob/main/backend/server.py): `backend/server.py`
- [Price estimates](https://github.com/naresh-svg/app/blob/main/backend/price_bands.py): `backend/price_bands.py`

### Other components

- **Patient**
- **Caregiver**
- **LLM service**
- **MongoDB**
- **Supabase Realtime**

## Connections

- Patient → App entry routing: opens
- Caregiver → App entry routing: opens
- App entry routing → Login and signup: routes unauthenticated (evidence: `frontend/app/index.tsx`)
- App entry routing → Patient onboarding: routes new patients (evidence: `frontend/app/index.tsx`)
- App entry routing → Patient dashboard: routes returning patients (evidence: `frontend/app/index.tsx`)
- App entry routing → Caregiver adherence feed: routes caregivers (evidence: `frontend/app/index.tsx`)
- Login and signup → Authentication state: uses (evidence: `frontend/app/auth/login.tsx`)
- Authentication state → HTTP API client: calls auth endpoints (evidence: `frontend/src/authContext.tsx`)
- Patient dashboard → Prescription upload: renders (evidence: `frontend/app/(patient)/dashboard.tsx`)
- Prescription upload → HTTP API client: uploads image (evidence: `frontend/src/components/UploadPrescriptionModal.tsx`)
- Patient dashboard → Wellness check-in: renders (evidence: `frontend/app/(patient)/dashboard.tsx`)
- Medication schedules → HTTP API client: requests medication data (evidence: `frontend/app/(patient)/meds.tsx`)
- Savings view → HTTP API client: requests savings data (evidence: `frontend/app/(patient)/savings.tsx`)
- Insights → HTTP API client: requests insights data (evidence: `frontend/app/(patient)/insights.tsx`)
- Wellness check-in → HTTP API client: submits check-ins (evidence: `frontend/src/components/WellnessCheckin.tsx`)
- Medication assistant → HTTP API client: sends questions
- Caregiver adherence feed → HTTP API client: loads adherence feed (evidence: `frontend/app/(caregiver)/feed.tsx`)
- Caregiver adherence feed → Supabase Realtime: subscribes to events (evidence: `frontend/app/(caregiver)/feed.tsx`)
- Patient linking → HTTP API client: uses linking endpoints (evidence: `frontend/app/(caregiver)/link.tsx`)
- Settings and subscription → Purchase management: uses subscription state (evidence: `frontend/app/(patient)/settings.tsx`)
- Subscription paywall → Purchase management: uses purchase flows (evidence: `frontend/app/paywall.tsx`)
- HTTP API client → Dose and schedule API: calls backend over HTTP (evidence: `frontend/src/api.ts`)
- Dose and schedule API → MongoDB: reads and writes (evidence: `backend/server.py`)
- Dose and schedule API → Price estimates: looks up price bands (evidence: `backend/server.py`)
- Dose and schedule API → LLM service: requests assistant response (evidence: `backend/server.py`)
