# rakesh7-k/ruralhealthcare architecture

> Architecture diagram of the GitHub repository rakesh7-k/ruralhealthcare, 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/rakesh7-k/ruralhealthcare
- Repository: https://github.com/rakesh7-k/ruralhealthcare

## Overview

SETHU is a prototype for coordinating care across patients, frontline workers, clinicians, facilities, and district administrators. Its central workflow follows registration and encounters through triage, consultation or teleconsultation, care-route recommendations, referrals, and follow-up. Role-specific client screens use API services to reach an Express server, whose controllers and domain services work with SQLite; shared types and states describe the care domain. The README documents the broader role and care capabilities. Several service and route implementations were not sampled, so unsupported links between them are omitted.

Main entry points: [`client/src/App.tsx`](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/App.tsx) (Route shell), [`server/src/app.ts`](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/app.ts) (Express API), [`server/src/controllers/doctorController.ts`](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/doctorController.ts) (Doctor workflows), [`server/src/controllers/facilityController.ts`](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/facilityController.ts) (Facility information)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Role-based client"]
  node_app["Route shell<br/>[App.tsx]"]
  node_auth["Session state<br/>[authStore.ts]"]
  node_login["Sign-in<br/>[LoginPage.tsx]"]
  node_worker["Worker workflow"]
  node_patient["Patient portal<br/>[PatientPortal.tsx]"]
  node_doctor["Doctor consultation"]
  node_facility["Facility operations"]
  node_district["District oversight"]
  node_care_assurance_ui["Route assurance view"]
  node_tele_ui["Teleconsultation rooms"]
  node_api_client["API transport<br/>[apiClient.ts]"]
  node_patient_api["Patient service<br/>[patientService.ts]"]
  node_auth_api["Authentication service<br/>[authService.ts]"]
  node_webrtc["WebRTC session<br/>[useWebRTC.ts]"]
  node_socket["Socket client<br/>[socketService.ts]"]
end

subgraph group_care["Care coordination"]
  node_patient_controller["Patient records"]
  node_doctor_controller["Doctor workflows"]
  node_facility_controller["Facility information"]
  node_tele_controller["Teleconsultation workflow"]
  node_triage["Triage engine<br/>[triageEngine.ts]"]
  node_route_assurance["Care route assurance"]
  node_trust_scorer["Data trust scoring<br/>[dataTrustScorer.ts]"]
end

subgraph group_platform["API and persistence"]
  node_api["Express API<br/>[app.ts]"]
  node_auth_middleware["JWT middleware<br/>[auth.ts]"]
  node_database[("SQLite database<br/>[database.ts]")]
end

subgraph group_shared["Shared domain"]
  node_enums["Care domain states<br/>[enums.ts]"]
end

node_user(("Care participants"))

node_user -->|"uses"| node_app
node_app -->|"reads session"| node_auth
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_worker
node_app -->|"routes to"| node_patient
node_app -->|"routes to"| node_doctor
node_app -->|"routes to"| node_facility
node_app -->|"routes to"| node_district
node_app -->|"routes to"| node_care_assurance_ui
node_app -->|"routes to"| node_tele_ui
node_auth -->|"calls"| node_auth_api
node_auth_api -->|"uses"| node_api_client
node_worker -->|"loads patients"| node_patient_api
node_patient -->|"loads portal data"| node_patient_api
node_doctor -.->|"supports consultation"| node_doctor_controller
node_facility -->|"supports facility work"| node_facility_controller
node_care_assurance_ui -.->|"displays assurance"| node_route_assurance
node_tele_ui -.->|"uses session"| node_webrtc
node_webrtc -->|"uses signaling"| node_socket
node_api -->|"mounts routes"| node_patient_controller
node_api -->|"mounts routes"| node_doctor_controller
node_api -->|"mounts routes"| node_facility_controller
node_api -->|"mounts routes"| node_tele_controller
node_patient_controller -->|"reads and writes"| node_database
node_doctor_controller -->|"uses"| node_database
node_doctor_controller -->|"evaluates triage"| node_triage
node_facility_controller -->|"uses"| node_database
node_facility_controller -->|"scores freshness"| node_trust_scorer
node_tele_controller -->|"uses"| node_database
node_patient_controller -->|"requires auth"| node_auth_middleware
node_api -.->|"shares domain states"| node_enums
node_user -->|"views care journey"| node_patient
node_user -->|"registers and follows up"| node_worker
node_user -->|"consults"| node_doctor
node_user -->|"manages resources"| node_facility
node_user -->|"oversees care"| node_district
node_api -.->|"recommends routes"| node_route_assurance

