DEV Community

Cover image for I built an app so I stop crashing out at work
daniel
daniel

Posted on

I built an app so I stop crashing out at work

Presage SmartSpectra SDK Challenge Submission

This is a submission for the Presage Challenge

What I Built

I sit in front of my laptop for many hours every day. I never know when to get up or when to take a break. And I only notice I'm stressed or tired when it's already too late (hello back pain >_<).

So I built Ovra. It reads your heart rate through your camera to guess your mood. Then it changes your Spotify music to match, and tells you when to stretch or take a walk.

It's for anyone who works long hours at a laptop. Students, developers, designers, LITERALLY anyone who forgets their body exists until 2 AM :)

Demo

Tip: click the chapters in the video description to jump to each mood.

Real moods take minutes to show up. Want to try it out fast? Turn on the built-in Demo mode: a 10-minute tour that shows everything Ovra can do. That's what the video uses.

There are 3 ways to run Ovra:

Mode What it's for
Normal session The real thing. Best for 45+ minutes
Demo mode A 10-minute tour of every mood, music change and exercise
Simulator A dev tool that fakes every mood on demand (npm run dev:simulate)

Code

GitHub logo surrelsaga / ovra

a desktop app that reads your heart rate through camera to guess your mood, then plays Spotify music to match

Ovra icon

Ovra

Ovra reads your heart rate and breathing through your camera, then changes your Spotify music to fit how you feel. It also reminds you to stretch or take a walk when you've sat too long

Tech stack

  • Electron: runs Ovra as a desktop app on Mac and Windows
  • TypeScript + React: the app's code and screens
  • Vite (electron-vite): builds and runs the app while developing
  • Presage SmartSpectra SDK: reads heart rate, breathing and face from the camera
  • Spotify desktop app: plays your music; Ovra controls it (AppleScript on Mac, PowerShell on Windows)
  • Last.fm: song tags, to know if a song is calm or upbeat
  • OpenRouter: AI guess of a song's mood when Last.fm isn't enough
  • Vitest: tests
  • electron-builder: makes the .dmg and .exe files

Get Ovra

Recommended: download the app

The downloaded app has everything set up, no keys needed…

  • Download: .dmg (Mac) and .exe (Windows) on Releases
  • Or run it yourself: clone, add your keys to .env, then npm run dev. Setup is in the README.

How It Responds to Human Signals

The signals

Signal What it does in Ovra
Heart rate The main one. It decides the mood
HRV (time between beats) Backup. Can confirm or cancel Stressed
Breathing Can only make Ovra more sure of Stressed. Never decides
Face (smiling, looking upset, blinking, head tilt) Only if you say yes. Supports a mood, never makes one alone. Also checks you really did the neck stretch
Status codes Tell Ovra if you're there, away, moving, or if someone else is in view

The rules

First, Ovra reads your heart rate for 30 seconds while you sit normally. That's your baseline: what's normal for you right now. Every rule below compares your heart rate with it.

Example: baseline 70 bpm → Stressed from about 81 bpm, Tired at about 64 bpm or lower.

Mood Rule (compared with your baseline) Music Exercise
Steady Heart rate within 8% of it Your usual mix for what you're doing —
Good mood Steady + smiling most of the time Upbeat songs to keep it going —
Stressed 15% or more above it (10% if HRV agrees), for 3 min Calmer songs Breathe along
Very stressed Stressed for 10 min, or 20% above it with an upset face Fades down to a calm song A short walk
Tired 8% or more below it, for 2 min Energetic songs to wake you up Stand and stretch
Away No face for 20 s Pauses —

The whole loop:

camera → Presage SDK → every 30 s, look at the last minute
       → compare with your baseline → mood must hold for a few minutes
       → change the moon, the music, maybe suggest an exercise
Enter fullscreen mode Exit fullscreen mode

=> One weird reading never changes anything. A mood has to hold first.

