# whooslizi/drowsinessdetector architecture

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

- Interactive diagram: https://gitdiagram.com/whooslizi/drowsinessdetector
- Repository: https://github.com/whooslizi/drowsinessdetector

## Overview

Drowsiness Detector offers two runtime paths: a browser-based Vue monitor and a Python desktop app. Both use camera input to assess eye closure and surface drowsiness; the desktop path sends detector telemetry into its webview and can play a system sound. The README also documents a chime and meme overlay, though their implementation is not visible in the sampled excerpts. The large Vue component appears to combine the monitor with its Windows XP-style desktop interface. Connections reflect shown calls and documented behavior; unsampled details are omitted.

Main entry points: [`app.py`](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/app.py) (Desktop API and loop), [`src/components/DrowsinessMonitor.vue`](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/components/DrowsinessMonitor.vue) (Monitor and desktop UI), [`detector.py`](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py) (Frame detector), [`src/App.vue`](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/App.vue) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web monitor"]
  node_webentry["Vue entry<br/>[main.ts]"]
  node_appview["App shell<br/>[App.vue]"]
  node_monitor["Monitor and desktop UI"]
end

subgraph group_desktop["Desktop runtime"]
  node_desktopapp["Desktop API and loop<br/>[app.py]"]
  node_webview["PyWebView window<br/>[app.py]"]
end

subgraph group_detection["Detection"]
  node_detector["Frame detector<br/>[detector.py]"]
  node_opencv["OpenCV camera and fallback<br/>[detector.py]"]
end

subgraph group_contracts["Telemetry contract"]
  node_telemetry["Telemetry data<br/>[detector.py]"]
  node_webcontract["Telemetry type<br/>[telemetry.ts]"]
end

node_user(("User"))
node_browser["Browser camera"]
node_mp["MediaPipe Face Mesh"]
node_webalerts["Chime and meme"]
node_systemaudio["System audio"]

node_user -->|"uses"| node_monitor
node_webentry -->|"mounts"| node_appview
node_appview -->|"renders"| node_monitor
node_monitor -->|"requests camera"| node_browser
node_monitor -->|"configures and sends frames"| node_mp
node_monitor -->|"uses type"| node_webcontract
node_monitor -.->|"triggers"| node_webalerts
node_user -->|"runs"| node_desktopapp
node_desktopapp -->|"creates and processes frames"| node_detector
node_desktopapp -->|"captures camera frames"| node_opencv
node_detector -->|"uses fallback detection"| node_opencv
node_detector -->|"uses face mesh"| node_mp
node_detector -->|"returns"| node_telemetry
node_desktopapp -->|"creates window"| node_webview
node_desktopapp -->|"pushes telemetry"| node_webview
node_desktopapp -->|"plays alert"| node_systemaudio
node_desktopapp -->|"updates thresholds"| node_detector

click node_webentry "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/main.ts"
click node_appview "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/App.vue"
click node_monitor "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/components/DrowsinessMonitor.vue"
click node_desktopapp "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/app.py"
click node_webview "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/app.py"
click node_detector "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py"
click node_opencv "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py"
click node_telemetry "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py"
click node_webcontract "https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/types/telemetry.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_webentry,node_appview,node_monitor,node_user,node_browser toneBlue
class node_desktopapp,node_webview toneAmber
class node_detector,node_opencv,node_mp toneMint
class node_telemetry,node_webcontract toneRose
class node_webalerts,node_systemaudio toneIndigo
```

## Components

### Web monitor

- [Vue entry](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/main.ts): `src/main.ts`
- [App shell](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/App.vue): `src/App.vue`
- [Monitor and desktop UI](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/components/DrowsinessMonitor.vue): `src/components/DrowsinessMonitor.vue`

### Desktop runtime

- [Desktop API and loop](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/app.py): `app.py`
- [PyWebView window](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/app.py): `app.py`

### Detection

- [Frame detector](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py): `detector.py`
- [OpenCV camera and fallback](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py): `detector.py`

### Telemetry contract

- [Telemetry data](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/detector.py): `detector.py`
- [Telemetry type](https://github.com/whooslizi/drowsinessdetector/blob/eoleun/src/types/telemetry.ts): `src/types/telemetry.ts`

### Other components

- **User**
- **Browser camera**
- **MediaPipe Face Mesh**
- **Chime and meme**
- **System audio**

## Connections

- User → Monitor and desktop UI: uses (evidence: `README.md`)
- Vue entry → App shell: mounts (evidence: `src/main.ts`)
- App shell → Monitor and desktop UI: renders (evidence: `src/App.vue`)
- Monitor and desktop UI → Browser camera: requests camera (evidence: `src/components/DrowsinessMonitor.vue`)
- Monitor and desktop UI → MediaPipe Face Mesh: configures and sends frames (evidence: `src/components/DrowsinessMonitor.vue`)
- Monitor and desktop UI → Telemetry type: uses type (evidence: `src/components/DrowsinessMonitor.vue`)
- Monitor and desktop UI → Chime and meme: triggers (evidence: `README.md`)
- User → Desktop API and loop: runs (evidence: `README.md`)
- Desktop API and loop → Frame detector: creates and processes frames (evidence: `app.py`)
- Desktop API and loop → OpenCV camera and fallback: captures camera frames (evidence: `app.py`)
- Frame detector → OpenCV camera and fallback: uses fallback detection (evidence: `detector.py`)
- Frame detector → MediaPipe Face Mesh: uses face mesh (evidence: `detector.py`)
- Frame detector → Telemetry data: returns (evidence: `detector.py`)
- Desktop API and loop → PyWebView window: creates window (evidence: `app.py`)
- Desktop API and loop → PyWebView window: pushes telemetry (evidence: `app.py`)
- Desktop API and loop → System audio: plays alert (evidence: `app.py`)
- Desktop API and loop → Frame detector: updates thresholds (evidence: `app.py`)
