Jarvis watches how you actually use your devices β not how you think you use them β and turns that raw activity into a stress score, a wellness score, and a handful of nudges that tell you when to put the phone down. It tracks PC and Android usage in the background, runs the numbers through a trained ML model, and surfaces everything in a live dashboard with charts, alerts, and a small wellness chatbot.
No surveys. No manual logging. Just two background scripts, a Flask API, and a React dashboard that updates in near real time.
- Tracks screen time automatically on Windows (active window polling) and Android (via ADB) β no app installs required on the phone.
- Predicts a stress level (
Low/Medium/High) from behavioral features using a trained Decision Tree model. - Computes a 0β100 Wellness Score that blends stress, screen time, night usage, breaks, and productive-vs-distracting ratio.
- Generates smart alerts in real time β long unbroken sessions, late-night usage, heavy phone use, "distraction mode," and positive reinforcement when you're doing well.
- Sends phone push notifications directly via ADB when you've spent too long in a distracting app.
- Visualizes everything: 7-day history, an hourly activity heatmap, a stress scatter plot, and category breakdowns.
- Analyzes Digital Wellbeing screenshots with Gemini β drop in a screenshot, get a parsed breakdown of app usage and recommendations.
- Recommends therapy content (breathing exercises, mood-based Spotify playlists) based on your current stress level.
- Answers natural-language questions about your day ("how was my day", "should I take a break", "what should I fix tomorrow") through a lightweight rule-based chat endpoint.
βββββββββββββββββββ βββββββββββββββββββ
β tracker.py β β phone_tracker.py β
β (PC, Windows) β β (Android, ADB) β
ββββββββββ¬ββββββββββ ββββββββββ¬ββββββββββ
β writes every 5s β
ββββββββββββββββ¬βββββββββββββββββββ
βΌ
backend/api/activity_log.csv
β
βΌ
βββββββββββββββββββββββ
β Flask API (app.py) β
β feature extraction β
β + stress_model.pkl β
ββββββββββββ¬ββββββββββββ
β REST / JSON
βΌ
βββββββββββββββββββββββ
β React + TS frontend β
β (Dashboard, charts, β
β alerts, therapy) β
βββββββββββββββββββββββ
Data flow: the two tracker scripts append rows (timestamp, app, duration_seconds, source) to a shared CSV every 5 seconds. The Flask backend reads that CSV on each request, computes behavioral features (screen time, continuous usage, night usage, app switches, breaks, productive ratio), feeds them into a pre-trained scikit-learn model, and returns stress/wellness data as JSON. The frontend polls these endpoints and renders the dashboard.
| Layer | Technology |
|---|---|
| PC tracker | Python, pygetwindow, Win32 idle detection (ctypes) |
| Phone tracker | Python, Android Debug Bridge (ADB), dumpsys parsing |
| Backend API | Flask, Flask-CORS, pandas, scikit-learn, Pillow, google-generativeai |
| ML model | DecisionTreeClassifier (scikit-learn), trained on 6 behavioral features |
| Frontend | React 19, TypeScript, Vite, Tailwind CSS v4, Framer Motion, Recharts, React Router, lucide-react |
- Python 3.10+ (the project ships compiled artifacts for both 3.10 and 3.14, so most recent versions work)
- Node.js 18+ and npm
- Windows OS for
tracker.pyβ it uses the Win32 API (ctypes.windll) for idle detection and active-window polling. On other platforms idle detection silently no-ops. - An Android phone with ADB enabled (optional) β only needed for phone tracking. USB debugging must be turned on, and the device must be authorized.
- A Gemini API key (optional) β only needed for the screenshot-analysis feature.
β οΈ Note on phone tracking:phone_tracker.pywas built and tested against a specific device (Nothing Phone, Nothing OS 15 / Android 15) and parsesdumpsys window/dumpsys poweroutput specific to that OS build. It will likely need adjustment (notably themFocusedAppparsing logic and the hardcoded ADB path) for other Android skins or versions.
git clone https://github.com/Prithvi-Aithal/Jarvis.git
cd JarvisThe backend doesn't ship a requirements.txt, so install the packages it imports directly:
cd backend
pip install flask flask-cors pandas scikit-learn joblib numpy pillow google-generativeai python-dotenvIf you're on Windows and want PC tracking, also install:
pip install pygetwindowCreate a .env file inside backend/api/ if you want screenshot analysis to work:
GEMINI_API_KEY=your_gemini_api_key_herecd frontend
npm installOptionally, point the frontend at a non-default API URL by creating frontend/.env:
VITE_API_URL=http://localhost:5000- Install Android Platform Tools (ADB).
- Enable Developer Options β USB Debugging on your phone.
- Open
backend/api/phone_tracker.pyand update theADBconstant to point at your localadb.exe/adbbinary path. - Connect your phone via USB and run
adb devicesto confirm it's authorized.
You'll need up to four terminals, depending on which features you want active.
# Terminal 1 β Backend API (required)
cd backend/api
python app.py
# β runs on http://localhost:5000
# Terminal 2 β PC activity tracker (required for PC data)
cd backend/api
python tracker.py
# Terminal 3 β Phone activity tracker (optional)
cd backend/api
python phone_tracker.py
# Terminal 4 β Frontend dashboard
cd frontend
npm run dev
# β runs on http://localhost:5173 (default Vite port)Open the frontend URL in your browser. The dashboard will show "no data yet" until the trackers have written at least a few entries to activity_log.csv β give it a minute or two after starting tracker.py.
All endpoints are served from the Flask app at http://localhost:5000.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/status |
Health check β confirms the backend is running |
GET |
/api/stress |
Current stress level, wellness score, features, and a therapy recommendation |
GET |
/api/features |
Raw computed behavioral features for today |
GET |
/api/wellness |
Wellness score + formatted screen time summary |
GET |
/api/history |
Last 7 days of daily aggregated stats (for charts) |
GET |
/api/heatmap |
Hourly activity intensity grid over the last 7 days |
GET |
/api/alerts |
List of currently active wellness alerts/nudges |
POST |
/api/chat |
Natural-language Q&A about today's activity ({ "message": "..." }) |
POST |
/api/analyze-screenshot |
Upload a Digital Wellbeing screenshot (multipart/form-data, field name image) for Gemini-powered analysis |
Every activity entry feeds into six behavioral features, computed per day:
- Screen time β total minutes of tracked activity
- Continuous usage β longest unbroken streak (gaps > 5 min count as a break)
- Night usage β minutes of activity after 10 PM
- App switches β context-switching frequency, capped to filter noise
- Breaks β number of gaps longer than 5 minutes
- Productive ratio β share of time not spent in distracting apps (YouTube, Instagram, Netflix, Twitter, TikTok, Facebook, WhatsApp)
These six numbers are passed into a DecisionTreeClassifier (backend/ml/stress_model.pkl) trained on synthetic/labeled data in backend/ml/training_data.csv, which outputs Low, Medium, or High. The wellness score (0β100) is then derived from stress level plus screen time, night usage, productive ratio, and break frequency.
cd backend/ml
python train_model.pyThis reads training_data.csv, trains a fresh DecisionTreeClassifier (max depth 5), prints accuracy/cross-validation metrics, and overwrites stress_model.pkl.
Jarvis/
βββ backend/
β βββ api/
β β βββ app.py # Flask API β all routes
β β βββ tracker.py # PC activity tracker (Windows)
β β βββ phone_tracker.py # Android activity tracker (ADB)
β β βββ activity_log.csv # Shared activity log (auto-generated)
β βββ ml/
β βββ feature_extractor.py
β βββ predictor.py # Loads model, predicts stress level
β βββ train_model.py # Trains/retrains the classifier
β βββ stress_model.pkl # Trained model artifact
β βββ training_data.csv # Labeled training data
βββ frontend/
βββ src/
βββ pages/ # Dashboard, Analytics, Therapy, PhoneInsights, Insights, Settings
βββ components/
β βββ charts/ # Line chart, heatmap, scatter plot, category bar chart
β βββ dashboard/ # Wellness score, stress gauge, screen time, sleep risk cards
β βββ therapy/ # Breathing animation, mood playlist selector
β βββ notifications/ # Smart in-app notifications
βββ hooks/useJarvisData.ts
βββ api.ts # API client
| Route | Page | Purpose |
|---|---|---|
/ |
Dashboard | Wellness score, stress gauge, screen time card, sleep risk, smart notifications |
/analytics |
Analytics | 7-day trends, category breakdown, hourly heatmap |
/therapy |
Therapy | Breathing exercises and mood-based playlists |
/phone-insights |
Phone Insights | Phone-specific usage breakdown |
/insights |
Insights | Screenshot analysis (upload a Digital Wellbeing screenshot) |
/settings |
Settings | App configuration |
tracker.pyrelies on the Win32 API and only works on Windows.phone_tracker.pyhas device-specific parsing logic (built for Nothing OS 15) and a hardcoded local ADB path β update both for your own setup.- The activity log auto-trims to the last 7 days, so long-term historical trends aren't retained.
- The chat endpoint (
/api/chat) is keyword/rule-based, not an LLM β only the screenshot-analysis feature uses Gemini. - The training dataset is small; treat stress predictions as directional rather than clinically meaningful.
No license file is currently included in this repository. Add one (MIT, Apache-2.0, etc.) if you intend for others to reuse this code.
Built by Prithvi Aithal