# acprarthana/human_immunovirus-detection architecture

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

- Interactive diagram: https://gitdiagram.com/acprarthana/human_immunovirus-detection
- Repository: https://github.com/acprarthana/human_immunovirus-detection

## Overview

This is a hospital clinical workspace for longitudinal HIV patient records and research risk estimates. Doctors sign in, register and verify pseudonymous patients, enter clinical data, request an estimate, and review patient records, reports, and notifications. The backend exposes authentication, patient and clinical-record APIs, document handling, model information, and prediction workflows; predictions derive features from visits, invoke Python inference, and persist results. The frontend and several route implementations were not excerpted, so their unshown relationships are omitted; documented paths and sampled calls anchor the edges shown.

Main entry points: [`backend/src/middleware/auth.js`](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/middleware/auth.js) (Token authentication), [`backend/src/routes/predictions.js`](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/predictions.js) (Prediction workflow), [`frontend/app/dashboard/WorkspaceDashboard.tsx`](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/dashboard/WorkspaceDashboard.tsx) (Workspace dashboard), [`backend/src/routes/patients.js`](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/patients.js) (Patient records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Clinical workspace"]
  node_login["Sign in<br/>[page.tsx]"]
  node_dashboard["Workspace dashboard"]
  node_clinical["Clinical entry<br/>[page.tsx]"]
  node_patientpage["Patient profile<br/>[page.tsx]"]
  node_report["Clinical report<br/>[page.tsx]"]
end

subgraph group_api["Backend API"]
  node_authroutes["Authentication routes<br/>[auth.js]"]
  node_authmw["Token authentication<br/>[auth.js]"]
  node_doctors["Doctor services<br/>[doctors.js]"]
  node_patients["Patient records<br/>[patients.js]"]
  node_visits["Clinical visits<br/>[visits.js]"]
  node_documents["Document handling<br/>[documents.js]"]
  node_notifications["Notifications<br/>[notifications.js]"]
  node_models["Model information<br/>[models.js]"]
  node_predictions["Prediction workflow<br/>[predictions.js]"]
end

subgraph group_ml["Risk modeling"]
  node_features["Visit feature builder<br/>[featureService.js]"]
  node_mlservice["Inference bridge<br/>[mlService.js]"]
  node_inference["Single prediction<br/>[predict_single.py]"]
  node_explain["Risk explanation<br/>[explain.py]"]
  node_artifact["Trained model<br/>[best_model.pkl]"]
end

subgraph group_data["Persistence"]
  node_supabaseclient["Supabase client<br/>[supabase.js]"]
  node_supabase[("Supabase database")]
end

node_doctor(("Hospital doctor"))

node_doctor -->|"signs in"| node_login
node_doctor -->|"manages records"| node_dashboard
node_dashboard -->|"requests profile"| node_authroutes
node_dashboard -->|"lists and adds"| node_patients
node_dashboard -->|"loads stats"| node_doctors
node_dashboard -->|"requests estimate"| node_predictions
node_dashboard -->|"updates alerts"| node_notifications
node_authroutes -->|"queries accounts"| node_supabaseclient
node_authroutes -->|"protects profile"| node_authmw
node_authmw -->|"loads doctor"| node_supabaseclient
node_doctors -->|"authenticates requests"| node_authmw
node_patients -->|"authenticates requests"| node_authmw
node_visits -->|"authenticates requests"| node_authmw
node_documents -->|"authenticates requests"| node_authmw
node_notifications -->|"authenticates requests"| node_authmw
node_models -->|"authenticates requests"| node_authmw
node_predictions -->|"authenticates requests"| node_authmw
node_patients -->|"reads and writes"| node_supabaseclient
node_predictions -->|"loads and saves"| node_supabaseclient
node_authroutes -->|"queries accounts"| node_supabase
node_patients -->|"stores patient data"| node_supabase
node_predictions -->|"stores estimates"| node_supabase
node_supabaseclient -->|"creates client"| node_supabase
node_predictions -->|"builds visit features"| node_features
node_predictions -->|"runs inference"| node_mlservice
node_mlservice -->|"executes script"| node_inference
node_inference -->|"uses explanations"| node_explain
node_mlservice -->|"checks availability"| node_artifact
node_clinical -.->|"submits clinical data"| node_visits
node_patientpage -.->|"views patient"| node_patients
node_patientpage -.->|"views visits"| node_visits
node_patientpage -.->|"reviews estimates"| node_predictions
node_report -.->|"uploads reports"| node_documents

click node_login "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/login/page.tsx"
click node_dashboard "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/dashboard/WorkspaceDashboard.tsx"
click node_clinical "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/clinical/page.tsx"
click node_patientpage "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/patients/%5BpatientId%5D/page.tsx"
click node_report "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/report/page.tsx"
click node_authroutes "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/auth.js"
click node_authmw "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/middleware/auth.js"
click node_doctors "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/doctors.js"
click node_patients "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/patients.js"
click node_visits "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/visits.js"
click node_documents "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/documents.js"
click node_notifications "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/notifications.js"
click node_models "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/models.js"
click node_predictions "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/predictions.js"
click node_features "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/services/featureService.js"
click node_mlservice "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/services/mlService.js"
click node_inference "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/ml/predict_single.py"
click node_explain "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/ml/explain.py"
click node_artifact "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/ml/artifacts/best_model.pkl"
click node_supabaseclient "https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/supabase.js"

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_login,node_dashboard,node_clinical,node_patientpage,node_report toneBlue
class node_authroutes,node_authmw,node_doctors,node_patients,node_visits,node_documents,node_notifications,node_models,node_predictions toneAmber
class node_features,node_mlservice,node_inference,node_explain,node_artifact toneMint
class node_supabaseclient,node_supabase toneRose
class node_doctor toneIndigo
```

## Components

### Clinical workspace

- [Sign in](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`
- [Workspace dashboard](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/dashboard/WorkspaceDashboard.tsx): `frontend/app/dashboard/WorkspaceDashboard.tsx`
- [Clinical entry](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/clinical/page.tsx): `frontend/app/clinical/page.tsx`
- [Patient profile](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/patients/%5BpatientId%5D/page.tsx): `frontend/app/patients/[patientId]/page.tsx`
- [Clinical report](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/frontend/app/report/page.tsx): `frontend/app/report/page.tsx`

### Backend API

- [Authentication routes](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Token authentication](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Doctor services](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/doctors.js): `backend/src/routes/doctors.js`
- [Patient records](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/patients.js): `backend/src/routes/patients.js`
- [Clinical visits](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/visits.js): `backend/src/routes/visits.js`
- [Document handling](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/documents.js): `backend/src/routes/documents.js`
- [Notifications](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/notifications.js): `backend/src/routes/notifications.js`
- [Model information](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/models.js): `backend/src/routes/models.js`
- [Prediction workflow](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/routes/predictions.js): `backend/src/routes/predictions.js`

### Risk modeling

- [Visit feature builder](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/services/featureService.js): `backend/src/services/featureService.js`
- [Inference bridge](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/services/mlService.js): `backend/src/services/mlService.js`
- [Single prediction](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/ml/predict_single.py): `ml/predict_single.py`
- [Risk explanation](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/ml/explain.py): `ml/explain.py`
- [Trained model](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/ml/artifacts/best_model.pkl): `ml/artifacts/best_model.pkl`

### Persistence

- [Supabase client](https://github.com/acprarthana/human_immunovirus-detection/blob/dev/backend/src/supabase.js): `backend/src/supabase.js`
- **Supabase database**

### Other components

- **Hospital doctor**

## Connections

- Hospital doctor → Sign in: signs in
- Hospital doctor → Workspace dashboard: manages records
- Workspace dashboard → Authentication routes: requests profile (evidence: `frontend/app/dashboard/WorkspaceDashboard.tsx`)
- Workspace dashboard → Patient records: lists and adds (evidence: `frontend/app/dashboard/WorkspaceDashboard.tsx`)
- Workspace dashboard → Doctor services: loads stats (evidence: `frontend/app/dashboard/WorkspaceDashboard.tsx`)
- Workspace dashboard → Prediction workflow: requests estimate (evidence: `frontend/app/dashboard/WorkspaceDashboard.tsx`)
- Workspace dashboard → Notifications: updates alerts (evidence: `frontend/app/dashboard/WorkspaceDashboard.tsx`)
- Authentication routes → Supabase client: queries accounts (evidence: `backend/src/routes/auth.js`)
- Authentication routes → Token authentication: protects profile (evidence: `backend/src/routes/auth.js`)
- Token authentication → Supabase client: loads doctor (evidence: `backend/src/middleware/auth.js`)
- Doctor services → Token authentication: authenticates requests (evidence: `backend/src/routes/doctors.js`)
- Patient records → Token authentication: authenticates requests (evidence: `backend/src/routes/patients.js`)
- Clinical visits → Token authentication: authenticates requests (evidence: `backend/src/routes/visits.js`)
- Document handling → Token authentication: authenticates requests (evidence: `backend/src/routes/documents.js`)
- Notifications → Token authentication: authenticates requests (evidence: `backend/src/routes/notifications.js`)
- Model information → Token authentication: authenticates requests (evidence: `backend/src/routes/models.js`)
- Prediction workflow → Token authentication: authenticates requests (evidence: `backend/src/routes/predictions.js`)
- Patient records → Supabase client: reads and writes (evidence: `backend/src/routes/patients.js`)
- Prediction workflow → Supabase client: loads and saves (evidence: `backend/src/routes/predictions.js`)
- Authentication routes → Supabase database: queries accounts (evidence: `backend/src/routes/auth.js`)
- Patient records → Supabase database: stores patient data (evidence: `backend/src/routes/patients.js`)
- Prediction workflow → Supabase database: stores estimates (evidence: `backend/src/routes/predictions.js`)
- Supabase client → Supabase database: creates client (evidence: `backend/src/supabase.js`)
- Prediction workflow → Visit feature builder: builds visit features (evidence: `backend/src/routes/predictions.js`)
- Prediction workflow → Inference bridge: runs inference (evidence: `backend/src/routes/predictions.js`)
- Inference bridge → Single prediction: executes script (evidence: `backend/src/services/mlService.js`)
- Single prediction → Risk explanation: uses explanations (evidence: `ml/predict_single.py`)
- Inference bridge → Trained model: checks availability (evidence: `backend/src/services/mlService.js`)
- Clinical entry → Clinical visits: submits clinical data
- Patient profile → Patient records: views patient
- Patient profile → Clinical visits: views visits
- Patient profile → Prediction workflow: reviews estimates
- Clinical report → Document handling: uploads reports
