# bhavyash2615/real-time-emergency-response-triage-assistant architecture

> Architecture diagram of the GitHub repository bhavyash2615/real-time-emergency-response-triage-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhavyash2615/real-time-emergency-response-triage-assistant
- Repository: https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant

## Overview

This is a real-time emergency triage assistant. A client submits a patient ID and current issue; the API orchestrates patient-history retrieval, issue-focused context pruning, protocol retrieval, and triage generation, returning a structured recommendation with latency details. The README also describes SVM condition classification, prioritization, explainability, and voice/text input. The supplied excerpts show the orchestration and retrieval implementation, but not the reasoner, classifier, patient-store, or frontend source, so uncertain wiring for those capabilities is omitted.

Main entry points: [`app/services/triage_service.py`](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/triage_service.py) (Triage orchestrator), [`app/retrieval/protocol_retriever.py`](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/retrieval/protocol_retriever.py) (Protocol retrieval), [`app/api/triage_routes.py`](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/api/triage_routes.py) (Triage routes), [`app/retrieval/history_retriever.py`](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/retrieval/history_retriever.py) (History retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_frontend["Web frontend"]
  node_main["FastAPI app<br/>[main.py]"]
  node_routes["Triage routes<br/>[triage_routes.py]"]
end

subgraph group_workflow["Triage workflow"]
  node_triage["Triage orchestrator<br/>[triage_service.py]"]
  node_pruner["History pruning<br/>[pruning_service.py]"]
end

subgraph group_intelligence["Clinical intelligence"]
  node_embedding["Embedding model<br/>[embedding_model.py]"]
  node_reasoner["Triage reasoning<br/>[triage_reasoner.py]"]
  node_classifier["SVM classifier<br/>[svm_classifier.py]"]
end

subgraph group_data["Patient and protocol data"]
  node_history["History retrieval"]
  node_patient_service["Patient service<br/>[patient_service.py]"]
  node_patient_db[("Patient database<br/>[patient_db.py]")]
  node_protocols["Protocol retrieval"]
  node_vector[("Protocol vector index")]
  node_metadata["Protocol metadata"]
end

subgraph group_integrations["External services"]
  node_llm["LLM client<br/>[llm_client.py]"]
  node_scaledown["ScaleDown client"]
end

node_client(("Triage user"))
node_llm_provider(("LLM providers"))
node_scaledown_api(("ScaleDown API"))

node_client -->|"uses"| node_frontend
node_main -->|"mounts"| node_routes
node_routes -->|"invokes"| node_triage
node_triage -->|"retrieves history"| node_history
node_history --> node_patient_service
node_patient_service --> node_patient_db
node_triage -->|"prunes context"| node_pruner
node_triage -->|"retrieves protocols"| node_protocols
node_protocols -->|"embeds query"| node_embedding
node_protocols -->|"searches"| node_vector
node_protocols -->|"reads"| node_metadata
node_triage -->|"generates triage"| node_reasoner
node_llm -->|"requests generation"| node_llm_provider
node_scaledown -.->|"compresses history"| node_scaledown_api

click node_frontend "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/tree/main/frontend"
click node_main "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/main.py"
click node_routes "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/api/triage_routes.py"
click node_triage "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/triage_service.py"
click node_history "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/retrieval/history_retriever.py"
click node_patient_service "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/patient_service.py"
click node_patient_db "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/database/patient_db.py"
click node_pruner "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/pruning_service.py"
click node_protocols "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/retrieval/protocol_retriever.py"
click node_embedding "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/embeddings/embedding_model.py"
click node_vector "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/disease_index.faiss"
click node_metadata "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/disease_metadata.json"
click node_reasoner "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/reasoning/triage_reasoner.py"
click node_classifier "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/ml/svm_classifier.py"
click node_llm "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/llm/llm_client.py"
click node_scaledown "https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/pruning/scaledown_client.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_main,node_routes,node_client toneBlue
class node_triage,node_pruner toneAmber
class node_embedding,node_reasoner,node_classifier,node_scaledown_api toneMint
class node_history,node_patient_service,node_patient_db,node_protocols,node_vector,node_metadata toneRose
class node_llm,node_scaledown,node_llm_provider toneIndigo
```

## Components

### User interface

- [Web frontend](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/tree/main/frontend): `frontend`
- [FastAPI app](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/main.py): `app/main.py`
- [Triage routes](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/api/triage_routes.py): `app/api/triage_routes.py`

### Triage workflow

- [Triage orchestrator](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/triage_service.py): `app/services/triage_service.py`
- [History pruning](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/pruning_service.py): `app/services/pruning_service.py`

### Clinical intelligence

- [Embedding model](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/embeddings/embedding_model.py): `app/embeddings/embedding_model.py`
- [Triage reasoning](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/reasoning/triage_reasoner.py): `app/reasoning/triage_reasoner.py`
- [SVM classifier](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/ml/svm_classifier.py): `app/ml/svm_classifier.py`

### Patient and protocol data

- [History retrieval](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/retrieval/history_retriever.py): `app/retrieval/history_retriever.py`
- [Patient service](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/services/patient_service.py): `app/services/patient_service.py`
- [Patient database](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/database/patient_db.py): `database/patient_db.py`
- [Protocol retrieval](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/retrieval/protocol_retriever.py): `app/retrieval/protocol_retriever.py`
- [Protocol vector index](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/disease_index.faiss): `disease_index.faiss`
- [Protocol metadata](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/disease_metadata.json): `disease_metadata.json`

### External services

- [LLM client](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/llm/llm_client.py): `app/llm/llm_client.py`
- [ScaleDown client](https://github.com/bhavyash2615/real-time-emergency-response-triage-assistant/blob/main/app/pruning/scaledown_client.py): `app/pruning/scaledown_client.py`

### Other components

- **Triage user**
- **LLM providers**
- **ScaleDown API**

## Connections

- Triage user → Web frontend: uses
- FastAPI app → Triage routes: mounts
- Triage routes → Triage orchestrator: invokes
- Triage orchestrator → History retrieval: retrieves history
- History retrieval → Patient service
- Patient service → Patient database
- Triage orchestrator → History pruning: prunes context
- Triage orchestrator → Protocol retrieval: retrieves protocols
- Protocol retrieval → Embedding model: embeds query
- Protocol retrieval → Protocol vector index: searches
- Protocol retrieval → Protocol metadata: reads
- Triage orchestrator → Triage reasoning: generates triage
- LLM client → LLM providers: requests generation
- ScaleDown client → ScaleDown API: compresses history
