Inspiration

The sleep deprivation epidemic among students has reached alarming proportions: 70% of college students get insufficient sleep (National Sleep Foundation), 50% report chronic daytime sleepiness (American College Health Association), and over 96% sleep less than 8 hours on weeknights (Sleep Medicine Reviews). Most critically, students sleeping 6 hours or less perform as poorly as those who haven't slept for 48 hours (Nature and Science of Sleep).

As a final-year engineering student, I’ve seen firsthand how common — and harmful — sleep deprivation is. Whether it's deadlines, late-night screen time, anxiety, or caffeine overload, my peers and I constantly struggle to get proper rest. Over time, this chips away at our focus, health, and even emotional well-being.

I created SleepWell as a way to make sleep recovery engaging, rewarding, and intelligent. Not just another tracker — but a game-inspired journey guided by mystical companions who help you grow into The Dreamy One.


What It Does

SleepWell is a gamified, AI-powered sleep wellness system that turns better sleep into a magical quest. Built entirely by a solo developer, it uses local AI to preserve privacy and ensure performance — no external servers needed.

Core Features:

  • Companion Quests: Four magical companions (Sage, Knight, Tracker, Healer), each offering unique sleep-related missions.
    • The Sage reflects and guides your inner journey
    • The Knight builds routine and discipline
    • The Tracker monitors patterns and progress
    • The Healer restores calm and focus
  • XP & Badges: Earn XP, level up, and get rewarded for healthy sleep habits.
  • Sleep Logging & Analysis: Record hours slept, caffeine intake, screen time, and dreams.
  • Emotion-Aware Sleep Insight:
    • Journal entries are analyzed for emotional tone using an AI model and converted into mood and positivity scores.
    • Webcam snapshots provide facial emotion feedback using an on-device classifier.
  • Sleep Score Prediction: A custom ML model combines behavioral and emotional data to estimate sleep quality.
  • Routine Advisor: Get daily tips from an AI model based on your habits like caffeine timing, screen use, and sleep routine.
  • Relaxation Tools: Calming sounds, breathing exercises, and a memory game to help you unwind.
  • Insight Dashboards: Sleep trends, mood charts, XP levels, and streak counters to reflect your growth.
    Includes an Emotion Distribution Pie Chart based on journal entries.

How I Built It

Tech Stack:

  • Frontend: React, Vite, Firebase Auth, MediaRecorder API
  • Backend: Flask, Firebase Admin SDK
  • Database: Firestore
  • Authentication: Firebase (Email/Password)
  • Push Notifications: Firebase Cloud Messaging (partial integration)
  • AI/ML Modules:
    • Emotion Analysis: Hugging Face emotion classifier on journal entries (converted to mood/polarity)
    • Facial Emotion Detection: OpenCV + DeepFace (snapshot-based)
    • Sleep Score Prediction: Custom logic combining habits and emotion/sentiment
    • Routine Tip Generation: LLM-based suggestion engine (initially API-based, now fully local)

Two GitHub branches:

  • main: Uses Hugging Face Inference API
  • local: Runs all models fully locally (made after inference quota expired)

Challenges We Ran Into

  • Hugging Face API Quota Exhaustion: My Inference API quota expired mid-development, forcing a quick switch to fully local model inference using the transformers library. This required re-architecting how tips were generated while keeping them fast and relevant.

  • Efficient Local AI Execution: Getting models like Transformers and DeepFace to run locally without overloading the system meant trimming memory usage and choosing lighter models, while still keeping the user experience smooth.

  • Real-Time Emotion Processing: Implementing facial emotion detection from webcam snapshots involved balancing usability, accuracy, and privacy. Images were processed in-session only and never stored.

  • UX Design for Motivation: It wasn’t enough to just show sleep data — I had to design a gamified experience that made users want to return. Quests, XP, and badges were tied directly to behavior and AI feedback.

  • Tip Feedback Loop: To improve the quality of routine suggestions, I implemented a feedback loop where users could mark tips as helpful. These “good” tips were stored along with their inputs and reused in future prompts to help the AI generate better advice over time.

  • Model Fallback Handling: Built-in logic ensures that if an AI model fails (e.g., due to missing input or overload), the app gracefully falls back to default tips or placeholder content without breaking the experience.

  • Solo Development While Unwell: Developing a full-stack AI-integrated wellness product solo — while ill — was a personal and technical challenge that required constant prioritization and adaptation.


Accomplishments That We're Proud Of

  • Successfully merged gamification and AI to create a motivational sleep improvement journey.
  • Built a full companion quest system with XP, badges, and streaks tied directly to healthy habits.
  • Designed an adaptive routine advisor that improves with feedback, powered entirely by on-device models.
  • Delivered mood-aware insights using journal entries and facial emotion detection, all computed locally.
  • Released a fully functional product with two branches: one using APIs and one fully local for offline use — balancing convenience and privacy.
  • Managed and shipped the entire product solo, under tight time limits and challenging circumstances.

What We Learned

  • How to design local-first AI features that adapt to resource limits and still feel responsive and useful.
  • The value of reinforcement-style prompting, where feedback loops help the AI get better at personalized tips.
  • How to align behavioral motivation with technical insights, turning predictions into quests, feedback, and progress.
  • Designing with fallbacks and edge cases in mind, to keep the experience stable no matter what fails.
  • The unique challenge of building something that’s not just functional, but emotionally helpful — a product that supports health, not just tracks it.

What's Next for SleepWell

  • Relaxation Mini-Games
    Add calming interactive games like rhythmic breathing, memory matching, or ambient scene builders to help users unwind before bed.

  • Smarter Companion Dialogues
    Introduce LLM-powered conversations — each companion responds uniquely:

    • The Sage reflects and listens
    • The Healer soothes with calm suggestions
    • The Knight encourages routines
    • The Tracker provides progress feedback
  • Offline-First PWA & Smart Reminders
    Transform SleepWell into a fully installable app with:

    • Offline support for local storage and model inference
    • Smart reminders based on past habits
    • Dark/night mode for comfort
  • Behavior-Aware Sleep Insights
    Track and highlight meaningful sleep patterns:

    • “You sleep better after workouts before 7 PM.”
    • “Late caffeine reduces your sleep score.”
  • Visual Growth for Companions
    Unlock evolving visual realms for each companion — forests grow, shrines glow, stars twinkle — as users complete quests and streaks.

  • Tip Feedback Loop Expansion
    Strengthen the tip engine by learning from feedback:

    • Store helpful tips
    • Refresh advice weekly
    • Let users save favorite tips in a “Dreambook”
  • Hybrid AI Mode Switching
    Automatically switch between local and API-based models depending on system capability — or let users choose between Offline, Cloud, or Auto.


Live Demo: https://effulgent-sundae-e24053.netlify.app
GitHub: https://github.com/KaranMishra3610/SleepWell

Built With

  • css3
  • custom-gamification-engine-(xp
  • deepface-(local)
  • emotion-based-sentiment-mapping
  • firebase-admin-sdk
  • firebase-authentication
  • firebase-cloud-messaging-(partial)
  • firebase-firestore
  • flask
  • html5
  • hugging-face-emotion-classifier-(distilroberta)
  • hugging-face-transformers-(api-in-main-branch
  • local-in-local-branch)
  • mediarecorder-api
  • netlify
  • opencv-(local)
  • optional)
  • python
  • quests
  • react
  • routine-tip-generator
  • sleep-score-prediction-model
  • vite
  • whisper-(local
Share this project:

Updates