# arsh720/athena architecture

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

- Interactive diagram: https://gitdiagram.com/arsh720/athena
- Repository: https://github.com/arsh720/athena

## Overview

This is an offline, single-video running-gait analysis service. A user uploads a side-on video through the API; the pipeline extracts frames and pose landmarks, conditions signals and builds features, detects gait events, maps them to ALTIS phases, then computes and aggregates biomechanics metrics for a structured JSON response. The geometric detector is the documented default; ML detection is an optional, checkpoint-dependent alternative. Edges reflect the README and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`pipeline.py`](https://github.com/arsh720/athena/blob/main/pipeline.py) (Pipeline orchestrator), [`features/builder.py`](https://github.com/arsh720/athena/blob/main/features/builder.py) (Feature builder), [`api/main.py`](https://github.com/arsh720/athena/blob/main/api/main.py) (Analysis API), [`gait_events/detector.py`](https://github.com/arsh720/athena/blob/main/gait_events/detector.py) (Detector dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["API interface"]
  node_api["Analysis API<br/>[main.py]"]
  node_schemas["Response schemas<br/>[schemas.py]"]
end

subgraph group_orchestration["Analysis orchestration"]
  node_pipeline["Pipeline orchestrator<br/>[pipeline.py]"]
  node_config["Pipeline configuration<br/>[config.py]"]
  node_ingestion["Video ingestion<br/>[video_loader.py]"]
end

subgraph group_signals["Pose and features"]
  node_pose["Pose extraction<br/>[extractor.py]"]
  node_landmarks["Landmark data<br/>[landmarks.py]"]
  node_conditioning["Confidence handling<br/>[confidence.py]"]
  node_filters["Temporal filters<br/>[filters.py]"]
  node_features["Feature builder<br/>[builder.py]"]
  node_angles["Joint angles<br/>[angles.py]"]
  node_kinematics["Kinematics<br/>[kinematics.py]"]
end

subgraph group_events["Gait events"]
  node_detector["Detector dispatch<br/>[detector.py]"]
  node_geometric["Geometric detector"]
  node_ml["ML detector<br/>[ml_detector.py]"]
end

subgraph group_results["Phases and metrics"]
  node_phase["ALTIS phase mapping<br/>[phase_mapper.py]"]
  node_calculator["Stride metrics<br/>[calculator.py]"]
  node_aggregator["Metric aggregation<br/>[aggregator.py]"]
end

node_runner(("Video uploader"))

node_runner -->|"uploads video"| node_api
node_api -->|"runs analysis"| node_pipeline
node_api -->|"validates response"| node_schemas
node_pipeline -->|"loads settings"| node_config
node_pipeline -->|"extracts frames"| node_ingestion
node_pipeline -->|"processes frames"| node_pose
node_pose -->|"builds records"| node_landmarks
node_pipeline -->|"builds features"| node_features
node_features -->|"handles confidence"| node_conditioning
node_features -->|"smooths signals"| node_filters
node_features -->|"computes angles"| node_angles
node_features -->|"computes kinematics"| node_kinematics
node_pipeline -->|"dispatches detection"| node_detector
node_detector -->|"selects detector"| node_geometric
node_detector -.->|"selects detector"| node_ml
node_pipeline -->|"maps events"| node_phase
node_pipeline -->|"computes strides"| node_calculator
node_calculator -->|"uses phase timing"| node_phase
node_pipeline -->|"aggregates metrics"| node_aggregator

click node_api "https://github.com/arsh720/athena/blob/main/api/main.py"
click node_schemas "https://github.com/arsh720/athena/blob/main/api/schemas.py"
click node_pipeline "https://github.com/arsh720/athena/blob/main/pipeline.py"
click node_config "https://github.com/arsh720/athena/blob/main/config.py"
click node_ingestion "https://github.com/arsh720/athena/blob/main/ingestion/video_loader.py"
click node_pose "https://github.com/arsh720/athena/blob/main/pose/extractor.py"
click node_landmarks "https://github.com/arsh720/athena/blob/main/pose/landmarks.py"
click node_conditioning "https://github.com/arsh720/athena/blob/main/signal_processing/confidence.py"
click node_filters "https://github.com/arsh720/athena/blob/main/signal_processing/filters.py"
click node_features "https://github.com/arsh720/athena/blob/main/features/builder.py"
click node_angles "https://github.com/arsh720/athena/blob/main/features/angles.py"
click node_kinematics "https://github.com/arsh720/athena/blob/main/features/kinematics.py"
click node_detector "https://github.com/arsh720/athena/blob/main/gait_events/detector.py"
click node_geometric "https://github.com/arsh720/athena/blob/main/gait_events/geometric_detector.py"
click node_ml "https://github.com/arsh720/athena/blob/main/gait_events/ml_detector.py"
click node_phase "https://github.com/arsh720/athena/blob/main/metrics/phase_mapper.py"
click node_calculator "https://github.com/arsh720/athena/blob/main/metrics/calculator.py"
click node_aggregator "https://github.com/arsh720/athena/blob/main/metrics/aggregator.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,node_schemas toneBlue
class node_pipeline,node_config,node_ingestion toneAmber
class node_pose,node_landmarks,node_conditioning,node_filters,node_features,node_angles,node_kinematics toneMint
class node_detector,node_geometric,node_ml toneRose
class node_phase,node_calculator,node_aggregator,node_runner toneIndigo
```

## Components

### API interface

- [Analysis API](https://github.com/arsh720/athena/blob/main/api/main.py): `api/main.py`
- [Response schemas](https://github.com/arsh720/athena/blob/main/api/schemas.py): `api/schemas.py`

### Analysis orchestration

- [Pipeline orchestrator](https://github.com/arsh720/athena/blob/main/pipeline.py): `pipeline.py`
- [Pipeline configuration](https://github.com/arsh720/athena/blob/main/config.py): `config.py`
- [Video ingestion](https://github.com/arsh720/athena/blob/main/ingestion/video_loader.py): `ingestion/video_loader.py`

### Pose and features

- [Pose extraction](https://github.com/arsh720/athena/blob/main/pose/extractor.py): `pose/extractor.py`
- [Landmark data](https://github.com/arsh720/athena/blob/main/pose/landmarks.py): `pose/landmarks.py`
- [Confidence handling](https://github.com/arsh720/athena/blob/main/signal_processing/confidence.py): `signal_processing/confidence.py`
- [Temporal filters](https://github.com/arsh720/athena/blob/main/signal_processing/filters.py): `signal_processing/filters.py`
- [Feature builder](https://github.com/arsh720/athena/blob/main/features/builder.py): `features/builder.py`
- [Joint angles](https://github.com/arsh720/athena/blob/main/features/angles.py): `features/angles.py`
- [Kinematics](https://github.com/arsh720/athena/blob/main/features/kinematics.py): `features/kinematics.py`

### Gait events

- [Detector dispatch](https://github.com/arsh720/athena/blob/main/gait_events/detector.py): `gait_events/detector.py`
- [Geometric detector](https://github.com/arsh720/athena/blob/main/gait_events/geometric_detector.py): `gait_events/geometric_detector.py`
- [ML detector](https://github.com/arsh720/athena/blob/main/gait_events/ml_detector.py): `gait_events/ml_detector.py`

### Phases and metrics

- [ALTIS phase mapping](https://github.com/arsh720/athena/blob/main/metrics/phase_mapper.py): `metrics/phase_mapper.py`
- [Stride metrics](https://github.com/arsh720/athena/blob/main/metrics/calculator.py): `metrics/calculator.py`
- [Metric aggregation](https://github.com/arsh720/athena/blob/main/metrics/aggregator.py): `metrics/aggregator.py`

### Other components

- **Video uploader**

## Connections

- Video uploader → Analysis API: uploads video (evidence: `README.md`)
- Analysis API → Pipeline orchestrator: runs analysis (evidence: `api/main.py`)
- Analysis API → Response schemas: validates response (evidence: `api/main.py`)
- Pipeline orchestrator → Pipeline configuration: loads settings (evidence: `pipeline.py`)
- Pipeline orchestrator → Video ingestion: extracts frames (evidence: `pipeline.py`)
- Pipeline orchestrator → Pose extraction: processes frames (evidence: `pipeline.py`)
- Pose extraction → Landmark data: builds records (evidence: `pose/extractor.py`)
- Pipeline orchestrator → Feature builder: builds features (evidence: `pipeline.py`)
- Feature builder → Confidence handling: handles confidence (evidence: `features/builder.py`)
- Feature builder → Temporal filters: smooths signals (evidence: `features/builder.py`)
- Feature builder → Joint angles: computes angles (evidence: `features/builder.py`)
- Feature builder → Kinematics: computes kinematics (evidence: `features/builder.py`)
- Pipeline orchestrator → Detector dispatch: dispatches detection (evidence: `pipeline.py`)
- Detector dispatch → Geometric detector: selects detector (evidence: `gait_events/detector.py`)
- Detector dispatch → ML detector: selects detector (evidence: `gait_events/detector.py`)
- Pipeline orchestrator → ALTIS phase mapping: maps events (evidence: `pipeline.py`)
- Pipeline orchestrator → Stride metrics: computes strides (evidence: `pipeline.py`)
- Stride metrics → ALTIS phase mapping: uses phase timing (evidence: `metrics/calculator.py`)
- Pipeline orchestrator → Metric aggregation: aggregates metrics (evidence: `pipeline.py`)
