# telu-transtrack-fatigue-detection/transtrack-cloud-review architecture

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

- Interactive diagram: https://gitdiagram.com/telu-transtrack-fatigue-detection/transtrack-cloud-review
- Repository: https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review

## Overview

TransTrack Cloud Review Engine accepts fatigue alarms, queues asynchronous video review, extracts facial features, classifies driver state, applies documented escalation rules, stores results, and posts callbacks. The graph also includes the documented offline batch-inference and dataset-evaluation capabilities. The sampled worker implementation shows download, inference, record writing, and callback delivery, but not the README’s night/history rules; those links are therefore marked as documented rather than verified in source.

Main entry points: [`app/worker.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py) (Alarm Worker), [`app/main.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/main.py) (Review API), [`app/pipeline.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/pipeline.py) (Landmark Features), [`scripts/batch_video_infer.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/batch_video_infer.py) (Batch Inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Intake"]
  node_api_service["Review API<br/>[main.py]"]
  node_alarm_schema["Alarm Schema<br/>[schemas.py]"]
  node_redis["Redis Queue"]
  node_worker["Alarm Worker<br/>[worker.py]"]
  node_settings["Service Settings<br/>[config.py]"]
end

subgraph group_processing["Video and Inference"]
  node_video["Video Download<br/>[worker.py]"]
  node_feature_extract["Landmark Features<br/>[pipeline.py]"]
  node_classifier["MultiScaleTCN<br/>[pipeline.py]"]
  node_model_files[("Model Files")]
  node_model_manager["Model Setup<br/>[model_manager.py]"]
end

subgraph group_review["Review and Records"]
  node_review_rules["Escalation Rules"]
  node_result_schema["Review Result<br/>[schemas.py]"]
  node_records[("Review Records<br/>[worker.py]")]
  node_callback(("Callback Service"))
end

subgraph group_offline["Offline Analysis"]
  node_batch["Batch Inference"]
  node_batch_output["Batch Reports"]
  node_evaluation["Dataset Evaluation<br/>[eval_npz.py]"]
end

node_platform(("TransTrack Platform"))

node_platform -->|"submits alarm"| node_api_service
node_api_service -->|"validates payload"| node_alarm_schema
node_api_service -->|"queues task"| node_redis
node_api_service -->|"dispatches task"| node_worker
node_api_service -->|"reads settings"| node_settings
node_worker -->|"reads settings"| node_settings
node_worker -->|"downloads video"| node_video
node_worker -->|"initializes models"| node_model_manager
node_model_manager -->|"downloads weights"| node_model_files
node_worker -->|"extracts features"| node_feature_extract
node_worker -->|"runs inference"| node_classifier
node_worker -.->|"applies rules"| node_review_rules
node_worker -->|"builds result"| node_result_schema
node_worker -->|"writes records"| node_records
node_worker -->|"posts verdict"| node_callback
node_platform -->|"receives verdict"| node_callback
node_batch -->|"uses pipeline"| node_feature_extract
node_batch -->|"writes reports"| node_batch_output
node_evaluation -->|"uses pipeline"| node_feature_extract

click node_api_service "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/main.py"
click node_alarm_schema "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/schemas.py"
click node_worker "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py"
click node_settings "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/config.py"
click node_video "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py"
click node_feature_extract "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/pipeline.py"
click node_classifier "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/pipeline.py"
click node_model_files "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/tree/main/models"
click node_model_manager "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/model_manager.py"
click node_review_rules "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/tree/main/app"
click node_result_schema "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/schemas.py"
click node_records "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py"
click node_batch "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/batch_video_infer.py"
click node_batch_output "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/batch_video_infer.py"
click node_evaluation "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/eval_npz.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_api_service,node_alarm_schema,node_redis,node_worker,node_settings toneBlue
class node_video,node_feature_extract,node_classifier,node_model_files,node_model_manager toneAmber
class node_review_rules,node_result_schema,node_records,node_callback toneMint
class node_batch,node_batch_output,node_evaluation toneRose
class node_platform toneIndigo
```

## Components

### API and Intake

- [Review API](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/main.py): `app/main.py`
- [Alarm Schema](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/schemas.py): `app/schemas.py`
- **Redis Queue**
- [Alarm Worker](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py): `app/worker.py`
- [Service Settings](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/config.py): `app/config.py`

### Video and Inference

- [Video Download](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py): `app/worker.py`
- [Landmark Features](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/pipeline.py): `app/pipeline.py`
- [MultiScaleTCN](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/pipeline.py): `app/pipeline.py`
- [Model Files](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/tree/main/models): `models`
- [Model Setup](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/model_manager.py): `app/model_manager.py`

### Review and Records

- [Escalation Rules](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/tree/main/app): `app`
- [Review Result](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/schemas.py): `app/schemas.py`
- [Review Records](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/app/worker.py): `app/worker.py`
- **Callback Service**

### Offline Analysis

- [Batch Inference](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/batch_video_infer.py): `scripts/batch_video_infer.py`
- [Batch Reports](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/batch_video_infer.py): `scripts/batch_video_infer.py`
- [Dataset Evaluation](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-review/blob/main/scripts/eval_npz.py): `scripts/eval_npz.py`

### Other components

- **TransTrack Platform**

## Connections

- TransTrack Platform → Review API: submits alarm (evidence: `README.md`)
- Review API → Alarm Schema: validates payload (evidence: `app/main.py`)
- Review API → Redis Queue: queues task (evidence: `app/main.py`)
- Review API → Alarm Worker: dispatches task (evidence: `app/main.py`)
- Review API → Service Settings: reads settings (evidence: `app/main.py`)
- Alarm Worker → Service Settings: reads settings (evidence: `app/worker.py`)
- Alarm Worker → Video Download: downloads video (evidence: `app/worker.py`)
- Alarm Worker → Model Setup: initializes models (evidence: `app/worker.py`)
- Model Setup → Model Files: downloads weights (evidence: `app/model_manager.py`)
- Alarm Worker → Landmark Features: extracts features (evidence: `app/worker.py`)
- Alarm Worker → MultiScaleTCN: runs inference (evidence: `app/worker.py`)
- Alarm Worker → Escalation Rules: applies rules (evidence: `README.md`)
- Alarm Worker → Review Result: builds result (evidence: `app/worker.py`)
- Alarm Worker → Review Records: writes records (evidence: `app/worker.py`)
- Alarm Worker → Callback Service: posts verdict (evidence: `app/worker.py`)
- TransTrack Platform → Callback Service: receives verdict (evidence: `README.md`)
- Batch Inference → Landmark Features: uses pipeline (evidence: `scripts/batch_video_infer.py`)
- Batch Inference → Batch Reports: writes reports (evidence: `README.md`)
- Dataset Evaluation → Landmark Features: uses pipeline (evidence: `scripts/eval_npz.py`)