How I use the SmartSpectra SDK

  • Setup. Face metrics are only requested if you said yes to face reading:
  const sdk = new SmartSpectraSDK({
    apiKey,
    requestedMetrics: [...breathingMetrics, ...cardioMetrics, ...(face ? faceMetrics : [])],
    enableTelemetry: false // the SDK's default is true
  })
Enter fullscreen mode Exit fullscreen mode
  • My camera, not the default one. I open the camera myself and hand it over with sdk.useMediaStream(stream). That's how you can pick which camera in Settings (my friend's laptop kept picking his phone camera 😅).
  • The shrunk picture. The camera is drawn at 80% size inside a 1280×720 frame. That gets past the SDK's "chest not visible" check (code 7) when you slouch. Good signal went from 7–27% of the time to ~75%.
  • Status codes → plain words. Ovra listens to validationStatus and says what's going on:
    • code 2 (only one face allowed) → "Another face in view · no change"
    • code 12 (too much motion) → "Couldn't see you clearly · no change"
    • code 1 (no face) for 20 s → Away, music pauses
  • When the SDK dies. I listen for error and processingStatus === kError. Ovra restarts the SDK up to 3 times and says "Camera reconnecting", instead of thinking you left.
  • Frozen camera. I use the SDK's own frame timestamps, not the time a reading arrives. A frozen picture can't fake you being there.
  • Camera off between checks. By default the camera looks for about 90 s every 5 minutes, then fully turns off.

You can't fake a mood

I tried. A test clip with a fake angry face changed nothing, because the heart rate didn't go up. The face only supports what your heart says.

In my own 45-minute session: no false Stressed, no false Away. Standing up to stretch came close to "away" (about 13 s without a face) but stayed present.

Bugs that taught me things
  • The slouch. When my chest left the frame, the SDK said code 7 and gave no pulse at all. Calibration kept failing. => Shrunk picture (above). Calibration then passed in 83 s.
  • The VPN. Behind my VPN, Presage's usage check failed and the SDK went into a dead state, refusing every frame. Ovra thought I was away. => Watch for it, restart it, and say "Couldn't reach Presage. Check your internet or VPN" if it keeps failing.
  • A second face. Even a few frames with another face (code 2) made the pulse go quiet for 10–60 s. It doesn't read the wrong person, it just stops. => Ovra now names the cause instead of a vague "couldn't see you".
  • Spotify lied (a little). Right after a skip, Spotify still reports the old song for a moment. Ovra judged that old song again and skipped ~7 good songs in 25 s. => Wait for a new song id after every skip.
  • The packaged app couldn't find the SDK. In the built app, the SDK looked for its native library inside app.asar, which can't load native files. => Point the SDK to the unpacked copy before importing it.

Full rules (for the curious)
  • "Almost counts": a check within 3% of the Stressed or Tired bar pauses the countdown instead of resetting it.
  • Your baseline keeps learning for 10 minutes, but only from calm checks. Stress can't become "normal".
  • Tired uses the lower of your first baseline and the adjusted one, so a normal heart rate later doesn't look tired.
  • A check counts only with 10+ seconds of steady heart rate. Otherwise: "Couldn't see you clearly · no change".
  • After 3 min of unclear checks, Stressed or Tired is forgotten and has to build up again.
  • Breathing is ignored with the shrunk picture, because the chest isn't really in view.

The science behind the vibes

I didn't want Ovra to guess on vibes alone, so I read up first. Here's what I found, and what it changed.

What the research says Source So Ovra…
Mental stress raises heart rate (a Stroop task: about +20 bpm) Crossover study uses heart rate as the main signal. Stressed = 15%+ above your baseline
HRV drops under acute mental stress (12 studies, 758 adults) Castaldo et al. 2015 uses HRV to confirm or cancel Stressed
Webcam heart rate is off by about 2–3 bpm, worse when you move Webcam vs ECG study waits minutes before naming a mood, and pauses when you move
About 6 breaths a minute raises HRV the most (84 people) PubMed 2024 the breathing moon grows and shrinks at 6 breaths a minute
Hold a stretch 10–30 seconds ACSM 2021 each stretch step lasts 10–35 s
Short breaks (10 min or less) boost energy and lower fatigue (2,335 people) Albulescu et al. 2022 suggests short breaks: a 5-min walk, or 10 min outside

Break timing and music

Sitting reminders (counted from when you sat down, reset when you leave for a minute or more):

Reminder Focus / Reading Creative / Everyday / Unwind
Neck and shoulder stretch 30 min 25 min
Stand and stretch 60 min 50 min
Walk and get water 90 min 75 min

=> At most one suggestion every 20 minutes, so it never piles up.

Music: the direction changes at most once every 3 minutes. For variety, Ovra switches playlist after 12 songs in Focus/Reading, or 7 in the other activities.


Prize Categories

Most Creative or Delightful Use: your heartbeat picks the music, and a little pixel moon breathes with you when you need to calm down.

Best Thoughtful Real-World Use: for anyone stuck at a desk for hours, Ovra notices stress and tiredness early and gets you moving, with no poses to hold.

Consent and Data Handling

Ovra asks first. The questions come one at a time, with no "accept all":

Consent screen

Question Default
Can Ovra use your camera during sessions you start? You must answer
Every few minutes, or the whole session? Every few minutes
Read your face too, or heart rate and breathing only? You must pick
Look up songs on Last.fm and use AI to sort them? No
Share anonymous diagnostics with Presage? Don't share
Auto-delete old session history? 30 days

Say "Not now" to the camera and Ovra still works: timer, music and break reminders.

The camera only runs in sessions you start. A ring around the moon shows whenever it's on. Ovra never asks for the microphone.

What's stored, and what's not:

Stored (on your computer) Never stored
Mood labels with times ("Steady at 10:05") Video, frames or images
Moves done or skipped, session length Heart rate, breathing, HRV
Songs played and how they suit you Face data or expressions
Playlist links, settings, privacy answers, which camera you picked Your baseline (it's dropped when the session ends)

Everything sits in one folder that only your user account can read: ~/Library/Application Support/Ovra/ on Mac, %APPDATA%\Ovra\ on Windows. The code refuses to save a file that contains a raw reading.

Ovra privacy settings Ovra session history and delete options
Ovra privacy settings Ovra session history and delete options

What leaves your computer:

  • Presage: your API key check and a usage count, each time the camera starts. Video is processed on your computer.
  • Last.fm and OpenRouter (only if you say yes): song titles, artists and public tags. Never your readings or moods.
  • Telemetry: off unless you choose "Share".

Deleting: history auto-deletes after 30 days. You can also delete one session, clear the music library, or press Delete everything.

Ovra never saves or uploads your video. It's a wellness app, not a medical device.

Not perfect (yet), and how I'd fix it

  • Spotify pops up for a second when Ovra switches playlist. The desktop app only lets other apps skip songs, not pick one quietly. => Connecting to Spotify's Web API would let Ovra pick songs directly, with no pop-up.
  • Accuracy needs long sessions. Demo mode is a tour, not a test. => Test with more people over full work days, then tune the numbers.
  • The Mac app isn't signed by Apple, so the first launch needs one Terminal command. => An Apple developer account fixes that.
  • Breathing is mostly unused, because the shrunk picture hides the chest. => Better framing could bring it back.
  • The download carries shared API keys that someone could dig out of the app. OpenRouter is capped at 50 requests a day, so the risk is small. => A small server that holds the keys.

That's Ovra. Try it, take a break, and let your music chill you out

If you like it, a ⭐ on GitHub really help!

Top comments (2)

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

the 'one weird reading never changes anything' rule is the part i respect. a mood has to hold before it counts.

Collapse
 
daniel_ng profile image
daniel •

haha, thanks 😊