# harshitahegde/safego_ai-safety-monitoring-and-alert-system architecture

> Architecture diagram of the GitHub repository harshitahegde/safego_ai-safety-monitoring-and-alert-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system
- Repository: https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system

## Overview

SafeGoAI combines a Flask user-management application with a separate webcam monitoring process. Its main safety workflow is camera capture, gesture confirmation, identity and location enrichment, evidence capture, then push and email alerts subject to a cooldown. The sampled detection excerpts show several stages, but omit portions of alert dispatch and temporal logic; README statements support those links. The user-management routes and SQLite access are visible in app.py; the schema is initialized separately.

Main entry points: [`detection.py`](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py) (Monitoring loop), [`app.py`](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py) (Flask routes), [`init_db.py`](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/init_db.py) (Database initializer), [`index.html`](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/index.html) (Web pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monitoring["Safety monitoring"]
  node_monitor["Monitoring loop<br/>[detection.py]"]
  node_gesture["Gesture recognition<br/>[detection.py]"]
  node_face["Face recognition<br/>[detection.py]"]
  node_geolocation["IP geolocation<br/>[detection.py]"]
  node_evidence["Evidence capture<br/>[detection.py]"]
  node_cooldown["Alert cooldown<br/>[detection.py]"]
end

subgraph group_alerts["Alert delivery"]
  node_push["Push notification<br/>[detection.py]"]
  node_email["Email alert<br/>[detection.py]"]
end

subgraph group_web["User management"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_web_views["Web pages<br/>[index.html]"]
  node_registration["Registration and login<br/>[app.py]"]
  node_profile["Profile management<br/>[app.py]"]
  node_photo_upload["Profile photo upload<br/>[app.py]"]
end

subgraph group_storage["User data"]
  node_database[("SQLite user database<br/>[app.py]")]
  node_schema["Database initializer<br/>[init_db.py]"]
end

node_person(("Person at camera"))
node_webcam["Webcam"]
node_ntfy["ntfy.sh"]
node_gmail["Gmail SMTP"]
node_browser_user(("Web user"))

node_person -->|"signals to"| node_webcam
node_webcam -->|"provides frames"| node_monitor
node_monitor -->|"processes frames"| node_gesture
node_gesture -->|"confirms gesture"| node_monitor
node_monitor -->|"identifies person"| node_face
node_monitor -->|"requests location"| node_geolocation
node_monitor -->|"captures frame"| node_evidence
node_monitor -->|"checks interval"| node_cooldown
node_monitor -->|"dispatches alert"| node_push
node_monitor -->|"dispatches alert"| node_email
node_push -->|"sends notification"| node_ntfy
node_email -->|"sends email"| node_gmail
node_email -->|"attaches image"| node_evidence
node_browser_user -->|"uses"| node_webapp
node_webapp -->|"renders pages"| node_web_views
node_webapp -->|"routes requests"| node_registration
node_webapp -->|"routes requests"| node_profile
node_registration -->|"inserts user"| node_database
node_profile -->|"reads and updates"| node_database
node_registration -->|"saves photo"| node_photo_upload
node_photo_upload -->|"provides known faces"| node_face
node_schema -->|"creates schema"| node_database

click node_monitor "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_gesture "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_face "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_geolocation "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_evidence "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_cooldown "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_push "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_email "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py"
click node_webapp "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py"
click node_web_views "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/index.html"
click node_registration "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py"
click node_profile "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py"
click node_photo_upload "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py"
click node_database "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py"
click node_schema "https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/init_db.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_monitor,node_gesture,node_face,node_geolocation,node_evidence,node_cooldown,node_browser_user toneBlue
class node_push,node_email toneAmber
class node_webapp,node_web_views,node_registration,node_profile,node_photo_upload toneMint
class node_database,node_schema toneRose
class node_person,node_webcam,node_ntfy,node_gmail toneIndigo
```

## Components

### Safety monitoring

- [Monitoring loop](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`
- [Gesture recognition](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`
- [Face recognition](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`
- [IP geolocation](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`
- [Evidence capture](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`
- [Alert cooldown](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`

### Alert delivery

- [Push notification](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`
- [Email alert](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/detection.py): `detection.py`

### User management

- [Flask routes](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py): `app.py`
- [Web pages](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/index.html): `index.html`
- [Registration and login](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py): `app.py`
- [Profile management](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py): `app.py`
- [Profile photo upload](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py): `app.py`

### User data

- [SQLite user database](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/app.py): `app.py`
- [Database initializer](https://github.com/harshitahegde/safego_ai-safety-monitoring-and-alert-system/blob/main/init_db.py): `init_db.py`

### Other components

- **Person at camera**
- **Webcam**
- **ntfy.sh**
- **Gmail SMTP**
- **Web user**

## Connections

- Person at camera → Webcam: signals to (evidence: `README.md`)
- Webcam → Monitoring loop: provides frames (evidence: `README.md`)
- Monitoring loop → Gesture recognition: processes frames (evidence: `detection.py`)
- Gesture recognition → Monitoring loop: confirms gesture (evidence: `detection.py`)
- Monitoring loop → Face recognition: identifies person (evidence: `detection.py`)
- Monitoring loop → IP geolocation: requests location (evidence: `detection.py`)
- Monitoring loop → Evidence capture: captures frame (evidence: `detection.py`)
- Monitoring loop → Alert cooldown: checks interval (evidence: `README.md`)
- Monitoring loop → Push notification: dispatches alert (evidence: `README.md`)
- Monitoring loop → Email alert: dispatches alert (evidence: `README.md`)
- Push notification → ntfy.sh: sends notification (evidence: `README.md`)
- Email alert → Gmail SMTP: sends email (evidence: `detection.py`)
- Email alert → Evidence capture: attaches image (evidence: `README.md`)
- Web user → Flask routes: uses (evidence: `app.py`)
- Flask routes → Web pages: renders pages (evidence: `app.py`)
- Flask routes → Registration and login: routes requests (evidence: `app.py`)
- Flask routes → Profile management: routes requests (evidence: `app.py`)
- Registration and login → SQLite user database: inserts user (evidence: `app.py`)
- Profile management → SQLite user database: reads and updates (evidence: `app.py`)
- Registration and login → Profile photo upload: saves photo (evidence: `app.py`)
- Profile photo upload → Face recognition: provides known faces (evidence: `README.md`)
- Database initializer → SQLite user database: creates schema (evidence: `init_db.py`)
