# maheshkhadilkar07/stampede-prediction-with-alerts-system architecture

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

- Interactive diagram: https://gitdiagram.com/maheshkhadilkar07/stampede-prediction-with-alerts-system
- Repository: https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system

## Overview

StampedeGuard is a Flask application for analyzing uploaded footage and live CCTV to detect crowd risk, present results, and notify authorities. The main workflows are upload → background video processing → dashboard/history, and camera → live stream processing → live dashboard/alerts. The graph preserves authentication, administration, persistence, analytics, and PDF reports. Source excerpts show the video-processing orchestration and alert persistence; documented capabilities support other links. Some route-level details and detector internals were not sampled, so those connections are based on the README or omitted where uncertain.

Main entry points: [`streaming/stream_manager.py`](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/stream_manager.py) (Live session manager), [`app.py`](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/app.py) (Flask routes), [`detector/video_processor.py`](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/video_processor.py) (Uploaded video processing), [`database/history.py`](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/history.py) (History and analytics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask routes<br/>[app.py]"]
  node_pages["Web pages"]
  node_auth["Authentication and OTP<br/>[otp_service.py]"]
end

subgraph group_analysis["Crowd analysis"]
  node_video["Uploaded video processing<br/>[video_processor.py]"]
  node_yolo["Person detection<br/>[person_detector.py]"]
  node_counter["Crowd counting<br/>[crowd_counter.py]"]
  node_density["Density estimation"]
  node_risk["Risk analysis<br/>[risk_analyzer.py]"]
  node_heatmap["Heatmap overlay<br/>[heatmap.py]"]
end

subgraph group_live["Live streaming"]
  node_camera_reader["Camera reader<br/>[camera_reader.py]"]
  node_producer["Frame producer<br/>[producer.py]"]
  node_consumer["Frame consumer<br/>[consumer.py]"]
  node_manager["Live session manager<br/>[stream_manager.py]"]
end

subgraph group_data["Persistence and alerts"]
  node_database[("SQLite database<br/>[database.py]")]
  node_models["User/video/alert records<br/>[models.py]"]
  node_history["History and analytics<br/>[history.py]"]
  node_notifications["Risk notifications<br/>[email_alert.py]"]
end

subgraph group_services["Supporting services"]
  node_mailer["Email delivery<br/>[mailer.py]"]
  node_reports["PDF reports"]
end

node_user(("User"))
node_camera(("Camera / CCTV"))
node_broker["Fluvio topic"]
node_email(("Email recipients"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_pages
node_app -->|"verifies OTP"| node_auth
node_app -->|"starts background processing"| node_video
node_video -->|"detects people"| node_yolo
node_video -->|"counts crowd"| node_counter
node_video -->|"estimates density"| node_density
node_video -->|"scores risk"| node_risk
node_video -->|"generates overlay"| node_heatmap
node_camera -->|"provides frames"| node_manager
node_app -->|"starts live session"| node_manager
node_manager -->|"opens source"| node_camera_reader
node_manager -->|"publishes frames"| node_producer
node_producer -->|"sends frames"| node_broker
node_broker -->|"delivers frames"| node_consumer
node_manager -->|"reads frames"| node_consumer
node_manager -->|"detects people"| node_yolo
node_manager -->|"counts crowd"| node_counter
node_manager -->|"estimates density"| node_density
node_manager -->|"scores risk"| node_risk
node_manager -->|"generates overlay"| node_heatmap
node_app -->|"initializes"| node_database
node_database -->|"creates tables"| node_models
node_app -->|"persists results"| node_models
node_app -->|"queries history"| node_history
node_history -->|"requests delivery"| node_notifications
node_app -->|"sends live alerts"| node_notifications
node_notifications -->|"sends messages"| node_mailer
node_mailer -->|"delivers email"| node_email
node_app -->|"generates PDF"| node_reports
node_manager -->|"serves live preview and stats"| node_pages
node_video -.->|"provides risk timeline"| node_history

click node_app "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/app.py"
click node_pages "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/tree/main/templates"
click node_auth "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/otp_service.py"
click node_video "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/video_processor.py"
click node_yolo "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/person_detector.py"
click node_counter "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/crowd_counter.py"
click node_density "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/density_estimator.py"
click node_risk "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/risk_analyzer.py"
click node_heatmap "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/heatmap.py"
click node_camera_reader "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/camera_reader.py"
click node_producer "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/producer.py"
click node_consumer "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/consumer.py"
click node_manager "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/stream_manager.py"
click node_database "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/database.py"
click node_models "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/models.py"
click node_history "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/history.py"
click node_notifications "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/email_alert.py"
click node_mailer "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/mailer.py"
click node_reports "https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/report_generator.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_app,node_pages,node_auth,node_user toneBlue
class node_video,node_yolo,node_counter,node_density,node_risk,node_heatmap toneAmber
class node_camera_reader,node_producer,node_consumer,node_manager toneMint
class node_database,node_models,node_history,node_notifications toneRose
class node_mailer,node_reports,node_camera,node_broker,node_email toneIndigo
```

## Components

### Web application

- [Flask routes](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/app.py): `app.py`
- [Web pages](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/tree/main/templates): `templates`
- [Authentication and OTP](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/otp_service.py): `utils/otp_service.py`

### Crowd analysis

- [Uploaded video processing](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/video_processor.py): `detector/video_processor.py`
- [Person detection](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/person_detector.py): `detector/person_detector.py`
- [Crowd counting](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/crowd_counter.py): `detector/crowd_counter.py`
- [Density estimation](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/density_estimator.py): `detector/density_estimator.py`
- [Risk analysis](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/risk_analyzer.py): `detector/risk_analyzer.py`
- [Heatmap overlay](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/detector/heatmap.py): `detector/heatmap.py`

### Live streaming

- [Camera reader](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/camera_reader.py): `streaming/camera_reader.py`
- [Frame producer](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/producer.py): `streaming/producer.py`
- [Frame consumer](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/consumer.py): `streaming/consumer.py`
- [Live session manager](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/streaming/stream_manager.py): `streaming/stream_manager.py`

### Persistence and alerts

- [SQLite database](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/database.py): `database/database.py`
- [User/video/alert records](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/models.py): `database/models.py`
- [History and analytics](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/database/history.py): `database/history.py`
- [Risk notifications](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/email_alert.py): `utils/email_alert.py`

### Supporting services

- [Email delivery](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/mailer.py): `utils/mailer.py`
- [PDF reports](https://github.com/maheshkhadilkar07/stampede-prediction-with-alerts-system/blob/main/utils/report_generator.py): `utils/report_generator.py`

### Other components

- **User**
- **Camera / CCTV**
- **Fluvio topic**
- **Email recipients**

## Connections

- User → Flask routes: uses (evidence: `README.md`)
- Flask routes → Web pages: renders (evidence: `README.md`)
- Flask routes → Authentication and OTP: verifies OTP (evidence: `app.py`)
- Flask routes → Uploaded video processing: starts background processing (evidence: `README.md`)
- Uploaded video processing → Person detection: detects people (evidence: `detector/video_processor.py`)
- Uploaded video processing → Crowd counting: counts crowd (evidence: `detector/video_processor.py`)
- Uploaded video processing → Density estimation: estimates density (evidence: `detector/video_processor.py`)
- Uploaded video processing → Risk analysis: scores risk (evidence: `detector/video_processor.py`)
- Uploaded video processing → Heatmap overlay: generates overlay (evidence: `detector/video_processor.py`)
- Camera / CCTV → Live session manager: provides frames (evidence: `README.md`)
- Flask routes → Live session manager: starts live session (evidence: `README.md`)
- Live session manager → Camera reader: opens source (evidence: `streaming/stream_manager.py`)
- Live session manager → Frame producer: publishes frames (evidence: `streaming/stream_manager.py`)
- Frame producer → Fluvio topic: sends frames (evidence: `README.md`)
- Fluvio topic → Frame consumer: delivers frames (evidence: `README.md`)
- Live session manager → Frame consumer: reads frames (evidence: `streaming/stream_manager.py`)
- Live session manager → Person detection: detects people (evidence: `streaming/stream_manager.py`)
- Live session manager → Crowd counting: counts crowd (evidence: `streaming/stream_manager.py`)
- Live session manager → Density estimation: estimates density (evidence: `streaming/stream_manager.py`)
- Live session manager → Risk analysis: scores risk (evidence: `streaming/stream_manager.py`)
- Live session manager → Heatmap overlay: generates overlay (evidence: `README.md`)
- Flask routes → SQLite database: initializes (evidence: `README.md`)
- SQLite database → User/video/alert records: creates tables (evidence: `database/database.py`)
- Flask routes → User/video/alert records: persists results (evidence: `app.py`)
- Flask routes → History and analytics: queries history (evidence: `database/history.py`)
- History and analytics → Risk notifications: requests delivery (evidence: `database/history.py`)
- Flask routes → Risk notifications: sends live alerts (evidence: `app.py`)
- Risk notifications → Email delivery: sends messages (evidence: `utils/email_alert.py`)
- Email delivery → Email recipients: delivers email (evidence: `README.md`)
- Flask routes → PDF reports: generates PDF (evidence: `README.md`)
- Live session manager → Web pages: serves live preview and stats (evidence: `README.md`)
- Uploaded video processing → History and analytics: provides risk timeline
