✦vishal/VJ
← work/cognitive-monitoring
● shipped·2025·Full-stack engineer

Cognitive Monitoring System.

An ML platform that reads keystrokes, mouse drift, and idle patterns to predict stress in real time.

ReactNode.jsExpressPythonscikit-learnPostgreSQLTailwind
01
Problem.
$ cat problem.md

Most stress-detection tools need a wearable or a clinical setting. I wanted something that could read a developer or student's cognitive state from signals they already generate — typing rhythm, mouse micro-movements, idle windows — and surface it as a trend they can act on before burnout lands.

02
Approach.
$ ./build.sh
01

Built a lightweight event-collector that runs in the browser and timestamps keystrokes, mouse trajectories, scroll bursts, and idle gaps at ~30Hz.

02

Aggregated events into rolling features (flight time, dwell, jitter, idle ratio) and pushed them through a feature pipeline that normalises per-user baselines — so a fast typist isn't labelled 'stressed' just because they type fast.

03

Trained a gradient-boosted classifier on a labelled session dataset to predict a 0–100 stress score in 60s windows, with confidence bands the UI can display honestly.

04

Wrapped it in a React dashboard with trend lines, weekly heatmaps, and 'quiet hours' suggestions. Backend on Node + Express, persistence on PostgreSQL, model served as a small Python sidecar.

03
Architecture.
$ tree ./layers
layer_01
Capture
Browser event collector (~30Hz, ~2KB/min)
layer_02
Features
Rolling aggregates, per-user baseline normalisation
layer_03
Model
Gradient-boosted classifier, 60s windows
layer_04
API
Node + Express, score + confidence payload
layer_05
UI
React + Tailwind, trends + heatmap + nudges
layer_06
Storage
PostgreSQL (events), Redis (hot window)
04
Decisions.
$ git log --grep=why
commit_01 · Per-user baselines, not absolute thresholds

Per-user baselines, not absolute thresholds

Typing 120wpm calmly is not the same as typing 120wpm under pressure. We normalise each feature against a rolling 14-day baseline so the model reads change, not raw speed.

commit_02 · Confidence bands, not point estimates

Confidence bands, not point estimates

A stress score without uncertainty is dangerous — people anchor to it. We surface 80% confidence intervals and the UI visibly shrinks when confidence is low.

commit_03 · Browser capture, not OS-level hooks

Browser capture, not OS-level hooks

Anything that needs a native agent or accessibility permission kills adoption. Browser events get us 85% of the signal with zero install friction.

05
Reflections.
$ cat TODO.nice-to-have
↳ TODO_1

I'd add an opt-in 'focus mode' that doesn't just log — it actively mutes notifications when the stress trend crosses a threshold, and lets the user override with a reason.

↳ TODO_2

The model is biased toward my own session patterns. Real product would need a small labelled corpus from diverse users and a periodic recalibration loop.

// nav.next