# developer-yash04/aarogyan architecture

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

- Interactive diagram: https://gitdiagram.com/developer-yash04/aarogyan
- Repository: https://github.com/developer-yash04/aarogyan

## Overview

Aarogyan is a role-based clinical-trial matching product: patients can import FHIR health records and use a privacy-preserving proof workflow, while hospitals, researchers, and inspectors have separate workspaces. The current router and authentication flow are visible, as are the EHR parser, server authentication/trial/credential routes, and proof worker. The excerpts do not establish how the worker or contract deployment is invoked, nor all dashboard-to-backend calls, so those links are omitted.

Main entry points: [`web/src/components/auth/WalletConnect.tsx`](https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/auth/WalletConnect.tsx) (Wallet sign-in), [`web/src/App.tsx`](https://github.com/developer-yash04/aarogyan/blob/main/web/src/App.tsx) (Role router), [`web/src/pages/PatientDashboard.tsx`](https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/PatientDashboard.tsx) (Patient workspace), [`web/src/pages/HospitalDashboard.tsx`](https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/HospitalDashboard.tsx) (Hospital workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Role router<br/>[App.tsx]"]
  node_auth["Auth context<br/>[useAuth.tsx]"]
  node_wallet["Wallet sign-in<br/>[WalletConnect.tsx]"]
  node_patient["Patient workspace"]
  node_hospital["Hospital workspace"]
  node_researcher["Research workspace"]
  node_inspector["Inspector workspace"]
end

subgraph group_clinical["Clinical workflow"]
  node_hospital_portal["Hospital portal<br/>[HospitalPortal.tsx]"]
  node_ehr_importer["EHR importer<br/>[EHRImporter.tsx]"]
  node_fhir_parser["FHIR parser<br/>[fhirParser.ts]"]
  node_domain_types["Clinical data types<br/>[aarogyan.ts]"]
end

subgraph group_services["Identity and services"]
  node_api["API routes<br/>[index.ts]"]
  node_models["Data models<br/>[db.js]"]
  node_database[("SQLite database<br/>[db.js]")]
end

subgraph group_chain["Proof and blockchain"]
  node_proof_worker["ZK proof worker<br/>[zkProofWorker.ts]"]
  node_abi["Contract interface<br/>[aarogyanAbi.ts]"]
  node_chain_inspector["On-chain inspector"]
  node_contract["Aarogyan contract module<br/>[AarogyanModule.ts]"]
end

node_user(("Portal user"))
node_ethereum{{"Ethereum wallet and chain"}}

node_user -->|"opens portal"| node_app
node_app -->|"routes to"| node_patient
node_app -->|"routes to"| node_hospital
node_app -->|"routes to"| node_researcher
node_app -->|"routes to"| node_inspector
node_app -->|"provides context"| node_auth
node_patient -->|"prompts sign-in"| node_wallet
node_hospital -->|"prompts sign-in"| node_wallet
node_researcher -->|"prompts sign-in"| node_wallet
node_inspector -->|"prompts sign-in"| node_wallet
node_wallet -->|"requests signature"| node_ethereum
node_wallet -->|"requests nonce"| node_api
node_wallet -->|"submits login"| node_auth
node_auth -->|"verifies session"| node_api
node_api -->|"queries models"| node_models
node_models -->|"stores records"| node_database
node_patient -->|"opens importer"| node_ehr_importer
node_ehr_importer -->|"parses bundle"| node_fhir_parser
node_ehr_importer -->|"returns parsed data"| node_patient
node_hospital -.->|"hosts portal"| node_hospital_portal
node_hospital_portal -->|"uses clinical types"| node_domain_types
node_fhir_parser -.->|"produces patient data"| node_domain_types
node_proof_worker -.->|"prepares proof for submission"| node_ethereum
node_chain_inspector -->|"uses interface"| node_abi
node_chain_inspector -.->|"queries chain"| node_ethereum
node_contract -.->|"deploys to"| node_ethereum

click node_app "https://github.com/developer-yash04/aarogyan/blob/main/web/src/App.tsx"
click node_auth "https://github.com/developer-yash04/aarogyan/blob/main/web/src/hooks/useAuth.tsx"
click node_wallet "https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/auth/WalletConnect.tsx"
click node_patient "https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/PatientDashboard.tsx"
click node_hospital "https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/HospitalDashboard.tsx"
click node_researcher "https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/ResearcherDashboard.tsx"
click node_inspector "https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/InspectorDashboard.tsx"
click node_hospital_portal "https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/HospitalPortal.tsx"
click node_ehr_importer "https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/EHRImporter.tsx"
click node_fhir_parser "https://github.com/developer-yash04/aarogyan/blob/main/web/src/utils/fhirParser.ts"
click node_domain_types "https://github.com/developer-yash04/aarogyan/blob/main/web/src/types/aarogyan.ts"
click node_api "https://github.com/developer-yash04/aarogyan/blob/main/server/index.ts"
click node_models "https://github.com/developer-yash04/aarogyan/blob/main/server/db.js"
click node_database "https://github.com/developer-yash04/aarogyan/blob/main/server/db.js"
click node_proof_worker "https://github.com/developer-yash04/aarogyan/blob/main/web/src/workers/zkProofWorker.ts"
click node_abi "https://github.com/developer-yash04/aarogyan/blob/main/web/src/contracts/aarogyanAbi.ts"
click node_chain_inspector "https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/OnChainInspector.tsx"
click node_contract "https://github.com/developer-yash04/aarogyan/blob/main/contracts/ignition/modules/AarogyanModule.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_app,node_auth,node_wallet,node_patient,node_hospital,node_researcher,node_inspector,node_user toneBlue
class node_hospital_portal,node_ehr_importer,node_fhir_parser,node_domain_types toneAmber
class node_api,node_models,node_database toneMint
class node_proof_worker,node_abi,node_chain_inspector,node_contract toneRose
class node_ethereum toneIndigo
```

## Components

### Web application

- [Role router](https://github.com/developer-yash04/aarogyan/blob/main/web/src/App.tsx): `web/src/App.tsx`
- [Auth context](https://github.com/developer-yash04/aarogyan/blob/main/web/src/hooks/useAuth.tsx): `web/src/hooks/useAuth.tsx`
- [Wallet sign-in](https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/auth/WalletConnect.tsx): `web/src/components/auth/WalletConnect.tsx`
- [Patient workspace](https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/PatientDashboard.tsx): `web/src/pages/PatientDashboard.tsx`
- [Hospital workspace](https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/HospitalDashboard.tsx): `web/src/pages/HospitalDashboard.tsx`
- [Research workspace](https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/ResearcherDashboard.tsx): `web/src/pages/ResearcherDashboard.tsx`
- [Inspector workspace](https://github.com/developer-yash04/aarogyan/blob/main/web/src/pages/InspectorDashboard.tsx): `web/src/pages/InspectorDashboard.tsx`

### Clinical workflow

- [Hospital portal](https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/HospitalPortal.tsx): `web/src/components/HospitalPortal.tsx`
- [EHR importer](https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/EHRImporter.tsx): `web/src/components/EHRImporter.tsx`
- [FHIR parser](https://github.com/developer-yash04/aarogyan/blob/main/web/src/utils/fhirParser.ts): `web/src/utils/fhirParser.ts`
- [Clinical data types](https://github.com/developer-yash04/aarogyan/blob/main/web/src/types/aarogyan.ts): `web/src/types/aarogyan.ts`

### Identity and services

- [API routes](https://github.com/developer-yash04/aarogyan/blob/main/server/index.ts): `server/index.ts`
- [Data models](https://github.com/developer-yash04/aarogyan/blob/main/server/db.js): `server/db.js`
- [SQLite database](https://github.com/developer-yash04/aarogyan/blob/main/server/db.js): `server/db.js`

### Proof and blockchain

- [ZK proof worker](https://github.com/developer-yash04/aarogyan/blob/main/web/src/workers/zkProofWorker.ts): `web/src/workers/zkProofWorker.ts`
- [Contract interface](https://github.com/developer-yash04/aarogyan/blob/main/web/src/contracts/aarogyanAbi.ts): `web/src/contracts/aarogyanAbi.ts`
- [On-chain inspector](https://github.com/developer-yash04/aarogyan/blob/main/web/src/components/OnChainInspector.tsx): `web/src/components/OnChainInspector.tsx`
- [Aarogyan contract module](https://github.com/developer-yash04/aarogyan/blob/main/contracts/ignition/modules/AarogyanModule.ts): `contracts/ignition/modules/AarogyanModule.ts`

### Other components

- **Portal user**
- **Ethereum wallet and chain**

## Connections

- Portal user → Role router: opens portal (evidence: `web/src/App.tsx`)
- Role router → Patient workspace: routes to (evidence: `web/src/App.tsx`)
- Role router → Hospital workspace: routes to (evidence: `web/src/App.tsx`)
- Role router → Research workspace: routes to (evidence: `web/src/App.tsx`)
- Role router → Inspector workspace: routes to (evidence: `web/src/App.tsx`)
- Role router → Auth context: provides context (evidence: `web/src/App.tsx`)
- Patient workspace → Wallet sign-in: prompts sign-in (evidence: `web/src/pages/PatientDashboard.tsx`)
- Hospital workspace → Wallet sign-in: prompts sign-in (evidence: `web/src/pages/HospitalDashboard.tsx`)
- Research workspace → Wallet sign-in: prompts sign-in (evidence: `web/src/pages/ResearcherDashboard.tsx`)
- Inspector workspace → Wallet sign-in: prompts sign-in (evidence: `web/src/pages/InspectorDashboard.tsx`)
- Wallet sign-in → Ethereum wallet and chain: requests signature (evidence: `web/src/components/auth/WalletConnect.tsx`)
- Wallet sign-in → API routes: requests nonce (evidence: `web/src/components/auth/WalletConnect.tsx`)
- Wallet sign-in → Auth context: submits login (evidence: `web/src/components/auth/WalletConnect.tsx`)
- Auth context → API routes: verifies session (evidence: `web/src/hooks/useAuth.tsx`)
- API routes → Data models: queries models (evidence: `server/index.ts`)
- Data models → SQLite database: stores records (evidence: `server/db.js`)
- Patient workspace → EHR importer: opens importer
- EHR importer → FHIR parser: parses bundle (evidence: `web/src/components/EHRImporter.tsx`)
- EHR importer → Patient workspace: returns parsed data
- Hospital workspace → Hospital portal: hosts portal
- Hospital portal → Clinical data types: uses clinical types (evidence: `web/src/components/HospitalPortal.tsx`)
- FHIR parser → Clinical data types: produces patient data
- ZK proof worker → Ethereum wallet and chain: prepares proof for submission
- On-chain inspector → Contract interface: uses interface (evidence: `web/src/components/OnChainInspector.tsx`)
- On-chain inspector → Ethereum wallet and chain: queries chain
- Aarogyan contract module → Ethereum wallet and chain: deploys to
