# jiajuntang2006/pose-based-fall-risk-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/jiajuntang2006/pose-based-fall-risk-prediction
- Repository: https://github.com/jiajuntang2006/pose-based-fall-risk-prediction

## Overview

FallGuard is a macOS fall-risk monitoring product built around a local Python inference service and a native SwiftUI client. Its main workflow captures or imports video, extracts pose and temporal features, predicts confirmed and advisory risk states, then records monitoring sessions and events for review. The graph also preserves the documented training/data-preparation and model-fusion capabilities. Some backend and UI links rely on README-level architecture statements; unsampled source is not treated as inspected.

Main entry points: [`app/macos/native/FallGuard/Services/FallGuardAPIClient.swift`](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/FallGuardAPIClient.swift) (API client), [`fall_prediction/ml_predictor.py`](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/ml_predictor.py) (Tree prediction), [`app/macos/src/fall_prediction_desktop/frame_pipeline.py`](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/frame_pipeline.py) (Frame risk pipeline), [`app/macos/src/fall_prediction_service/app.py`](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_service/app.py) (Service composition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Native macOS client"]
  node_swift_ui["SwiftUI screens<br/>[ContentView.swift]"]
  node_dashboard["Dashboard"]
  node_events_ui["Event history<br/>[EventsView.swift]"]
  node_import_ui["Media import"]
  node_settings_ui["Profiles and settings<br/>[SettingsView.swift]"]
  node_api_client["API client"]
  node_service_manager["Python service manager"]
  node_notifications["Notifications"]
end

subgraph group_service["Local service and records"]
  node_service_app["Service composition<br/>[app.py]"]
  node_http_server["Authenticated API<br/>[server.py]"]
  node_desktop_runtime["Monitoring runtime<br/>[web_app.py]"]
  node_frame_pipeline["Frame risk pipeline<br/>[frame_pipeline.py]"]
  node_state_machine["Risk state machine"]
  node_event_service["Event service<br/>[event_service.py]"]
  node_database[("SQLite persistence<br/>[database.py]")]
end

subgraph group_inference["Pose and risk inference"]
  node_video_input["Camera and video<br/>[video_app.py]"]
  node_pose["Pose extraction<br/>[pose.py]"]
  node_tree_model["Tree prediction<br/>[ml_predictor.py]"]
  node_features["Motion features<br/>[features.py]"]
  node_robustness["Calibration and robustness<br/>[robustness.py]"]
  node_fusion_model["Skeleton fusion model<br/>[fusion_model.py]"]
  node_postprocessing["Temporal risk policy<br/>[risk.py]"]
end

subgraph group_research["Datasets and model development"]
  node_window_dataset["Window datasets<br/>[window_dataset.py]"]
  node_skeleton_dataset["Skeleton datasets"]
  node_tree_training["Tree model training<br/>[train_model.py]"]
  node_fusion_training["Fusion model training"]
end

node_user(("User"))

node_user -->|"uses"| node_swift_ui
node_swift_ui -.->|"requests data"| node_api_client
node_service_manager -.->|"starts"| node_service_app
node_api_client -.->|"calls localhost API"| node_http_server
node_dashboard -.->|"requests status"| node_api_client
node_events_ui -.->|"requests events"| node_api_client
node_import_ui -.->|"submits media"| node_api_client
node_settings_ui -.->|"updates settings"| node_api_client
node_http_server -->|"routes requests"| node_desktop_runtime
node_service_app -->|"configures"| node_http_server
node_service_app -->|"creates runtime"| node_desktop_runtime
node_desktop_runtime -->|"processes frames"| node_frame_pipeline
node_frame_pipeline -->|"updates risk state"| node_state_machine
node_frame_pipeline -->|"observes risk"| node_event_service
node_event_service -.->|"persists events"| node_database
node_frame_pipeline -.->|"predicts risk"| node_tree_model
node_video_input -->|"extracts keypoints"| node_pose
node_pose -->|"derives motion"| node_features
node_features -->|"provides features"| node_tree_model
node_tree_model -->|"uses calibration"| node_robustness
node_tree_model -.->|"combines prediction"| node_fusion_model
node_tree_model -->|"stabilizes state"| node_postprocessing
node_window_dataset -->|"builds windows"| node_features
node_skeleton_dataset -->|"uses windowing"| node_window_dataset
node_tree_training -->|"trains from windows"| node_window_dataset
node_fusion_training -->|"trains from skeletons"| node_skeleton_dataset
node_fusion_training -->|"builds model"| node_fusion_model
node_notifications -.->|"alerts"| node_user

click node_swift_ui "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/ContentView.swift"
click node_dashboard "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/Dashboard/DashboardView.swift"
click node_events_ui "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/Events/EventsView.swift"
click node_import_ui "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/ImportMedia/ImportMediaView.swift"
click node_settings_ui "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/Settings/SettingsView.swift"
click node_api_client "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/FallGuardAPIClient.swift"
click node_service_manager "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/PythonServiceManager.swift"
click node_notifications "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/NotificationService.swift"
click node_service_app "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_service/app.py"
click node_http_server "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_service/server.py"
click node_desktop_runtime "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/web_app.py"
click node_frame_pipeline "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/frame_pipeline.py"
click node_state_machine "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/risk_state_machine.py"
click node_event_service "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/event_service.py"
click node_database "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/database/database.py"
click node_video_input "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/video_app.py"
click node_pose "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/pose.py"
click node_tree_model "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/ml_predictor.py"
click node_features "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/features.py"
click node_robustness "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/robustness.py"
click node_fusion_model "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/fusion_model.py"
click node_postprocessing "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/risk.py"
click node_window_dataset "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/window_dataset.py"
click node_skeleton_dataset "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/skeleton_dataset.py"
click node_tree_training "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/train_model.py"
click node_fusion_training "https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/train_fusion_model.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_swift_ui,node_dashboard,node_events_ui,node_import_ui,node_settings_ui,node_api_client,node_service_manager,node_notifications,node_user toneBlue
class node_service_app,node_http_server,node_desktop_runtime,node_frame_pipeline,node_state_machine,node_event_service,node_database toneAmber
class node_video_input,node_pose,node_tree_model,node_features,node_robustness,node_fusion_model,node_postprocessing toneMint
class node_window_dataset,node_skeleton_dataset,node_tree_training,node_fusion_training toneRose
```

## Components

### Native macOS client

- [SwiftUI screens](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/ContentView.swift): `app/macos/native/FallGuard/Features/ContentView.swift`
- [Dashboard](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/Dashboard/DashboardView.swift): `app/macos/native/FallGuard/Features/Dashboard/DashboardView.swift`
- [Event history](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/Events/EventsView.swift): `app/macos/native/FallGuard/Features/Events/EventsView.swift`
- [Media import](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/ImportMedia/ImportMediaView.swift): `app/macos/native/FallGuard/Features/ImportMedia/ImportMediaView.swift`
- [Profiles and settings](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Features/Settings/SettingsView.swift): `app/macos/native/FallGuard/Features/Settings/SettingsView.swift`
- [API client](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/FallGuardAPIClient.swift): `app/macos/native/FallGuard/Services/FallGuardAPIClient.swift`
- [Python service manager](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/PythonServiceManager.swift): `app/macos/native/FallGuard/Services/PythonServiceManager.swift`
- [Notifications](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/native/FallGuard/Services/NotificationService.swift): `app/macos/native/FallGuard/Services/NotificationService.swift`

### Local service and records

- [Service composition](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_service/app.py): `app/macos/src/fall_prediction_service/app.py`
- [Authenticated API](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_service/server.py): `app/macos/src/fall_prediction_service/server.py`
- [Monitoring runtime](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/web_app.py): `app/macos/src/fall_prediction_desktop/web_app.py`
- [Frame risk pipeline](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/frame_pipeline.py): `app/macos/src/fall_prediction_desktop/frame_pipeline.py`
- [Risk state machine](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/risk_state_machine.py): `app/macos/src/fall_prediction_desktop/risk_state_machine.py`
- [Event service](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/event_service.py): `app/macos/src/fall_prediction_desktop/event_service.py`
- [SQLite persistence](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/app/macos/src/fall_prediction_desktop/database/database.py): `app/macos/src/fall_prediction_desktop/database/database.py`

### Pose and risk inference

- [Camera and video](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/video_app.py): `fall_prediction/video_app.py`
- [Pose extraction](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/pose.py): `fall_prediction/pose.py`
- [Tree prediction](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/ml_predictor.py): `fall_prediction/ml_predictor.py`
- [Motion features](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/features.py): `fall_prediction/features.py`
- [Calibration and robustness](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/robustness.py): `fall_prediction/robustness.py`
- [Skeleton fusion model](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/fusion_model.py): `fall_prediction/fusion_model.py`
- [Temporal risk policy](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/risk.py): `fall_prediction/risk.py`

### Datasets and model development

- [Window datasets](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/window_dataset.py): `fall_prediction/window_dataset.py`
- [Skeleton datasets](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/skeleton_dataset.py): `fall_prediction/skeleton_dataset.py`
- [Tree model training](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/train_model.py): `fall_prediction/train_model.py`
- [Fusion model training](https://github.com/jiajuntang2006/pose-based-fall-risk-prediction/blob/main/fall_prediction/train_fusion_model.py): `fall_prediction/train_fusion_model.py`

### Other components

- **User**

## Connections

- User → SwiftUI screens: uses
- SwiftUI screens → API client: requests data
- Python service manager → Service composition: starts
- API client → Authenticated API: calls localhost API
- Dashboard → API client: requests status
- Event history → API client: requests events
- Media import → API client: submits media
- Profiles and settings → API client: updates settings
- Authenticated API → Monitoring runtime: routes requests (evidence: `app/macos/src/fall_prediction_service/server.py`)
- Service composition → Authenticated API: configures (evidence: `app/macos/src/fall_prediction_service/app.py`)
- Service composition → Monitoring runtime: creates runtime (evidence: `app/macos/src/fall_prediction_service/app.py`)
- Monitoring runtime → Frame risk pipeline: processes frames (evidence: `app/macos/src/fall_prediction_desktop/web_app.py`)
- Frame risk pipeline → Risk state machine: updates risk state (evidence: `app/macos/src/fall_prediction_desktop/frame_pipeline.py`)
- Frame risk pipeline → Event service: observes risk (evidence: `app/macos/src/fall_prediction_desktop/frame_pipeline.py`)
- Event service → SQLite persistence: persists events
- Frame risk pipeline → Tree prediction: predicts risk
- Camera and video → Pose extraction: extracts keypoints (evidence: `fall_prediction/video_app.py`)
- Pose extraction → Motion features: derives motion
- Motion features → Tree prediction: provides features (evidence: `fall_prediction/ml_predictor.py`)
- Tree prediction → Calibration and robustness: uses calibration (evidence: `fall_prediction/ml_predictor.py`)
- Tree prediction → Skeleton fusion model: combines prediction (evidence: `fall_prediction/ml_predictor.py`)
- Tree prediction → Temporal risk policy: stabilizes state (evidence: `fall_prediction/ml_predictor.py`)
- Window datasets → Motion features: builds windows (evidence: `fall_prediction/window_dataset.py`)
- Skeleton datasets → Window datasets: uses windowing (evidence: `fall_prediction/skeleton_dataset.py`)
- Tree model training → Window datasets: trains from windows (evidence: `fall_prediction/train_model.py`)
- Fusion model training → Skeleton datasets: trains from skeletons (evidence: `fall_prediction/train_fusion_model.py`)
- Fusion model training → Skeleton fusion model: builds model (evidence: `fall_prediction/train_fusion_model.py`)
- Notifications → User: alerts