click node_app "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/App.tsx"
click node_auth "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/stores/authStore.ts"
click node_login "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/login/LoginPage.tsx"
click node_worker "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/worker/WorkerDashboard.tsx"
click node_patient "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/patient/PatientPortal.tsx"
click node_doctor "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/doctor/ConsultationWorkspace.tsx"
click node_facility "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/facility/FacilityDashboard.tsx"
click node_district "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/admin/DistrictDashboard.tsx"
click node_care_assurance_ui "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/doctor/CareRouteAssuranceView.tsx"
click node_tele_ui "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/doctor/TeleconsultationRoom.tsx"
click node_api_client "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/apiClient.ts"
click node_patient_api "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/patientService.ts"
click node_auth_api "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/authService.ts"
click node_webrtc "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/hooks/useWebRTC.ts"
click node_socket "https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/socketService.ts"
click node_api "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/app.ts"
click node_auth_middleware "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/middleware/auth.ts"
click node_patient_controller "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/patientController.ts"
click node_doctor_controller "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/doctorController.ts"
click node_facility_controller "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/facilityController.ts"
click node_tele_controller "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/teleconsultationController.ts"
click node_triage "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/services/triageEngine.ts"
click node_route_assurance "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/services/careRouteAssurance.ts"
click node_trust_scorer "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/services/dataTrustScorer.ts"
click node_database "https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/config/database.ts"
click node_enums "https://github.com/rakesh7-k/ruralhealthcare/blob/main/shared/src/types/enums.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_login,node_worker,node_patient,node_doctor,node_facility,node_district,node_care_assurance_ui,node_tele_ui,node_api_client,node_patient_api,node_auth_api,node_webrtc,node_socket toneBlue
class node_patient_controller,node_doctor_controller,node_facility_controller,node_tele_controller,node_triage,node_route_assurance,node_trust_scorer toneAmber
class node_api,node_auth_middleware,node_database toneMint
class node_enums toneRose
class node_user toneIndigo
```

## Components

### Role-based client

- [Route shell](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Session state](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/stores/authStore.ts): `client/src/stores/authStore.ts`
- [Sign-in](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/login/LoginPage.tsx): `client/src/routes/login/LoginPage.tsx`
- [Worker workflow](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/worker/WorkerDashboard.tsx): `client/src/routes/worker/WorkerDashboard.tsx`
- [Patient portal](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/patient/PatientPortal.tsx): `client/src/routes/patient/PatientPortal.tsx`
- [Doctor consultation](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/doctor/ConsultationWorkspace.tsx): `client/src/routes/doctor/ConsultationWorkspace.tsx`
- [Facility operations](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/facility/FacilityDashboard.tsx): `client/src/routes/facility/FacilityDashboard.tsx`
- [District oversight](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/admin/DistrictDashboard.tsx): `client/src/routes/admin/DistrictDashboard.tsx`
- [Route assurance view](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/doctor/CareRouteAssuranceView.tsx): `client/src/routes/doctor/CareRouteAssuranceView.tsx`
- [Teleconsultation rooms](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/routes/doctor/TeleconsultationRoom.tsx): `client/src/routes/doctor/TeleconsultationRoom.tsx`
- [API transport](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/apiClient.ts): `client/src/services/apiClient.ts`
- [Patient service](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/patientService.ts): `client/src/services/patientService.ts`
- [Authentication service](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/authService.ts): `client/src/services/authService.ts`
- [WebRTC session](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/hooks/useWebRTC.ts): `client/src/hooks/useWebRTC.ts`
- [Socket client](https://github.com/rakesh7-k/ruralhealthcare/blob/main/client/src/services/socketService.ts): `client/src/services/socketService.ts`

### Care coordination

- [Patient records](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/patientController.ts): `server/src/controllers/patientController.ts`
- [Doctor workflows](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/doctorController.ts): `server/src/controllers/doctorController.ts`
- [Facility information](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/facilityController.ts): `server/src/controllers/facilityController.ts`
- [Teleconsultation workflow](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/controllers/teleconsultationController.ts): `server/src/controllers/teleconsultationController.ts`
- [Triage engine](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/services/triageEngine.ts): `server/src/services/triageEngine.ts`
- [Care route assurance](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/services/careRouteAssurance.ts): `server/src/services/careRouteAssurance.ts`
- [Data trust scoring](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/services/dataTrustScorer.ts): `server/src/services/dataTrustScorer.ts`

### API and persistence

- [Express API](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/app.ts): `server/src/app.ts`
- [JWT middleware](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [SQLite database](https://github.com/rakesh7-k/ruralhealthcare/blob/main/server/src/config/database.ts): `server/src/config/database.ts`

### Shared domain

- [Care domain states](https://github.com/rakesh7-k/ruralhealthcare/blob/main/shared/src/types/enums.ts): `shared/src/types/enums.ts`

### Other components

- **Care participants**

## Connections

- Care participants → Route shell: uses (evidence: `README.md`)
- Route shell → Session state: reads session (evidence: `client/src/App.tsx`)
- Route shell → Sign-in: routes to (evidence: `client/src/App.tsx`)
- Route shell → Worker workflow: routes to (evidence: `client/src/App.tsx`)
- Route shell → Patient portal: routes to (evidence: `client/src/App.tsx`)
- Route shell → Doctor consultation: routes to (evidence: `client/src/App.tsx`)
- Route shell → Facility operations: routes to (evidence: `client/src/App.tsx`)
- Route shell → District oversight: routes to (evidence: `client/src/App.tsx`)
- Route shell → Route assurance view: routes to (evidence: `client/src/App.tsx`)
- Route shell → Teleconsultation rooms: routes to (evidence: `client/src/App.tsx`)
- Session state → Authentication service: calls (evidence: `client/src/stores/authStore.ts`)
- Authentication service → API transport: uses (evidence: `client/src/services/authService.ts`)
- Worker workflow → Patient service: loads patients (evidence: `client/src/routes/worker/WorkerDashboard.tsx`)
- Patient portal → Patient service: loads portal data (evidence: `client/src/routes/patient/PatientPortal.tsx`)
- Doctor consultation → Doctor workflows: supports consultation
- Facility operations → Facility information: supports facility work (evidence: `client/src/routes/facility/FacilityDashboard.tsx`)
- Route assurance view → Care route assurance: displays assurance
- Teleconsultation rooms → WebRTC session: uses session
- WebRTC session → Socket client: uses signaling (evidence: `client/src/hooks/useWebRTC.ts`)
- Express API → Patient records: mounts routes (evidence: `server/src/app.ts`)
- Express API → Doctor workflows: mounts routes (evidence: `server/src/app.ts`)
- Express API → Facility information: mounts routes (evidence: `server/src/app.ts`)
- Express API → Teleconsultation workflow: mounts routes (evidence: `server/src/app.ts`)
- Patient records → SQLite database: reads and writes (evidence: `server/src/controllers/patientController.ts`)
- Doctor workflows → SQLite database: uses (evidence: `server/src/controllers/doctorController.ts`)
- Doctor workflows → Triage engine: evaluates triage (evidence: `server/src/controllers/doctorController.ts`)
- Facility information → SQLite database: uses (evidence: `server/src/controllers/facilityController.ts`)
- Facility information → Data trust scoring: scores freshness (evidence: `server/src/controllers/facilityController.ts`)
- Teleconsultation workflow → SQLite database: uses (evidence: `server/src/controllers/teleconsultationController.ts`)
- Patient records → JWT middleware: requires auth (evidence: `server/src/routes/patient.routes.ts`)
- Express API → Care domain states: shares domain states
- Care participants → Patient portal: views care journey (evidence: `README.md`)
- Care participants → Worker workflow: registers and follows up (evidence: `README.md`)
- Care participants → Doctor consultation: consults (evidence: `README.md`)
- Care participants → Facility operations: manages resources (evidence: `README.md`)
- Care participants → District oversight: oversees care (evidence: `README.md`)
- Express API → Care route assurance: recommends routes
