Skip to content

PascuEric/dream-os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

DreamOS: Clinical Sleep Intelligence

DreamOS bridges the gap between your professional life and your biological needs. By analyzing your Google Calendar and sleep metrics, it identifies the root causes of insomnia and automatically schedules personalized Cognitive Behavioral Therapy for Insomnia (CBT-I) interventions directly into your daily schedule.

Zero Friction Architecture: Your calendar and sleep logs provide the data; DreamOS provides the clinical solutions.


System Architecture

DreamOS utilizes a multi-agent orchestration layer to transform raw data into actionable health interventions.

[ Data Input ]
Google Calendar (Workload, Meeting Density)
+ 
Sleep Logs (Efficiency, SOL, WASO, Duration)
        |
        v
[ LangGraph Agents ]
1. Sleep Analyst     -> Computes clinical metrics via Python
2. Cause Detector    -> Identifies insomnia phenotypes (via Groq LLM)
3. CBT-I Protocol    -> Generates targeted interventions (via Groq LLM)
4. Schedule Optimizer -> Synchronizes interventions with GCal (via Groq LLM)
        |
        v
[ Final Output ]
Google Calendar Updates (Breathing, Journaling, Wind-down, Stimulus Control)


Technical Stack

Layer Technology Role
Backend Python 3.11 + FastAPI Core API and Logic
Orchestration LangGraph Agentic Workflow Management
Intelligence Groq (Llama-3.3-70b-versatile) Inference and Decision Making
Frontend React 18 + Vite + Tailwind Dashboard and Visualizations
Data Viz Recharts Sleep Metric Analytics
Integration Google Calendar API v3 Bi-directional Schedule Sync

Installation and Setup

1. Backend Configuration

Navigate to the backend directory and set up the environment:

cd dreamos/backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

cp .env.example .env
# Edit .env: Add GROQ_API_KEY and GOOGLE_CREDENTIALS_PATH

Google Calendar Integration (Optional for Live Mode):

  1. Create a project in the Google Cloud Console.
  2. Enable the Google Calendar API.
  3. Download the credentials.json (OAuth 2.0 Desktop client).
  4. Update your .env: GOOGLE_CREDENTIALS_PATH=./credentials.json.

2. Frontend Configuration

Navigate to the frontend directory and install dependencies:

cd dreamos/frontend
npm install
npm run dev

The application will be available at http://localhost:5173.


API Documentation

GET /api/dashboard

Retrieves the main intelligence overview.

  • Parameters:

  • profile (ana | mihai | progress) - Default: ana

  • live (true | false) - Default: false

  • Response: DashboardResponse containing sleep scores, cause profiling, and the CBT-I protocol.

GET /api/calendar/analysis

Analyzes the user's workload and schedule density.

  • Response: Metrics on meeting frequency, free slots, and "fragmentation scores" that impact sleep.

POST /api/calendar/add-events

Writes the generated interventions to the user's calendar.

  • Body: JSON array of event objects (summary, description, start, end).
  • Note: Set ?live=true to write to a real Google Calendar; otherwise, it operates in mock mode.

Clinical Profiles (Demo)

Profile Primary Cause Sleep Score Context
Ana Hyperarousal 73 High workload (8+ meetings/day), zero breaks, SE=68%
Mihai Circadian Rhythm 62 Irregular schedule, late-night meetings, SE=72%
Progress Recovering 85 7-day positive trend, SE improved from 62% to 81%

CBT-I Interventions

DreamOS focuses on Active Interventions, not just passive tracking.

Intervention Mechanism Clinical Goal
4-7-8 Breathing Parasympathetic Activation Cortisol reduction before high-stress tasks
Light Exposure Circadian Reset Melatonin regulation through morning sunlight
Worry Journaling Cognitive Externalization Anti-rumination strategy for bedtime
Digital Sunset Blue Light Mitigation Protecting natural melatonin production
Sleep Restriction Homeostatic Pressure Consolidating sleep into a continuous block
Stimulus Control Classical Conditioning Re-associating the bed with sleep, not wakefulness

Quick Start

Run both services simultaneously to get started:

# Terminal 1: Backend
cd dreamos/backend && uvicorn main:app --reload --port 8000

# Terminal 2: Frontend
cd dreamos/frontend && npm run dev

The system is designed to work fully offline using mock data for demonstration purposes if no API keys are provided.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors