Project Story — Lock In
🚀 About the Project
Lock In is a browser-native, privacy-first focus coach. It uses your webcam to detect micro-distractions and bad habits—like hair touching, eye/nose rubbing, nail biting, and phone pick-ups—and gives gentle, real-time nudges. You get a session timer, smart breaks, a dashboard of focus metrics—all on-device—plus an in-app coach powered by Gemini + ElevenLabs voice.
🌱 Inspiration
I was losing study time to tiny bad habits I barely noticed: fixing hair, rubbing eyes, checking my phone “for a second.” App blockers don’t address physical habits. I wanted a coach that:
- runs in the browser (no installs),
- respects privacy (no video leaves the device),
- provides real-time feedback that helps unlearn bad habits, not just track them.
🧨 Why These “Bad Habits” Matter
- Stress signal: Face/hand self-touching spikes under cognitive stress—these are measurable self-soothing behaviors.
- They’re frequent: Students touch their faces dozens of times per hour, especially around eyes and nose—prime pathways for irritation and germs.
- Eye health risk: Habitual eye rubbing is linked to corneal issues (e.g., keratoconus) when forceful or prolonged.
- Mental health link: Nail biting (onychophagia) is a recognized body-focused repetitive behavior (BFRB) with physical and psychosocial impacts.
- Real campus prevalence: College samples show meaningful rates of nail biting (e.g., ~29% men, 19% women).
Takeaway: These “small” actions are stress markers, hygiene/health risks, and attention drains—perfect targets for timely, on-device nudges.
🛠️ How I Built It
Stack
- Frontend: React + TypeScript, HTML5 Canvas overlays
- CV Models: MediaPipe-style face & hand landmarks (web-friendly)
- Habit Engine: Lightweight detector with latching + hysteresis to avoid flicker
- In-App Coach: Gemini chatbot with ElevenLabs TTS voiceover; minimal REST for session logs/aggregates
Data Flow
- Webcam →
getUserMedia - Face + hand landmark models at ~15–30 FPS
- Habit engine classifies: hair touch, nail biting, eye/nose rubbing, phone pick-up → updates focus state (FOCUSED / NOT_FOCUSED / PAUSED)
- Overlay UI draws banners, timers, and micro-nudges
- Metrics aggregate client-side; optional anonymized sync
💬 In-App Coach — Gemini Chatbot
To complement real-time nudges, Lock In includes a Gemini-powered study coach embedded in the app:
- Context-aware tips (no video leaves device): The chatbot receives only anonymized session context—e.g., current focus state, recent habit counts, streak length, and break timers. It never sees raw video or landmarks.
- Actionable guidance: Ask for “2-minute reset routines,” posture/eye-strain relief, or CBT-style reframes for urges like nail biting. The coach responds with micro-plans (30–120s) rather than essays.
- Gentle accountability: When repeated habits pop up (e.g., eye rubs), the coach suggests a short intervention (“blink-20s + moisture drops later”) and sets a lightweight intention for the next 10 minutes.
- Voice mode: Responses are spoken via ElevenLabs for hands-free study; users can switch between text-only and voice at any time.
- Boundaries & privacy: Prompts are stripped of PII; the model never receives or stores images. Users can disable context sharing or use the coach as a generic study chatbot.
Under the hood
- Prompt schema:
{focus_state, streak_minutes, habits_last_10m, next_break_in, goals_today}→ few-shot prompts that favor brief, stepwise plans. - Guardrails: Rate-limits, safe-completion checks, and a compact library of pre-vetted interventions for BFRB-adjacent habits.
- Offline-friendly: If network is unavailable, the coach gracefully falls back to on-device canned playbooks matched to session context.
🧠 What I Learned
- Latency budgeting (<33 ms/frame) to keep models smooth in the browser
- State machines with hysteresis + dwell time to suppress false positives
- Privacy-by-default: only counters/aggregates, never video
- Behavior-change UX: soft, timely nudges help break bad habits better than harsh pop-ups
🧩 Challenges & Fixes
- False positives (e.g., hands over head ≠ hair touch) → tuned spatial regions + temporal windows + dwell time
- Device variance → adaptive FPS + dynamic model loading
- Lighting/camera angle → confidence gating + quick calibration hints
- Nudge fatigue → rate-limited banners + Pause Coaching toggle
📈 Early Results
Pilot sessions show longer uninterrupted blocks; users report fewer bad-habit gestures and better awareness of when they drift.
🔮 What’s Next
- Personalized models via lightweight on-device fine-tuning
- More habits (slouching, fidgeting), richer streaks/achievements
- Exportable progress reports for students/coaches—with privacy intact
🔐 Privacy First
All inference runs locally. Only anonymized counters (focused seconds, habit counts) are optionally saved. No video is uploaded—by design.
ElevenLabs TTS is generated from text prompts only—no user audio or video is ever sent to ElevenLabs.

Log in or sign up for Devpost to join the conversation.