# 2dydgh/agentic-fall-detection-system architecture

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

- Interactive diagram: https://gitdiagram.com/2dydgh/agentic-fall-detection-system
- Repository: https://github.com/2dydgh/agentic-fall-detection-system

## Overview

This is a real-time, multi-zone fall-detection and response system with a FastAPI backend and Next.js monitoring dashboard. Its main workflow ingests video and synchronized audio, detects falls, enriches incidents with scene context, assigns severity through one of four decision modes, and records or acts on the result. Medium- and high-severity incidents can also be dispatched to an asynchronous escalation agent. The graph preserves documented dashboard, ontology, and fusion capabilities; some links for unsampled API and UI details are supported only by the README.

Main entry points: [`agentic/graph.py`](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/graph.py) (Workflow Graph), [`frontend/src/app/page.tsx`](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/app/page.tsx) (Monitoring Dashboard), [`api/main.py`](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/api/main.py) (Stream Worker), [`agentic/nodes/decision_ontology.py`](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision_ontology.py) (Ontology Decision)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Input and Perception"]
  node_stream["Stream Worker<br/>[main.py]"]
  node_audio_extract["Audio Extraction<br/>[extractor.py]"]
  node_perception["Pose Perception<br/>[perception.py]"]
  node_audio_node["Audio Analysis<br/>[audio.py]"]
end

subgraph group_reason["Detection and Reasoning"]
  node_analysis["Scene Analysis<br/>[analysis.py]"]
  node_decision_router["Workflow Graph<br/>[graph.py]"]
  node_state["Incident State<br/>[state.py]"]
  node_decision["Rule and Attention<br/>[decision.py]"]
  node_decision_llm["LLM Decision<br/>[decision_llm.py]"]
  node_ontology_decision["Ontology Decision"]
  node_ontology_facts["Fact Mapping<br/>[facts.py]"]
  node_ontology_engine["Rule Inference<br/>[engine.py]"]
  node_ontology_history["Incident History<br/>[history.py]"]
  node_fusion_feature["Fusion Features<br/>[feature.py]"]
  node_fusion_model["Attention Model<br/>[model.py]"]
  node_fusion_data["Fusion Dataset<br/>[dataset.py]"]
  node_fusion_train["Fusion Training<br/>[train.py]"]
end

subgraph group_response["Incident Response"]
  node_action["Response Actions<br/>[action.py]"]
  node_agent_runner["Async Dispatcher<br/>[runner.py]"]
  node_escalation["Escalation Agent"]
  node_agent_tools["Agent Tools<br/>[tools.py]"]
end

subgraph group_platform["API and Persistence"]
  node_incident_db[("Incident Store<br/>[db.py]")]
  node_api["HTTP API<br/>[main.py]"]
end

subgraph group_dashboard["Monitoring Dashboard"]
  node_web_dashboard["Monitoring Dashboard<br/>[page.tsx]"]
  node_camera_grid["Camera Grid<br/>[CameraGrid.tsx]"]
  node_incident_views["Incident Views<br/>[IncidentsPage.tsx]"]
  node_analytics["Analytics View<br/>[AnalyticsPage.tsx]"]
  node_ontology_view["Ontology Simulator<br/>[OntologyPage.tsx]"]
  node_architecture_view["Pipeline View"]
end

node_camera(("Video and Audio"))
node_operator(("Care Operator"))

node_camera -->|"supplies frames"| node_stream
node_stream -->|"extracts audio"| node_audio_extract
node_stream -->|"invokes per frame"| node_decision_router
node_audio_extract -->|"provides chunks"| node_audio_node
node_decision_router -->|"runs first"| node_perception
node_decision_router -->|"runs next"| node_audio_node
node_decision_router -->|"routes fall context"| node_analysis
node_decision_router -->|"selects mode"| node_decision
node_decision_router -->|"selects mode"| node_decision_llm
node_decision_router -->|"selects mode"| node_ontology_decision
node_decision_router -->|"runs response"| node_action
node_ontology_decision -->|"maps state"| node_ontology_facts
node_ontology_decision -->|"requests inference"| node_ontology_engine
node_ontology_decision -->|"reads history"| node_ontology_history
node_ontology_history -->|"queries incidents"| node_incident_db
node_decision -->|"extracts features"| node_fusion_feature
node_decision -->|"predicts severity"| node_fusion_model
node_fusion_model -->|"uses features"| node_fusion_feature
node_fusion_train -->|"loads data"| node_fusion_data
node_fusion_train -->|"trains model"| node_fusion_model
node_action -->|"records incident"| node_incident_db
node_action -->|"dispatches escalation"| node_agent_runner
node_agent_runner -->|"runs asynchronously"| node_escalation
node_escalation -->|"calls tools"| node_agent_tools
node_stream -->|"serves streams"| node_api
node_api -.->|"serves incident data"| node_incident_db
node_operator -->|"monitors incidents"| node_web_dashboard
node_web_dashboard -.->|"requests monitoring data"| node_api
node_web_dashboard -->|"renders cameras"| node_camera_grid
node_camera_grid -.->|"loads video"| node_api
node_web_dashboard -->|"shows incident records"| node_incident_views
node_web_dashboard -->|"shows analytics"| node_analytics
node_web_dashboard -->|"offers simulation"| node_ontology_view
node_web_dashboard -->|"visualizes pipeline"| node_architecture_view
node_decision_router -->|"passes state"| node_state

