# anurag-mitti/eyantra-ai-in-smart-mirror architecture

> Architecture diagram of the GitHub repository anurag-mitti/eyantra-ai-in-smart-mirror, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anurag-mitti/eyantra-ai-in-smart-mirror
- Repository: https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror

## Overview

This is a local C++ smart-mirror physiotherapy engine. A RealSense camera supplies frames for pose inference; exercise-specific detectors derive movement metrics, state machines track form and repetitions, and the engine updates session statistics while streaming telemetry to a mirror UI. The README documents the camera, NEON conversion, MediaPipe, FSM, session, and WebSocket capabilities. Some internal wiring is supported only by that documentation and the source index; unsampled implementation details are not inferred.

Main entry points: [`src/detectors/detector_factory.hpp`](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/detector_factory.hpp) (Detector factory), [`src/fsm/fsm_factory.hpp`](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/fsm_factory.hpp) (FSM factory), [`src/main.cpp`](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/main.cpp) (Engine orchestration), [`src/pose_tracker.hpp`](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/pose_tracker.hpp) (Pose tracker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision pipeline"]
  node_capture["V4L2 capture<br/>[realsense_mmap.hpp]"]
  node_neon["NEON math<br/>[neon_math.hpp]"]
  node_pose["Pose tracker<br/>[pose_tracker.hpp]"]
  node_kalman["Kalman filter<br/>[kalman_filter.hpp]"]
end

subgraph group_detectors["Exercise metrics"]
  node_detector_factory["Detector factory"]
  node_base_detector["Detector base<br/>[base_detector.hpp]"]
  node_squat_detector["Squat detector<br/>[squat_detector.hpp]"]
  node_pendulum_detector["Pendulum detector"]
  node_shoulder_detector["Shoulder detector"]
  node_sit_detector["Sit-stand detector"]
  node_trap_detector["Trap detector"]
end

subgraph group_fsm["Exercise state"]
  node_fsm_factory["FSM factory<br/>[fsm_factory.hpp]"]
  node_base_fsm["FSM base<br/>[base_fsm.hpp]"]
  node_squat_fsm["Squat FSM<br/>[squat_fsm.hpp]"]
  node_pendulum_fsm["Pendulum FSM<br/>[pendulum_fsm.hpp]"]
  node_shoulder_fsm["Shoulder FSM"]
  node_sit_fsm["Sit-stand FSM"]
  node_trap_fsm["Trap FSM<br/>[upper_trap_fsm.hpp]"]
end

subgraph group_runtime["Runtime and telemetry"]
  node_engine["Engine orchestration<br/>[main.cpp]"]
  node_session["Session tracker"]
  node_report[("Session report")]
  node_websocket["WebSocket broadcaster<br/>[networking.hpp]"]
end

node_camera(("RealSense camera"))
node_ui(("Smart mirror UI"))

node_camera -->|"streams frames"| node_capture
node_capture -->|"supplies frames"| node_pose
node_neon -->|"converts frames"| node_pose
node_pose -->|"smooths metrics"| node_kalman
node_pose -->|"selects detector"| node_detector_factory
node_engine -->|"runs inference"| node_pose
node_engine -->|"changes exercise"| node_detector_factory
node_detector_factory -->|"creates"| node_squat_detector
node_detector_factory -->|"creates"| node_pendulum_detector
node_detector_factory -->|"creates"| node_shoulder_detector
node_detector_factory -->|"creates"| node_sit_detector
node_detector_factory -->|"creates"| node_trap_detector
node_base_detector -->|"uses geometry"| node_neon
node_engine -->|"creates FSM"| node_fsm_factory
node_fsm_factory -->|"creates"| node_squat_fsm
node_fsm_factory -->|"creates"| node_pendulum_fsm
node_fsm_factory -->|"creates"| node_shoulder_fsm
node_fsm_factory -->|"creates"| node_sit_fsm
node_fsm_factory -->|"creates"| node_trap_fsm
node_engine -->|"updates metrics"| node_session
node_session -->|"saves report"| node_report
node_engine -->|"broadcasts state"| node_websocket
node_websocket -->|"streams telemetry"| node_ui
node_ui -->|"sends commands"| node_websocket
node_websocket -->|"delivers commands"| node_engine
node_pose -.->|"processes landmarks"| node_base_detector
node_squat_fsm -.->|"implements"| node_base_fsm
node_pendulum_fsm -.->|"implements"| node_base_fsm
node_shoulder_fsm -.->|"implements"| node_base_fsm
node_sit_fsm -.->|"implements"| node_base_fsm
node_trap_fsm -.->|"implements"| node_base_fsm

click node_capture "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/core/realsense_mmap.hpp"
click node_neon "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/core/neon_math.hpp"
click node_pose "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/pose_tracker.hpp"
click node_kalman "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/core/kalman_filter.hpp"
click node_engine "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/main.cpp"
click node_detector_factory "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/detector_factory.hpp"
click node_base_detector "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/base_detector.hpp"
click node_squat_detector "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/squat_detector.hpp"
click node_pendulum_detector "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/pendulum_detector.hpp"
click node_shoulder_detector "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/shoulder_circle_detector.hpp"
click node_sit_detector "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/sit_to_stand_detector.hpp"
click node_trap_detector "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/upper_trap_detector.hpp"
click node_fsm_factory "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/fsm_factory.hpp"
click node_base_fsm "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/base_fsm.hpp"
click node_squat_fsm "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/squat_fsm.hpp"
click node_pendulum_fsm "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/pendulum_fsm.hpp"
click node_shoulder_fsm "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/shoulder_circle_fsm.hpp"
click node_sit_fsm "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/sit_to_stand_fsm.hpp"
click node_trap_fsm "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/upper_trap_fsm.hpp"
click node_session "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/session_tracker.hpp"
click node_report "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/session_tracker.hpp"
click node_websocket "https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/net/networking.hpp"

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_capture,node_neon,node_pose,node_kalman,node_ui toneBlue
class node_detector_factory,node_base_detector,node_squat_detector,node_pendulum_detector,node_shoulder_detector,node_sit_detector,node_trap_detector toneAmber
class node_fsm_factory,node_base_fsm,node_squat_fsm,node_pendulum_fsm,node_shoulder_fsm,node_sit_fsm,node_trap_fsm toneMint
class node_engine,node_session,node_report,node_websocket toneRose
class node_camera toneIndigo
```

## Components

### Vision pipeline

- [V4L2 capture](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/core/realsense_mmap.hpp): `src/core/realsense_mmap.hpp`
- [NEON math](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/core/neon_math.hpp): `src/core/neon_math.hpp`
- [Pose tracker](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/pose_tracker.hpp): `src/pose_tracker.hpp`
- [Kalman filter](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/core/kalman_filter.hpp): `src/core/kalman_filter.hpp`

### Exercise metrics

- [Detector factory](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/detector_factory.hpp): `src/detectors/detector_factory.hpp`
- [Detector base](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/base_detector.hpp): `src/detectors/base_detector.hpp`
- [Squat detector](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/squat_detector.hpp): `src/detectors/squat_detector.hpp`
- [Pendulum detector](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/pendulum_detector.hpp): `src/detectors/pendulum_detector.hpp`
- [Shoulder detector](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/shoulder_circle_detector.hpp): `src/detectors/shoulder_circle_detector.hpp`
- [Sit-stand detector](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/sit_to_stand_detector.hpp): `src/detectors/sit_to_stand_detector.hpp`
- [Trap detector](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/detectors/upper_trap_detector.hpp): `src/detectors/upper_trap_detector.hpp`

### Exercise state

- [FSM factory](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/fsm_factory.hpp): `src/fsm/fsm_factory.hpp`
- [FSM base](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/base_fsm.hpp): `src/fsm/base_fsm.hpp`
- [Squat FSM](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/squat_fsm.hpp): `src/fsm/squat_fsm.hpp`
- [Pendulum FSM](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/pendulum_fsm.hpp): `src/fsm/pendulum_fsm.hpp`
- [Shoulder FSM](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/shoulder_circle_fsm.hpp): `src/fsm/shoulder_circle_fsm.hpp`
- [Sit-stand FSM](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/sit_to_stand_fsm.hpp): `src/fsm/sit_to_stand_fsm.hpp`
- [Trap FSM](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/upper_trap_fsm.hpp): `src/fsm/upper_trap_fsm.hpp`

### Runtime and telemetry

- [Engine orchestration](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/main.cpp): `src/main.cpp`
- [Session tracker](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/session_tracker.hpp): `src/fsm/session_tracker.hpp`
- [Session report](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/fsm/session_tracker.hpp): `src/fsm/session_tracker.hpp`
- [WebSocket broadcaster](https://github.com/anurag-mitti/eyantra-ai-in-smart-mirror/blob/main/src/net/networking.hpp): `src/net/networking.hpp`

### Other components

- **RealSense camera**
- **Smart mirror UI**

## Connections

- RealSense camera → V4L2 capture: streams frames (evidence: `README.md`)
- V4L2 capture → Pose tracker: supplies frames (evidence: `README.md`)
- NEON math → Pose tracker: converts frames (evidence: `README.md`)
- Pose tracker → Kalman filter: smooths metrics (evidence: `src/pose_tracker.hpp`)
- Pose tracker → Detector factory: selects detector (evidence: `src/pose_tracker.hpp`)
- Engine orchestration → Pose tracker: runs inference (evidence: `src/main.cpp`)
- Engine orchestration → Detector factory: changes exercise (evidence: `src/main.cpp`)
- Detector factory → Squat detector: creates (evidence: `src/detectors/detector_factory.hpp`)
- Detector factory → Pendulum detector: creates (evidence: `src/detectors/detector_factory.hpp`)
- Detector factory → Shoulder detector: creates (evidence: `src/detectors/detector_factory.hpp`)
- Detector factory → Sit-stand detector: creates (evidence: `src/detectors/detector_factory.hpp`)
- Detector factory → Trap detector: creates (evidence: `src/detectors/detector_factory.hpp`)
- Detector base → NEON math: uses geometry (evidence: `src/detectors/base_detector.hpp`)
- Engine orchestration → FSM factory: creates FSM (evidence: `src/main.cpp`)
- FSM factory → Squat FSM: creates (evidence: `src/fsm/fsm_factory.hpp`)
- FSM factory → Pendulum FSM: creates (evidence: `src/fsm/fsm_factory.hpp`)
- FSM factory → Shoulder FSM: creates (evidence: `src/fsm/fsm_factory.hpp`)
- FSM factory → Sit-stand FSM: creates (evidence: `src/fsm/fsm_factory.hpp`)
- FSM factory → Trap FSM: creates (evidence: `src/fsm/fsm_factory.hpp`)
- Engine orchestration → Session tracker: updates metrics (evidence: `src/main.cpp`)
- Session tracker → Session report: saves report (evidence: `src/fsm/session_tracker.hpp`)
- Engine orchestration → WebSocket broadcaster: broadcasts state (evidence: `src/main.cpp`)
- WebSocket broadcaster → Smart mirror UI: streams telemetry (evidence: `README.md`)
- Smart mirror UI → WebSocket broadcaster: sends commands (evidence: `README.md`)
- WebSocket broadcaster → Engine orchestration: delivers commands (evidence: `src/main.cpp`)
- Pose tracker → Detector base: processes landmarks
- Squat FSM → FSM base: implements (evidence: `src/fsm/squat_fsm.hpp`)
- Pendulum FSM → FSM base: implements (evidence: `src/fsm/pendulum_fsm.hpp`)
- Shoulder FSM → FSM base: implements (evidence: `src/fsm/shoulder_circle_fsm.hpp`)
- Sit-stand FSM → FSM base: implements (evidence: `src/fsm/sit_to_stand_fsm.hpp`)
- Trap FSM → FSM base: implements (evidence: `src/fsm/upper_trap_fsm.hpp`)
