# suman222222/doom_scrolling_detector architecture

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

- Interactive diagram: https://gitdiagram.com/suman222222/doom_scrolling_detector
- Repository: https://github.com/suman222222/doom_scrolling_detector

## Overview

This is a small, single-script desktop gaze-monitoring assistant. The user starts the application, which reads webcam frames, detects face landmarks, estimates downward gaze, applies a timed state machine, and plays an alarm after the grace period; the live window shows the measured ratio and state. The README also documents calibration through threshold and grace-period settings. The workflow is implemented in `main.py`; component boundaries below describe its runtime responsibilities, not separate modules.

Main entry points: [`main.py`](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py) (Frame Capture), [`assets/face_landmarker.task`](https://github.com/suman222222/doom_scrolling_detector/blob/main/assets/face_landmarker.task) (Landmarker Model), [`assets/alarm.wav`](https://github.com/suman222222/doom_scrolling_detector/blob/main/assets/alarm.wav) (Alarm Audio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Gaze Detection"]
  node_frames["Frame Capture<br/>[main.py]"]
  node_prep["Frame Preparation<br/>[main.py]"]
  node_model["Face Landmarker<br/>[main.py]"]
  node_model_asset["Landmarker Model"]
  node_gaze["Iris Ratio<br/>[main.py]"]
  node_state["Gaze State Machine<br/>[main.py]"]
end

subgraph group_response["Alert and Display"]
  node_alarm["Alarm Thread<br/>[main.py]"]
  node_sound["Alarm Playback<br/>[main.py]"]
  node_sound_asset["Alarm Audio<br/>[alarm.wav]"]
  node_display["Camera Window<br/>[main.py]"]
end

node_user(("User"))
node_app["Gaze Monitor<br/>[main.py]"]
node_camera["Webcam"]

node_user -->|"starts"| node_app
node_camera -->|"provides frames"| node_frames
node_app -->|"opens stream"| node_frames
node_frames -->|"passes frames"| node_prep
node_prep -->|"submits image"| node_model
node_model_asset -->|"configures model"| node_model
node_model -->|"returns landmarks"| node_gaze
node_gaze -->|"sets gaze flag"| node_state
node_state -->|"starts or stops"| node_alarm
node_alarm -->|"runs playback"| node_sound
node_sound -->|"plays file"| node_sound_asset
node_frames -->|"shows annotated frame"| node_display
node_state -->|"shows status"| node_display
node_display -->|"q stops loop"| node_app

click node_app "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_frames "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_prep "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_model "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_model_asset "https://github.com/suman222222/doom_scrolling_detector/blob/main/assets/face_landmarker.task"
click node_gaze "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_state "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_alarm "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_sound "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py"
click node_sound_asset "https://github.com/suman222222/doom_scrolling_detector/blob/main/assets/alarm.wav"
click node_display "https://github.com/suman222222/doom_scrolling_detector/blob/main/main.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_frames,node_prep,node_model,node_model_asset,node_gaze,node_state,node_user toneBlue
class node_alarm,node_sound,node_sound_asset,node_display toneAmber
class node_app toneTeal
class node_camera toneIndigo
```

## Components

### Gaze Detection

- [Frame Capture](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- [Frame Preparation](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- [Face Landmarker](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- [Landmarker Model](https://github.com/suman222222/doom_scrolling_detector/blob/main/assets/face_landmarker.task): `assets/face_landmarker.task`
- [Iris Ratio](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- [Gaze State Machine](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`

### Alert and Display

- [Alarm Thread](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- [Alarm Playback](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- [Alarm Audio](https://github.com/suman222222/doom_scrolling_detector/blob/main/assets/alarm.wav): `assets/alarm.wav`
- [Camera Window](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`

### Other components

- **User**
- [Gaze Monitor](https://github.com/suman222222/doom_scrolling_detector/blob/main/main.py): `main.py`
- **Webcam**

## Connections

- User → Gaze Monitor: starts (evidence: `README.md`)
- Webcam → Frame Capture: provides frames (evidence: `main.py`)
- Gaze Monitor → Frame Capture: opens stream (evidence: `main.py`)
- Frame Capture → Frame Preparation: passes frames (evidence: `main.py`)
- Frame Preparation → Face Landmarker: submits image (evidence: `main.py`)
- Landmarker Model → Face Landmarker: configures model (evidence: `main.py`)
- Face Landmarker → Iris Ratio: returns landmarks (evidence: `main.py`)
- Iris Ratio → Gaze State Machine: sets gaze flag (evidence: `main.py`)
- Gaze State Machine → Alarm Thread: starts or stops (evidence: `main.py`)
- Alarm Thread → Alarm Playback: runs playback (evidence: `main.py`)
- Alarm Playback → Alarm Audio: plays file (evidence: `main.py`)
- Frame Capture → Camera Window: shows annotated frame (evidence: `main.py`)
- Gaze State Machine → Camera Window: shows status (evidence: `main.py`)
- Camera Window → Gaze Monitor: q stops loop (evidence: `main.py`)
