# akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection architecture

> Architecture diagram of the GitHub repository akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection, 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/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection
- Repository: https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection

## Overview

DrowSense monitors driver drowsiness using edge camera and wearable-style vital data, computes fatigue and stages it in the fog service, then persists metrics and serves live and historical dashboard views. The dashboard also presents alert/category summaries and offers Spotify wake-up controls. Evidence is limited to the supplied excerpts and SOURCE INDEX; integrations and routes not explicitly wired there are omitted.

Main entry points: [`dashboard/src/App.tsx`](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/App.tsx) (Dashboard App), [`fog/fog_server.py`](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/fog/fog_server.py) (Fog API), [`edge/main_edge.py`](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/main_edge.py) (Edge Orchestrator), [`edge/camera_module.py`](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/camera_module.py) (Camera Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge Sensing"]
  node_edge_runner["Edge Orchestrator<br/>[main_edge.py]"]
  node_camera["Camera Analysis<br/>[camera_module.py]"]
  node_vitals["Vital Simulator"]
  node_edge_ws["Edge WebSocket<br/>[edge_ws.py]"]
end

subgraph group_analysis["Fatigue Analysis"]
  node_logic["Drowsiness Logic"]
end

subgraph group_service["Fog Services"]
  node_fog["Fog API<br/>[fog_server.py]"]
  node_db[("PostgreSQL Data<br/>[db_manager.py]")]
  node_spotify["Wake-up Playback<br/>[spotify_wakeup.py]"]
end

subgraph group_dashboard["Driver Dashboard"]
  node_app["Dashboard App<br/>[App.tsx]"]
  node_metrics["Live Metrics"]
  node_chart["Fatigue History<br/>[FatigueChart.tsx]"]
  node_categories["Category Summary"]
  node_alerts["Alert Log<br/>[AlertLog.tsx]"]
  node_spotify_ui["Spotify Controls"]
  node_api_client["REST Client<br/>[api.ts]"]
  node_ws_client["WebSocket Client<br/>[websocket.ts]"]
  node_spotify_client["Spotify Client<br/>[spotify.ts]"]
  node_types["Dashboard Types<br/>[index.ts]"]
end

node_driver(("Driver"))
node_browser(("Dashboard User"))

node_driver -.->|"provides video"| node_camera
node_edge_runner -->|"reads frames"| node_camera
node_edge_runner -->|"gets vitals"| node_vitals
node_camera -->|"uses algorithms"| node_logic
node_edge_runner -->|"posts metrics"| node_fog
node_fog -->|"calculates fatigue"| node_logic
node_fog -->|"stores metrics"| node_db
node_fog -->|"reads history"| node_db
node_fog -->|"triggers playback"| node_spotify
node_browser -.->|"views dashboard"| node_app
node_app -.->|"requests data"| node_api_client
node_app -.->|"subscribes live"| node_ws_client
node_app -->|"renders"| node_metrics
node_app -->|"renders"| node_chart
node_app -->|"renders"| node_categories
node_app -->|"renders"| node_alerts
node_app -->|"renders"| node_spotify_ui
node_app -->|"uses data types"| node_types
node_metrics -->|"uses data types"| node_types
node_chart -.->|"uses data types"| node_types
node_browser -.->|"controls playback"| node_spotify_ui
node_spotify_ui -.->|"invokes controls"| node_spotify_client

click node_edge_runner "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/main_edge.py"
click node_camera "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/camera_module.py"
click node_vitals "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/heart_rate_simulator.py"
click node_edge_ws "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/edge_ws.py"
click node_logic "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/utils/drowsiness_logic.py"
click node_fog "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/fog/fog_server.py"
click node_db "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/databases/db_manager.py"
click node_spotify "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/spotify/spotify_wakeup.py"
click node_app "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/App.tsx"
click node_metrics "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/RealTimeMetrics.tsx"
click node_chart "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/FatigueChart.tsx"
click node_categories "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/CategoryDistribution.tsx"
click node_alerts "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/AlertLog.tsx"
click node_spotify_ui "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/SpotifyController.tsx"
click node_api_client "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/services/api.ts"
click node_ws_client "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/services/websocket.ts"
click node_spotify_client "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/services/spotify.ts"
click node_types "https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/types/index.ts"

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_edge_runner,node_camera,node_vitals,node_edge_ws,node_browser toneBlue
class node_logic toneAmber
class node_fog,node_db,node_spotify toneMint
class node_app,node_metrics,node_chart,node_categories,node_alerts,node_spotify_ui,node_api_client,node_ws_client,node_spotify_client,node_types toneRose
class node_driver toneIndigo
```

## Components

### Edge Sensing

- [Edge Orchestrator](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/main_edge.py): `edge/main_edge.py`
- [Camera Analysis](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/camera_module.py): `edge/camera_module.py`
- [Vital Simulator](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/heart_rate_simulator.py): `edge/heart_rate_simulator.py`
- [Edge WebSocket](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/edge/edge_ws.py): `edge/edge_ws.py`

### Fatigue Analysis

- [Drowsiness Logic](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/utils/drowsiness_logic.py): `utils/drowsiness_logic.py`

### Fog Services

- [Fog API](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/fog/fog_server.py): `fog/fog_server.py`
- [PostgreSQL Data](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/databases/db_manager.py): `databases/db_manager.py`
- [Wake-up Playback](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/spotify/spotify_wakeup.py): `spotify/spotify_wakeup.py`

### Driver Dashboard

- [Dashboard App](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/App.tsx): `dashboard/src/App.tsx`
- [Live Metrics](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/RealTimeMetrics.tsx): `dashboard/src/components/RealTimeMetrics.tsx`
- [Fatigue History](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/FatigueChart.tsx): `dashboard/src/components/FatigueChart.tsx`
- [Category Summary](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/CategoryDistribution.tsx): `dashboard/src/components/CategoryDistribution.tsx`
- [Alert Log](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/AlertLog.tsx): `dashboard/src/components/AlertLog.tsx`
- [Spotify Controls](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/components/SpotifyController.tsx): `dashboard/src/components/SpotifyController.tsx`
- [REST Client](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/services/api.ts): `dashboard/src/services/api.ts`
- [WebSocket Client](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/services/websocket.ts): `dashboard/src/services/websocket.ts`
- [Spotify Client](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/services/spotify.ts): `dashboard/src/services/spotify.ts`
- [Dashboard Types](https://github.com/akshara-gupta23bce1325/drowsense-edge-fog-fatigue-detection/blob/main/dashboard/src/types/index.ts): `dashboard/src/types/index.ts`

### Other components

- **Driver**
- **Dashboard User**

## Connections

- Driver → Camera Analysis: provides video
- Edge Orchestrator → Camera Analysis: reads frames (evidence: `edge/main_edge.py`)
- Edge Orchestrator → Vital Simulator: gets vitals (evidence: `edge/main_edge.py`)
- Camera Analysis → Drowsiness Logic: uses algorithms (evidence: `edge/camera_module.py`)
- Edge Orchestrator → Fog API: posts metrics (evidence: `edge/main_edge.py`)
- Fog API → Drowsiness Logic: calculates fatigue (evidence: `fog/fog_server.py`)
- Fog API → PostgreSQL Data: stores metrics (evidence: `fog/fog_server.py`)
- Fog API → PostgreSQL Data: reads history (evidence: `fog/fog_server.py`)
- Fog API → Wake-up Playback: triggers playback (evidence: `fog/fog_server.py`)
- Dashboard User → Dashboard App: views dashboard
- Dashboard App → REST Client: requests data
- Dashboard App → WebSocket Client: subscribes live
- Dashboard App → Live Metrics: renders (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Fatigue History: renders (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Category Summary: renders (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Alert Log: renders (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Spotify Controls: renders (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Dashboard Types: uses data types (evidence: `dashboard/src/App.tsx`)
- Live Metrics → Dashboard Types: uses data types (evidence: `dashboard/src/components/RealTimeMetrics.tsx`)
- Fatigue History → Dashboard Types: uses data types (evidence: `dashboard/src/components/FatigueChart.tsx`)
- Dashboard User → Spotify Controls: controls playback
- Spotify Controls → Spotify Client: invokes controls
