# santhoshkumargontla/ai-qtriage architecture

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

- Interactive diagram: https://gitdiagram.com/santhoshkumargontla/ai-qtriage
- Repository: https://github.com/santhoshkumargontla/ai-qtriage

## Overview

AI-QTriage is a research-demo web application for multimodal injury assessment, not a clinically validated triage or emergency-dispatch system. Users create a case, add an image and questionnaire answers, optionally provide or simulate sensor data, then request analysis and view the case or a research report. The backend coordinates vision and sensor inference, combines available evidence for research predictions, and offers rule-based or Gemini first-aid guidance; SOS is a local simulation with optional sandbox messaging. The README documents these capabilities, but several runtime links are only indicated by module references, so uncertain links are omitted or dashed.

Main entry points: [`backend/main.py`](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/main.py) (Case API), [`backend/services/sos_service.py`](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/sos_service.py) (SOS workflow), [`frontend/app/cases/page.tsx`](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/cases/page.tsx) (Case screens), [`frontend/app/create-case/page.tsx`](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/create-case/page.tsx) (Create case)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_frontend["Case screens<br/>[page.tsx]"]
  node_casecreate["Create case<br/>[page.tsx]"]
  node_casedetail["Case detail<br/>[page.tsx]"]
  node_sensorui["Sensor capture"]
  node_researchui["Research view<br/>[page.tsx]"]
end

subgraph group_api["Case API"]
  node_api["Case API<br/>[main.py]"]
  node_store[("MongoDB cases<br/>[connection.py]")]
  node_questionnaire["Questionnaire routing"]
  node_liveadapter["Live sensor adapter"]
end

subgraph group_inference["Assessment models"]
  node_sensorprocessing["Sensor processing"]
  node_yolo["YOLO detection<br/>[yolo_wrapper.py]"]
  node_efficientnet["Image classification"]
  node_unet["Image segmentation<br/>[unet_wrapper.py]"]
  node_fusion["Feature fusion<br/>[feature_fusion.py]"]
  node_xgboost["XGBoost classifier"]
  node_vqc["Experimental VQC<br/>[vqc_classifier.py]"]
  node_sensorclassifier["Motion classifier"]
  node_rules["Research rules<br/>[rules_engine.py]"]
end

subgraph group_guidance["Guidance and SOS"]
  node_aid["First-aid guidance"]
  node_gemini["Gemini guidance"]
  node_report["Research report<br/>[report_service.py]"]
  node_sos["SOS workflow<br/>[sos_service.py]"]
  node_delivery["SOS delivery<br/>[sos_delivery.py]"]
end

node_user(("Case user"))
node_twilio["Twilio sandbox<br/>[twilio_service.py]"]

node_user -->|"creates case"| node_casecreate
node_user -->|"opens cases"| node_frontend
node_frontend -.->|"requests cases"| node_api
node_casecreate -.->|"submits case"| node_api
node_sensorui -.->|"uploads sensor data"| node_api
node_researchui -.->|"requests research view"| node_api
node_casedetail -.->|"requests analysis"| node_api
node_api -->|"reads and writes"| node_store
node_api -->|"routes answers"| node_questionnaire
node_api -->|"adapts sensor input"| node_liveadapter
node_api -->|"processes motion"| node_sensorprocessing
node_sensorprocessing -->|"classifies motion"| node_sensorclassifier
node_api -->|"detects injuries"| node_yolo
node_api -->|"classifies images"| node_efficientnet
node_api -->|"segments images"| node_unet
node_api -.->|"combines evidence"| node_fusion
node_fusion -->|"provides features"| node_xgboost
node_api -.->|"requests experimental prediction"| node_vqc
node_api -.->|"derives category"| node_rules
node_api -->|"requests guidance"| node_aid
node_aid -->|"generates guidance"| node_gemini
node_api -->|"builds report"| node_report
node_api -->|"checks SOS"| node_sos
node_sos -->|"requests delivery"| node_delivery
node_sos -->|"dispatches optional SMS"| node_twilio
node_twilio -.->|"sends sandbox SMS"| node_user

