# ahmedsamehzaky/depi_g_project architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedsamehzaky/depi_g_project
- Repository: https://github.com/ahmedsamehzaky/depi_g_project

## Overview

DriveWake’s primary workflow captures camera frames, extracts facial and phone/hand signals, applies temporal rules, then presents and records alerts. Its broader product also includes a browser demo, trip/session APIs, GPS tracking, navigation, and safety analytics. The README supports the detection workflow; sampled source confirms selected API, browser-engine, and GPS relationships. Several larger subsystems are represented from the source index and README, so their internal links are omitted where call sites were not shown.

Main entry points: [`drivewake/state.py`](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/state.py) (Temporal State), [`drivewake/__main__.py`](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/__main__.py) (Desktop Monitor), [`web/app.js`](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/app.js) (Web Demo), [`drivewake/gps/coordinator.py`](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/gps/coordinator.py) (GPS Coordinator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_detection["Driver Detection"]
  node_desktop["Desktop Monitor<br/>[__main__.py]"]
  node_face["Face Tracking<br/>[detector.py]"]
  node_phone["Phone and Hand<br/>[phone.py]"]
  node_vision["Vision Enhancement"]
  node_signals["Frame Metrics<br/>[metrics.py]"]
  node_temporal["Temporal State<br/>[state.py]"]
  node_nodding["Nod Detection<br/>[nodding.py]"]
end

subgraph group_feedback["Alerts and Review"]
  node_alerts["Alert Policy<br/>[alerts.py]"]
  node_alarm["Audio Alerts<br/>[alarm.py]"]
  node_hud["Live HUD<br/>[hud.py]"]
  node_preview["Camera Preview<br/>[preview.py]"]
  node_evaluation["Scenario Evaluation<br/>[evaluate.py]"]
  node_reel["Drive Reel<br/>[reel.py]"]
end

subgraph group_trip["Trip Services"]
  node_server["REST API<br/>[server.py]"]
  node_sessions["Session Manager<br/>[session.py]"]
  node_livehub["Live Events<br/>[live.py]"]
  node_storage[("Trip Storage<br/>[storage.py]")]
  node_gps["GPS Coordinator<br/>[coordinator.py]"]
  node_gpsprovider["GPS Providers"]
  node_route["Route Reporting<br/>[reporting.py]"]
  node_navigation["Navigation<br/>[navigation.py]"]
  node_safety["Safety Score<br/>[safety_score.py]"]
end

subgraph group_web["Browser Experience"]
  node_webapp["Web Demo<br/>[app.js]"]
  node_webengine["Browser State Engine<br/>[engine.js]"]
  node_mesh["Browser Vision<br/>[mesh.js]"]
  node_worker["Vision Worker<br/>[worker.js]"]
  node_dashboard["Trip Dashboard<br/>[dashboard.js]"]
  node_dashnav["Dashboard Navigation<br/>[navigation.js]"]
  node_branding["Dashboard Branding<br/>[branding.js]"]
end

node_driver(("Driver"))
node_browser(("Browser User"))

node_driver -->|"starts monitoring"| node_desktop
node_desktop -->|"processes frames"| node_face
node_desktop -->|"checks frames"| node_phone
node_face -->|"enhances frames"| node_vision
node_face -->|"extracts signals"| node_signals
node_desktop -->|"evaluates signals"| node_temporal
node_phone -->|"provides evidence"| node_temporal
node_temporal -->|"checks head motion"| node_nodding
node_temporal -->|"drives display"| node_hud
node_temporal -->|"triggers alerts"| node_alarm
node_alarm -->|"selects phrases"| node_alerts
node_desktop -.->|"publishes frames"| node_preview
node_desktop -->|"logs events"| node_storage
node_evaluation -->|"evaluates scenarios"| node_temporal
node_reel -->|"analyzes footage"| node_temporal
node_server -->|"starts sessions"| node_sessions
node_server -->|"resolves destinations"| node_navigation
node_sessions -.->|"manages preview"| node_preview
node_gps -->|"selects source"| node_gpsprovider
node_gps -->|"records samples"| node_storage
node_gps -.->|"publishes updates"| node_livehub
node_storage -.->|"supplies samples"| node_route
node_browser -->|"opens demo"| node_webapp
node_webapp -->|"updates state"| node_webengine
node_webapp -->|"uses vision"| node_mesh
node_mesh -.->|"dispatches inference"| node_worker
node_webapp -.->|"opens dashboard"| node_dashboard
node_dashboard -.->|"uses navigation"| node_dashnav
node_dashboard -.->|"uses branding"| node_branding
node_navigation -.->|"contributes to scoring"| node_safety

click node_desktop "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/__main__.py"
click node_face "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/detector.py"
click node_phone "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/phone.py"
click node_vision "https://github.com/ahmedsamehzaky/depi_g_project/tree/main/drivewake/vision"
click node_signals "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/metrics.py"
click node_temporal "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/state.py"
click node_nodding "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/nodding.py"
click node_alerts "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/alerts.py"
click node_alarm "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/alarm.py"
click node_hud "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/hud.py"
click node_preview "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/preview.py"
click node_evaluation "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/evaluate.py"
click node_reel "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/reel.py"
click node_server "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/server.py"
click node_sessions "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/session.py"
click node_livehub "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/live.py"
click node_storage "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/storage.py"
click node_gps "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/gps/coordinator.py"
click node_gpsprovider "https://github.com/ahmedsamehzaky/depi_g_project/tree/main/drivewake/gps"
click node_route "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/gps/reporting.py"
click node_navigation "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/navigation.py"
click node_safety "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/safety_score.py"
click node_webapp "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/app.js"
click node_webengine "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/engine.js"
click node_mesh "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/mesh.js"
click node_worker "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/worker.js"
click node_dashboard "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/dashboard/dashboard.js"
click node_dashnav "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/dashboard/navigation.js"
click node_branding "https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/dashboard/branding.js"

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_desktop,node_face,node_phone,node_vision,node_signals,node_temporal,node_nodding,node_browser toneBlue
class node_alerts,node_alarm,node_hud,node_preview,node_evaluation,node_reel toneAmber
class node_server,node_sessions,node_livehub,node_storage,node_gps,node_gpsprovider,node_route,node_navigation,node_safety toneMint
class node_webapp,node_webengine,node_mesh,node_worker,node_dashboard,node_dashnav,node_branding toneRose
class node_driver toneIndigo
```

## Components

### Driver Detection

- [Desktop Monitor](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/__main__.py): `drivewake/__main__.py`
- [Face Tracking](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/detector.py): `drivewake/detector.py`
- [Phone and Hand](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/phone.py): `drivewake/phone.py`
- [Vision Enhancement](https://github.com/ahmedsamehzaky/depi_g_project/tree/main/drivewake/vision): `drivewake/vision`
- [Frame Metrics](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/metrics.py): `drivewake/metrics.py`
- [Temporal State](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/state.py): `drivewake/state.py`
- [Nod Detection](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/nodding.py): `drivewake/nodding.py`

### Alerts and Review

- [Alert Policy](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/alerts.py): `drivewake/alerts.py`
- [Audio Alerts](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/alarm.py): `drivewake/alarm.py`
- [Live HUD](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/hud.py): `drivewake/hud.py`
- [Camera Preview](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/preview.py): `drivewake/preview.py`
- [Scenario Evaluation](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/evaluate.py): `drivewake/evaluate.py`
- [Drive Reel](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/reel.py): `drivewake/reel.py`

### Trip Services

- [REST API](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/server.py): `drivewake/server.py`
- [Session Manager](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/session.py): `drivewake/session.py`
- [Live Events](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/live.py): `drivewake/live.py`
- [Trip Storage](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/storage.py): `drivewake/storage.py`
- [GPS Coordinator](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/gps/coordinator.py): `drivewake/gps/coordinator.py`
- [GPS Providers](https://github.com/ahmedsamehzaky/depi_g_project/tree/main/drivewake/gps): `drivewake/gps`
- [Route Reporting](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/gps/reporting.py): `drivewake/gps/reporting.py`
- [Navigation](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/navigation.py): `drivewake/navigation.py`
- [Safety Score](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/drivewake/safety_score.py): `drivewake/safety_score.py`

### Browser Experience

- [Web Demo](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/app.js): `web/app.js`
- [Browser State Engine](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/engine.js): `web/engine.js`
- [Browser Vision](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/mesh.js): `web/mesh.js`
- [Vision Worker](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/worker.js): `web/worker.js`
- [Trip Dashboard](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/dashboard/dashboard.js): `web/dashboard/dashboard.js`
- [Dashboard Navigation](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/dashboard/navigation.js): `web/dashboard/navigation.js`
- [Dashboard Branding](https://github.com/ahmedsamehzaky/depi_g_project/blob/main/web/dashboard/branding.js): `web/dashboard/branding.js`

### Other components

- **Driver**
- **Browser User**

## Connections

- Driver → Desktop Monitor: starts monitoring
- Desktop Monitor → Face Tracking: processes frames (evidence: `drivewake/__main__.py`)
- Desktop Monitor → Phone and Hand: checks frames (evidence: `drivewake/__main__.py`)
- Face Tracking → Vision Enhancement: enhances frames (evidence: `drivewake/detector.py`)
- Face Tracking → Frame Metrics: extracts signals (evidence: `drivewake/detector.py`)
- Desktop Monitor → Temporal State: evaluates signals (evidence: `drivewake/__main__.py`)
- Phone and Hand → Temporal State: provides evidence
- Temporal State → Nod Detection: checks head motion (evidence: `drivewake/state.py`)
- Temporal State → Live HUD: drives display (evidence: `drivewake/hud.py`)
- Temporal State → Audio Alerts: triggers alerts
- Audio Alerts → Alert Policy: selects phrases (evidence: `drivewake/alarm.py`)
- Desktop Monitor → Camera Preview: publishes frames (evidence: `drivewake/__main__.py`)
- Desktop Monitor → Trip Storage: logs events (evidence: `drivewake/__main__.py`)
- Scenario Evaluation → Temporal State: evaluates scenarios (evidence: `drivewake/evaluate.py`)
- Drive Reel → Temporal State: analyzes footage (evidence: `drivewake/reel.py`)
- REST API → Session Manager: starts sessions (evidence: `drivewake/server.py`)
- REST API → Navigation: resolves destinations (evidence: `drivewake/server.py`)
- Session Manager → Camera Preview: manages preview (evidence: `drivewake/session.py`)
- GPS Coordinator → GPS Providers: selects source (evidence: `drivewake/gps/coordinator.py`)
- GPS Coordinator → Trip Storage: records samples (evidence: `drivewake/gps/coordinator.py`)
- GPS Coordinator → Live Events: publishes updates (evidence: `drivewake/gps/coordinator.py`)
- Trip Storage → Route Reporting: supplies samples (evidence: `drivewake/storage.py`)
- Browser User → Web Demo: opens demo
- Web Demo → Browser State Engine: updates state (evidence: `web/app.js`)
- Web Demo → Browser Vision: uses vision (evidence: `web/app.js`)
- Browser Vision → Vision Worker: dispatches inference
- Web Demo → Trip Dashboard: opens dashboard
- Trip Dashboard → Dashboard Navigation: uses navigation
- Trip Dashboard → Dashboard Branding: uses branding
- Navigation → Safety Score: contributes to scoring