click node_stream "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/api/main.py"
click node_audio_extract "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/audio/extractor.py"
click node_perception "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/perception.py"
click node_audio_node "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/audio.py"
click node_analysis "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/analysis.py"
click node_decision_router "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/graph.py"
click node_state "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/state.py"
click node_decision "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision.py"
click node_decision_llm "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision_llm.py"
click node_ontology_decision "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision_ontology.py"
click node_ontology_facts "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/ontology/facts.py"
click node_ontology_engine "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/ontology/engine.py"
click node_ontology_history "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/ontology/history.py"
click node_fusion_feature "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/feature.py"
click node_fusion_model "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/model.py"
click node_fusion_data "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/dataset.py"
click node_action "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/action.py"
click node_agent_runner "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/agent/runner.py"
click node_escalation "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/agent/escalation_agent.py"
click node_agent_tools "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/agent/tools.py"
click node_incident_db "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/tools/db.py"
click node_api "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/api/main.py"
click node_web_dashboard "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/app/page.tsx"
click node_camera_grid "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/CameraGrid.tsx"
click node_incident_views "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/IncidentsPage.tsx"
click node_analytics "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/AnalyticsPage.tsx"
click node_ontology_view "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/OntologyPage.tsx"
click node_architecture_view "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/ArchitecturePage.tsx"
click node_fusion_train "https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/train.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_stream,node_audio_extract,node_perception,node_audio_node toneBlue
class node_analysis,node_decision_router,node_state,node_decision,node_decision_llm,node_ontology_decision,node_ontology_facts,node_ontology_engine,node_ontology_history,node_fusion_feature,node_fusion_model,node_fusion_data,node_fusion_train toneAmber
class node_action,node_agent_runner,node_escalation,node_agent_tools toneMint
class node_incident_db,node_api toneRose
class node_web_dashboard,node_camera_grid,node_incident_views,node_analytics,node_ontology_view,node_architecture_view,node_camera,node_operator toneIndigo
```

## Components

### Input and Perception

- [Stream Worker](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/api/main.py): `api/main.py`
- [Audio Extraction](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/audio/extractor.py): `agentic/audio/extractor.py`
- [Pose Perception](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/perception.py): `agentic/nodes/perception.py`
- [Audio Analysis](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/audio.py): `agentic/nodes/audio.py`

### Detection and Reasoning

- [Scene Analysis](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/analysis.py): `agentic/nodes/analysis.py`
- [Workflow Graph](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/graph.py): `agentic/graph.py`
- [Incident State](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/state.py): `agentic/state.py`
- [Rule and Attention](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision.py): `agentic/nodes/decision.py`
- [LLM Decision](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision_llm.py): `agentic/nodes/decision_llm.py`
- [Ontology Decision](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/decision_ontology.py): `agentic/nodes/decision_ontology.py`
- [Fact Mapping](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/ontology/facts.py): `agentic/ontology/facts.py`
- [Rule Inference](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/ontology/engine.py): `agentic/ontology/engine.py`
- [Incident History](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/ontology/history.py): `agentic/ontology/history.py`
- [Fusion Features](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/feature.py): `agentic/fusion/feature.py`
- [Attention Model](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/model.py): `agentic/fusion/model.py`
- [Fusion Dataset](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/dataset.py): `agentic/fusion/dataset.py`
- [Fusion Training](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/fusion/train.py): `agentic/fusion/train.py`

### Incident Response

- [Response Actions](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/nodes/action.py): `agentic/nodes/action.py`
- [Async Dispatcher](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/agent/runner.py): `agentic/agent/runner.py`
- [Escalation Agent](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/agent/escalation_agent.py): `agentic/agent/escalation_agent.py`
- [Agent Tools](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/agent/tools.py): `agentic/agent/tools.py`

### API and Persistence

- [Incident Store](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/agentic/tools/db.py): `agentic/tools/db.py`
- [HTTP API](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/api/main.py): `api/main.py`

### Monitoring Dashboard

- [Monitoring Dashboard](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Camera Grid](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/CameraGrid.tsx): `frontend/src/components/CameraGrid.tsx`
- [Incident Views](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/IncidentsPage.tsx): `frontend/src/components/IncidentsPage.tsx`
- [Analytics View](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/AnalyticsPage.tsx): `frontend/src/components/AnalyticsPage.tsx`
- [Ontology Simulator](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/OntologyPage.tsx): `frontend/src/components/OntologyPage.tsx`
- [Pipeline View](https://github.com/2dydgh/agentic-fall-detection-system/blob/main/frontend/src/components/ArchitecturePage.tsx): `frontend/src/components/ArchitecturePage.tsx`

### Other components

- **Video and Audio**
- **Care Operator**

## Connections

- Video and Audio → Stream Worker: supplies frames (evidence: `README.md`)
- Stream Worker → Audio Extraction: extracts audio (evidence: `api/main.py`)
- Stream Worker → Workflow Graph: invokes per frame (evidence: `api/main.py`)
- Audio Extraction → Audio Analysis: provides chunks (evidence: `agentic/audio/extractor.py`)
- Workflow Graph → Pose Perception: runs first (evidence: `agentic/graph.py`)
- Workflow Graph → Audio Analysis: runs next (evidence: `agentic/graph.py`)
- Workflow Graph → Scene Analysis: routes fall context (evidence: `agentic/graph.py`)
- Workflow Graph → Rule and Attention: selects mode (evidence: `agentic/graph.py`)
- Workflow Graph → LLM Decision: selects mode (evidence: `agentic/graph.py`)
- Workflow Graph → Ontology Decision: selects mode (evidence: `agentic/graph.py`)
- Workflow Graph → Response Actions: runs response (evidence: `agentic/graph.py`)
- Ontology Decision → Fact Mapping: maps state (evidence: `agentic/nodes/decision_ontology.py`)
- Ontology Decision → Rule Inference: requests inference (evidence: `agentic/nodes/decision_ontology.py`)
- Ontology Decision → Incident History: reads history (evidence: `agentic/nodes/decision_ontology.py`)
- Incident History → Incident Store: queries incidents (evidence: `agentic/ontology/history.py`)
- Rule and Attention → Fusion Features: extracts features (evidence: `agentic/nodes/decision.py`)
- Rule and Attention → Attention Model: predicts severity (evidence: `agentic/nodes/decision.py`)
- Attention Model → Fusion Features: uses features (evidence: `agentic/fusion/model.py`)
- Fusion Training → Fusion Dataset: loads data (evidence: `agentic/fusion/train.py`)
- Fusion Training → Attention Model: trains model (evidence: `agentic/fusion/train.py`)
- Response Actions → Incident Store: records incident (evidence: `agentic/nodes/action.py`)
- Response Actions → Async Dispatcher: dispatches escalation (evidence: `agentic/nodes/action.py`)
- Async Dispatcher → Escalation Agent: runs asynchronously (evidence: `agentic/agent/runner.py`)
- Escalation Agent → Agent Tools: calls tools (evidence: `agentic/agent/escalation_agent.py`)
- Stream Worker → HTTP API: serves streams (evidence: `api/main.py`)
- HTTP API → Incident Store: serves incident data (evidence: `api/main.py`)
- Care Operator → Monitoring Dashboard: monitors incidents (evidence: `README.md`)
- Monitoring Dashboard → HTTP API: requests monitoring data (evidence: `README.md`)
- Monitoring Dashboard → Camera Grid: renders cameras (evidence: `frontend/src/components/CameraGrid.tsx`)
- Camera Grid → HTTP API: loads video
- Monitoring Dashboard → Incident Views: shows incident records (evidence: `README.md`)
- Monitoring Dashboard → Analytics View: shows analytics (evidence: `README.md`)
- Monitoring Dashboard → Ontology Simulator: offers simulation (evidence: `README.md`)
- Monitoring Dashboard → Pipeline View: visualizes pipeline (evidence: `README.md`)
- Workflow Graph → Incident State: passes state (evidence: `agentic/graph.py`)
