Skip to content

commit111/cmdf-2026

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icarus (cmd-f 2026)

Authors: Jenny L., Linda L., Shereen L., Marian C.

About

Icarus is a Chrome extension that uses computer vision to detect early signs of eye fatigue in real time — monitoring blink rate, squinting, eye rubbing, and screen distance — and intervenes the moment strain appears.


Project Structure

cmdf-2026/
├── extension/       Chrome extension (MediaPipe detection, popup UI)
├── backend/         Next.js API server (MongoDB, Gemini AI insights)
├── dashboard/       Local prototype dashboard (HTML/JS, Chart.js)
└── PRD.md           Product requirements for the Lovable frontend

Prerequisites

  • Node.js 18+
  • A Chromium-based browser (Chrome, Edge, Arc)
  • MongoDB Atlas account (connection string)
  • Google Gemini API key
  • ngrok account + authtoken (only needed for Lovable/external access)

1. Backend API

The backend is a Next.js app that exposes REST endpoints and stores session data in MongoDB.

First-time setup

cd backend
npm install

Create backend/.env.local:

MONGODB_URI="mongodb+srv://<user>:<pass>@<cluster>.mongodb.net/?appName=icarus"
GEMINI_API_KEY="your-gemini-api-key"
NGROK_AUTHTOKEN="your-ngrok-authtoken"   # only needed for dev:ngrok

Local development (no ngrok)

cd backend
npm run dev
# API available at http://localhost:3000

With ngrok tunnel (for Lovable frontend)

cd backend
npm run dev:ngrok
# Starts Next.js on port 3000 + opens a public ngrok tunnel
# Prints the tunnel URL — copy it into Lovable's VITE_API_BASE env var

If port 3000 is already in use, kill the occupying process first:

netstat -ano | findstr :3000
taskkill /PID <PID> /F

API endpoints

Method Path Description
POST /api/sessions Start a new session
GET /api/sessions List recent sessions
PATCH /api/sessions/:id Append a sample / close session
GET /api/insights AI-generated insights (cached 6h)

2. Chrome Extension

The extension captures webcam frames, runs MediaPipe FaceLandmarker, and posts strain samples to the backend every 10 seconds.

Loading the extension

  1. Open Chrome and go to chrome://extensions
  2. Enable Developer mode (top-right toggle)
  3. Click Load unpacked
  4. Select the extension/ folder

Updating after code changes

Click the refresh icon on the extension card at chrome://extensions, then reload any page where the popup is open.

What it tracks (per session)

Signal Description
strainScore 0–100 composite eye strain score
blinkCount Blinks per minute
squint Eye narrowing (0–100%)
faceWidth Screen distance proxy (0–1); >0.18 = too close (~<45 cm)

The extension posts samples to http://localhost:3000 by default. This is hardcoded in extension/scripts/session.js (API_BASE).


3. Local Dashboard (prototype)

A standalone HTML dashboard for quick local inspection. No build step required.

# Just open the file directly in your browser:
open dashboard/index.html
# or on Windows:
start dashboard/index.html

The dashboard reads from http://localhost:3000 by default. Click the button to switch the API base URL to a ngrok tunnel.


4. Lovable Frontend (production)

The production web dashboard is built and hosted on Lovable.

Connecting it to your local backend

  1. Start the backend with npm run dev:ngrok
  2. Copy the ngrok URL from the terminal output
  3. In your Lovable project settings → Environment Variables, set:
    VITE_API_BASE=https://xxxx.ngrok-free.app
    
  4. Redeploy/rebuild the Lovable project

All fetch calls in the Lovable frontend must include the header: ngrok-skip-browser-warning: true


5. Typical dev workflow

Terminal 1                   Browser tab 1        Browser tab 2
──────────────────────────   ──────────────────   ──────────────────
cd backend                   chrome://extensions  Lovable preview URL
npm run dev:ngrok             Load unpacked →
                              extension/
                              [copy ngrok URL]
                              → paste into Lovable
                              VITE_API_BASE

All three run simultaneously. The extension posts to the backend; the Lovable dashboard reads from it.


Environment files summary

File Purpose In .gitignore?
backend/.env.local MongoDB URI, Gemini key, ngrok token Yes
backend/.ngrok-url Auto-written ngrok URL on each startup Yes

About

Icarus is a Chrome extension to detect and prevent eye strain, featuring voice-based eye exercises and an insight dashboard.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors