How thelost-beep/focous-gouard works
Project type & purpose (from README + tree)
FocusGuard is a single-user, local-only distraction detection app with two delivery modes:
Web version (static site + browser AI/WebGL)
• Files: index.html, style.css, app.js, *.mp3
• Hosted via Vercel (vercel.json) and also on GitHub Pages (per README).
• Uses the webcam in-browser and runs detection locally.
Python desktop version (native runtime)
• Files: focusguard.py, requirements.txt
• Likely uses OpenCV / ML libs for face/eye/pose detection, triggers alarms locally.
Web runtime
• index.html: UI shell (start/stop, status text, video canvas elements)
• style.css: UI styling
• app.js: core logic (camera access, ML inference loop, distraction rules, audio playback, UI updates)
• abey-uth-jaa-saale.mp3, uth-jaa-no-censor.mp3: alert audio assets (local)
• vercel.json: hosting/deployment config for static delivery
Python runtime
• focusguard.py: camera capture loop, inference, rules, alerting, window display, key handling
What the README adds (architecturally important)
• All processing is local (privacy): no backend, no database, no telemetry.
• Triggers: “looking down too long” (phone trap) and “eyes closing” (sleep alert), threshold “> 2 seconds”
• Controls: Web STOP button; Python q key.
• Reliability differences: web depends on Browser/WebGL; Python is more “locked-in”.
These statements guide what you emphasize: edge inference loop + device APIs, and differences between the two deployments.
UI Layer (DOM/Canvas)
• status display (“FOCUSED” / distracted)
• Start/Stop controls
Camera Capture Module
• getUserMedia video stream
• frame extraction (canvas/video frame)
Distraction Logic / State Machine
• timers (e.g., >2 seconds)
• rules: “head down” / “eyes closed”
• debounce / “only alerts when really lost focus”
Alerting Module
• audio playback (mp3 assets)
• possibly looping / cooldown
Static Assets
• mp3 files
• css/html/js
Hosting/CDN (Vercel / GitHub Pages)
• serves static files only
Hosting → Browser (HTML/CSS/JS/MP3)
Webcam → Camera Capture → Inference Engine → Distraction Logic → Alerting → Speakers
Distraction Logic → UI Layer (status updates)
CLI/App Runner
• starts loop, handles exit (q)
Distraction Logic / State Machine
• same two rules + 2s thresholds
Alerting Module
• play sound (could be OS audio lib)
Display/Preview Window (optional)
• if it renders camera feed/status
Dependencies
Webcam → Video Capture → Inference Engine → Distraction Logic → Alerting → Speakers
Distraction Logic → Display/CLI (status)
Keyboard (q) → App Runner (stop)
Level 2 “Algorithm pipeline” inset (shared conceptual pipeline)
• Frame acquisition
• Landmark/feature extraction (eyes/head pose)
• Temporal smoothing / rolling window
• Rule evaluation (down gaze duration, eye closure duration)
• Alert trigger + cooldown
This clarifies “smart tracking” and the 2-second logic.
Architectural patterns/principles to call out (specific to this repo)
• Edge AI / on-device inference (privacy-preserving, no backend)
• Event loop + state machine (real-time stream processing)
• Separation of concerns even in small code:
• Vs inference vs decision vs presentation vs alerting
• Two deployment targets with analogous pipelines:
• Browser (WebGL/Web APIs) vs Python (native CV stack)
What
To be maximally clear:
Labels
• Use concrete labels tied to the repo:
• “app.js (camera + inference loop + rules)”
• “focusguard.py (capture + inference + rules)”
• “mp3 alert assets”
• “Vercel static hosting (vercel.json)”
• “Python deps (requirements.txt)”
Python container: internal module flow
(+ small shared pipeline inset)
That will be the most accurate representation of FocusGuard’s actual architecture and its two execution modes.