click node_frontend "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/cases/page.tsx"
click node_casecreate "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/create-case/page.tsx"
click node_casedetail "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/cases/%5Bid%5D/page.tsx"
click node_sensorui "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/components/RealTimeSensorCapture.tsx"
click node_researchui "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/research/page.tsx"
click node_api "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/main.py"
click node_store "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/database/connection.py"
click node_questionnaire "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/questionnaire_router.py"
click node_sensorprocessing "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/sensor/sensor_processor.py"
click node_liveadapter "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/live_sensor_adapter.py"
click node_yolo "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/vision/yolo_wrapper.py"
click node_efficientnet "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/vision/efficientnet_wrapper.py"
click node_unet "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/vision/unet_wrapper.py"
click node_fusion "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/fusion/feature_fusion.py"
click node_xgboost "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/classifiers/xgboost_classifier.py"
click node_vqc "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/classifiers/vqc_classifier.py"
click node_sensorclassifier "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/classifiers/sensor_classifier.py"
click node_rules "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/fusion/rules_engine.py"
click node_aid "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/first_aid_service.py"
click node_gemini "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/gemini_first_aid_service.py"
click node_report "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/report_service.py"
click node_sos "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/sos_service.py"
click node_delivery "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/sos_delivery.py"
click node_twilio "https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/twilio_service.py"

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_frontend,node_casecreate,node_casedetail,node_sensorui,node_researchui,node_user toneBlue
class node_api,node_store,node_questionnaire,node_liveadapter toneAmber
class node_sensorprocessing,node_yolo,node_efficientnet,node_unet,node_fusion,node_xgboost,node_vqc,node_sensorclassifier,node_rules toneMint
class node_aid,node_gemini,node_report,node_sos,node_delivery toneRose
class node_twilio toneTeal
```

## Components

### Web interface

- [Case screens](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/cases/page.tsx): `frontend/app/cases/page.tsx`
- [Create case](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/create-case/page.tsx): `frontend/app/create-case/page.tsx`
- [Case detail](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/cases/%5Bid%5D/page.tsx): `frontend/app/cases/[id]/page.tsx`
- [Sensor capture](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/components/RealTimeSensorCapture.tsx): `frontend/components/RealTimeSensorCapture.tsx`
- [Research view](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/frontend/app/research/page.tsx): `frontend/app/research/page.tsx`

### Case API

- [Case API](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/main.py): `backend/main.py`
- [MongoDB cases](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/database/connection.py): `backend/database/connection.py`
- [Questionnaire routing](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/questionnaire_router.py): `backend/services/questionnaire_router.py`
- [Live sensor adapter](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/live_sensor_adapter.py): `backend/services/live_sensor_adapter.py`

### Assessment models

- [Sensor processing](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/sensor/sensor_processor.py): `ml/sensor/sensor_processor.py`
- [YOLO detection](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/vision/yolo_wrapper.py): `ml/vision/yolo_wrapper.py`
- [Image classification](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/vision/efficientnet_wrapper.py): `ml/vision/efficientnet_wrapper.py`
- [Image segmentation](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/vision/unet_wrapper.py): `ml/vision/unet_wrapper.py`
- [Feature fusion](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/fusion/feature_fusion.py): `ml/fusion/feature_fusion.py`
- [XGBoost classifier](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/classifiers/xgboost_classifier.py): `ml/classifiers/xgboost_classifier.py`
- [Experimental VQC](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/classifiers/vqc_classifier.py): `ml/classifiers/vqc_classifier.py`
- [Motion classifier](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/classifiers/sensor_classifier.py): `ml/classifiers/sensor_classifier.py`
- [Research rules](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/ml/fusion/rules_engine.py): `ml/fusion/rules_engine.py`

### Guidance and SOS

- [First-aid guidance](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/first_aid_service.py): `backend/services/first_aid_service.py`
- [Gemini guidance](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/gemini_first_aid_service.py): `backend/services/gemini_first_aid_service.py`
- [Research report](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/report_service.py): `backend/services/report_service.py`
- [SOS workflow](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/sos_service.py): `backend/services/sos_service.py`
- [SOS delivery](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/sos_delivery.py): `backend/services/sos_delivery.py`

### Other components

- **Case user**
- [Twilio sandbox](https://github.com/santhoshkumargontla/ai-qtriage/blob/main/backend/services/twilio_service.py): `backend/services/twilio_service.py`

## Connections

- Case user → Create case: creates case
- Case user → Case screens: opens cases
- Case screens → Case API: requests cases
- Create case → Case API: submits case
- Sensor capture → Case API: uploads sensor data
- Research view → Case API: requests research view
- Case detail → Case API: requests analysis
- Case API → MongoDB cases: reads and writes (evidence: `backend/main.py`)
- Case API → Questionnaire routing: routes answers (evidence: `backend/main.py`)
- Case API → Live sensor adapter: adapts sensor input (evidence: `backend/main.py`)
- Case API → Sensor processing: processes motion (evidence: `backend/main.py`)
- Sensor processing → Motion classifier: classifies motion (evidence: `ml/sensor/sensor_processor.py`)
- Case API → YOLO detection: detects injuries (evidence: `backend/main.py`)
- Case API → Image classification: classifies images (evidence: `backend/main.py`)
- Case API → Image segmentation: segments images (evidence: `backend/main.py`)
- Case API → Feature fusion: combines evidence (evidence: `backend/main.py`)
- Feature fusion → XGBoost classifier: provides features (evidence: `ml/classifiers/xgboost_classifier.py`)
- Case API → Experimental VQC: requests experimental prediction (evidence: `backend/main.py`)
- Case API → Research rules: derives category (evidence: `backend/main.py`)
- Case API → First-aid guidance: requests guidance (evidence: `backend/main.py`)
- First-aid guidance → Gemini guidance: generates guidance (evidence: `backend/services/first_aid_service.py`)
- Case API → Research report: builds report (evidence: `backend/services/report_service.py`)
- Case API → SOS workflow: checks SOS (evidence: `backend/main.py`)
- SOS workflow → SOS delivery: requests delivery (evidence: `backend/services/sos_service.py`)
- SOS workflow → Twilio sandbox: dispatches optional SMS (evidence: `backend/services/sos_service.py`)
- Twilio sandbox → Case user: sends sandbox SMS
