# sarfarazahemad9205/crowdshield-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sarfarazahemad9205/crowdshield-ai
- Repository: https://github.com/sarfarazahemad9205/crowdshield-ai

## Overview

StampedeGuard AI accepts a crowd video, tracks people and movement, then assesses tracking reliability and movement risk for display in the web dashboard. The live path is supported by the sampled frontend, API, video-processing, and risk-engine excerpts. The tree also shows separate dataset/training-video processing and offline feature-analysis code; their internal wiring is not established by the excerpts, so those branches are kept limited. No README content was provided.

Main entry points: [`backend/app/main.py`](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/main.py) (Backend API), [`backend/ml/inference/live_risk_engine.py`](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/inference/live_risk_engine.py) (Live risk engine), [`backend/ml/feature_extraction.py`](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/feature_extraction.py) (Feature extraction), [`backend/app/video_processor.py`](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/video_processor.py) (Video processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard and API"]
  node_dashboard["Dashboard<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_tracking["Video tracking"]
  node_backend_api["Backend API<br/>[main.py]"]
  node_video_processor["Video processor<br/>[video_processor.py]"]
  node_tracking_csv["Tracking CSV"]
  node_processed_video["Annotated video"]
end

subgraph group_risk["Live risk analysis"]
  node_live_engine["Live risk engine"]
  node_tracking_cleaning["Tracking checks"]
  node_time_windows["Time windows"]
  node_behavioral_features["Behavior features"]
  node_risk_result["Risk assessment"]
end

subgraph group_offline["Dataset analysis"]
  node_dataset_video["Dataset video processing"]
  node_training_video["Training video processing"]
  node_feature_extraction["Feature extraction"]
  node_basic_features["Basic features<br/>[basic_features.py]"]
  node_temporal_features["Temporal features"]
  node_directional_features["Directional features"]
  node_analysis_tools["Training analysis"]
end

node_viewer(("Video analyst"))
node_detector["YOLO tracker"]

node_viewer -->|"selects video"| node_dashboard
node_dashboard -->|"uploads and processes"| node_api_client
node_api_client -->|"HTTP requests"| node_backend_api
node_backend_api -->|"processes video"| node_video_processor
node_video_processor -.->|"tracks people"| node_detector
node_video_processor -->|"writes tracks"| node_tracking_csv
node_video_processor -->|"writes video"| node_processed_video
node_backend_api -->|"reads tracking data"| node_tracking_csv
node_backend_api -->|"analyzes tracks"| node_live_engine
node_live_engine -->|"checks anomalies"| node_tracking_cleaning
node_live_engine -->|"creates windows"| node_time_windows
node_live_engine -->|"calculates features"| node_behavioral_features
node_live_engine -->|"produces risk"| node_risk_result
node_backend_api -->|"returns result"| node_api_client
node_api_client -->|"returns analysis"| node_dashboard
node_feature_extraction -->|"checks anomalies"| node_tracking_cleaning
node_feature_extraction -->|"calculates features"| node_basic_features
node_feature_extraction -->|"calculates features"| node_temporal_features
node_feature_extraction -->|"calculates features"| node_directional_features

click node_dashboard "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/frontend/src/services/api.js"
click node_backend_api "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/main.py"
click node_video_processor "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/video_processor.py"
click node_live_engine "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/inference/live_risk_engine.py"
click node_tracking_cleaning "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/tracking_cleaning.py"
click node_time_windows "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/analysis/create_time_windows.py"
click node_behavioral_features "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/analysis/behavioral_features.py"
click node_dataset_video "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/process_dataset_videos.py"
click node_training_video "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/process_training_videos.py"
click node_feature_extraction "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/feature_extraction.py"
click node_basic_features "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/basic_features.py"
click node_temporal_features "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/temporal_features.py"
click node_directional_features "https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/directional_features.py"
click node_analysis_tools "https://github.com/sarfarazahemad9205/crowdshield-ai/tree/main/backend/ml/analysis"

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_dashboard,node_api_client toneBlue
class node_backend_api,node_video_processor,node_tracking_csv,node_processed_video toneAmber
class node_live_engine,node_tracking_cleaning,node_time_windows,node_behavioral_features,node_risk_result toneMint
class node_dataset_video,node_training_video,node_feature_extraction,node_basic_features,node_temporal_features,node_directional_features,node_analysis_tools toneRose
class node_viewer,node_detector toneIndigo
```

## Components

### Dashboard and API

- [Dashboard](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Video tracking

- [Backend API](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Video processor](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/video_processor.py): `backend/app/video_processor.py`
- **Tracking CSV**
- **Annotated video**

### Live risk analysis

- [Live risk engine](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/inference/live_risk_engine.py): `backend/ml/inference/live_risk_engine.py`
- [Tracking checks](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/tracking_cleaning.py): `backend/ml/features/tracking_cleaning.py`
- [Time windows](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/analysis/create_time_windows.py): `backend/ml/analysis/create_time_windows.py`
- [Behavior features](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/analysis/behavioral_features.py): `backend/ml/analysis/behavioral_features.py`
- **Risk assessment**

### Dataset analysis

- [Dataset video processing](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/process_dataset_videos.py): `backend/app/process_dataset_videos.py`
- [Training video processing](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/app/process_training_videos.py): `backend/app/process_training_videos.py`
- [Feature extraction](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/feature_extraction.py): `backend/ml/feature_extraction.py`
- [Basic features](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/basic_features.py): `backend/ml/features/basic_features.py`
- [Temporal features](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/temporal_features.py): `backend/ml/features/temporal_features.py`
- [Directional features](https://github.com/sarfarazahemad9205/crowdshield-ai/blob/main/backend/ml/features/directional_features.py): `backend/ml/features/directional_features.py`
- [Training analysis](https://github.com/sarfarazahemad9205/crowdshield-ai/tree/main/backend/ml/analysis): `backend/ml/analysis`

### Other components

- **Video analyst**
- **YOLO tracker**

## Connections

- Video analyst → Dashboard: selects video
- Dashboard → API client: uploads and processes
- API client → Backend API: HTTP requests
- Backend API → Video processor: processes video
- Video processor → YOLO tracker: tracks people
- Video processor → Tracking CSV: writes tracks
- Video processor → Annotated video: writes video
- Backend API → Tracking CSV: reads tracking data
- Backend API → Live risk engine: analyzes tracks
- Live risk engine → Tracking checks: checks anomalies
- Live risk engine → Time windows: creates windows
- Live risk engine → Behavior features: calculates features
- Live risk engine → Risk assessment: produces risk
- Backend API → API client: returns result
- API client → Dashboard: returns analysis
- Feature extraction → Tracking checks: checks anomalies
- Feature extraction → Basic features: calculates features
- Feature extraction → Temporal features: calculates features
- Feature extraction → Directional features: calculates features
