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

> Architecture diagram of the GitHub repository telu-transtrack-fatigue-detection/transtrack-cloud-public, 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-public
- Repository: https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public

## Overview

TransTrack Cloud Review Engine accepts DMS alarm events, queues them for asynchronous video review, and returns verdicts through a callback. The main workflow downloads video, extracts facial landmarks and frame features, classifies fatigue, applies documented night-hour and driver-history escalation rules, records results, and sends the callback. The repository also provides offline batch inference and evaluation paths. The classifier is explicitly a placeholder with random weights. Escalation rules are documented, but their implementation is not visible in the sampled excerpts.

Main entry points: [`app/worker.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py) (Alarm Worker), [`app/main.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/main.py) (Review API), [`app/pipeline.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/pipeline.py) (Feature Extraction), [`app/model.py`](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/model.py) (MultiScaleTCN)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["API and Queue"]
  node_review_api["Review API<br/>[main.py]"]
  node_alarm_schema["Alarm Schemas<br/>[schemas.py]"]
  node_redis["Redis Queue"]
  node_worker["Alarm Worker<br/>[worker.py]"]
end

subgraph group_analysis["Video Analysis"]
  node_model_manager["Model Setup<br/>[model_manager.py]"]
  node_feature_pipeline["Feature Extraction<br/>[pipeline.py]"]
  node_classifier["MultiScaleTCN<br/>[model.py]"]
end

subgraph group_decision["Verdict and Records"]
  node_night_rule["Night Rule<br/>[worker.py]"]
  node_history_rule["Driver History Rule<br/>[worker.py]"]
  node_result_schema["Review Result<br/>[schemas.py]"]
  node_records[("Review Records<br/>[worker.py]")]
end

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

node_platform(("TransTrack Platform"))
node_video_source["Signed Video URL"]
node_callback["Callback Platform"]

node_platform -->|"submits alarm"| node_review_api
node_review_api -->|"validates payload"| node_alarm_schema
node_review_api -->|"checks depth"| node_redis
node_review_api -->|"queues task"| node_worker
node_worker -->|"uses broker"| node_redis
node_worker -->|"downloads video"| node_video_source
node_worker -->|"ensures models"| node_model_manager
node_worker -->|"extracts features"| node_feature_pipeline
node_feature_pipeline -->|"loads architecture"| node_classifier
node_worker -->|"infers class"| node_classifier
node_worker -.->|"applies heuristic"| node_night_rule
node_worker -.->|"checks history"| node_history_rule
node_worker -->|"builds verdict"| node_result_schema
node_worker -->|"writes result"| node_records
node_worker -->|"posts verdict"| node_callback
node_batch -->|"uses pipeline"| node_feature_pipeline
node_evaluation -->|"loads model"| node_classifier
node_evaluation -->|"extracts video"| node_feature_pipeline

click node_review_api "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/main.py"
click node_alarm_schema "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/schemas.py"
click node_worker "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py"
click node_model_manager "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/model_manager.py"
click node_feature_pipeline "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/pipeline.py"
click node_classifier "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/model.py"
click node_night_rule "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py"
click node_history_rule "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py"
click node_result_schema "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/schemas.py"
click node_records "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py"
click node_batch "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/scripts/batch_video_infer.py"
click node_evaluation "https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/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_review_api,node_alarm_schema,node_redis,node_worker toneBlue
class node_model_manager,node_feature_pipeline,node_classifier toneAmber
class node_night_rule,node_history_rule,node_result_schema,node_records toneMint
class node_batch,node_evaluation toneRose
class node_platform,node_video_source,node_callback toneIndigo
```

## Components

### API and Queue

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

### Video Analysis

- [Model Setup](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/model_manager.py): `app/model_manager.py`
- [Feature Extraction](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/pipeline.py): `app/pipeline.py`
- [MultiScaleTCN](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/model.py): `app/model.py`

### Verdict and Records

- [Night Rule](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py): `app/worker.py`
- [Driver History Rule](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py): `app/worker.py`
- [Review Result](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/schemas.py): `app/schemas.py`
- [Review Records](https://github.com/telu-transtrack-fatigue-detection/transtrack-cloud-public/blob/main/app/worker.py): `app/worker.py`

### Offline Inference

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

### Other components

- **TransTrack Platform**
- **Signed Video URL**
- **Callback Platform**

## Connections

- TransTrack Platform → Review API: submits alarm (evidence: `README.md`)
- Review API → Alarm Schemas: validates payload (evidence: `app/main.py`)
- Review API → Redis Queue: checks depth (evidence: `app/main.py`)
- Review API → Alarm Worker: queues task (evidence: `app/main.py`)
- Alarm Worker → Redis Queue: uses broker (evidence: `app/worker.py`)
- Alarm Worker → Signed Video URL: downloads video (evidence: `app/worker.py`)
- Alarm Worker → Model Setup: ensures models (evidence: `app/worker.py`)
- Alarm Worker → Feature Extraction: extracts features (evidence: `app/worker.py`)
- Feature Extraction → MultiScaleTCN: loads architecture (evidence: `app/pipeline.py`)
- Alarm Worker → MultiScaleTCN: infers class (evidence: `app/worker.py`)
- Alarm Worker → Night Rule: applies heuristic (evidence: `README.md`)
- Alarm Worker → Driver History Rule: checks history (evidence: `README.md`)
- Alarm Worker → Review Result: builds verdict (evidence: `app/worker.py`)
- Alarm Worker → Review Records: writes result (evidence: `app/worker.py`)
- Alarm Worker → Callback Platform: posts verdict (evidence: `app/worker.py`)
- Batch Inference → Feature Extraction: uses pipeline (evidence: `scripts/batch_video_infer.py`)
- Dataset Evaluation → MultiScaleTCN: loads model (evidence: `scripts/eval_npz.py`)
- Dataset Evaluation → Feature Extraction: extracts video (evidence: `scripts/eval_npz.py`)
