A prayer-aware sleep schedule optimizer that calculates optimal sleep times based on Islamic prayer times (especially Fajr and Isha), with Google Calendar integration and Android widget support.
-
Prayer Times Integration
- Uses namozvaqti.uz for Uzbekistan locations
- Aladhan API (Hanafi method) for other locations
- Offline caching for reliability
- GPS-based location detection
-
Smart Sleep Optimization
- 30-minute buffer after Isha before sleep
- Wake time pivots around 4 AM for maximum productivity
- Flexible duration: 6-7.5 hours (targets 7 hours)
- Automatic daily recalculation as prayer times change
-
Google Calendar Integration
- Automatic sleep block creation
- Conflict detection with existing events
- Displays optimal sleep schedule
-
Android Widget
- Shows next sleep time
- Displays prayer times
- Shows sleep duration
- Time until sleep countdown
-
Creative Notifications
- 100 unique sleep reminder quotes
- Mix of supportive and playfully urgent (Duolingo-style)
- Teen-friendly content
Sleepy/
├── config/ # Configuration files
│ ├── settings.py # App settings
│ ├── credentials.json # Google OAuth credentials (not in repo)
│ └── token.json # Google OAuth token (not in repo)
├── src/
│ ├── api/ # FastAPI REST API
│ │ └── main.py # API endpoints
│ ├── models/ # Data models
│ │ ├── prayer_times.py
│ │ └── database.py
│ ├── services/ # Business logic
│ │ ├── prayer_times_service.py
│ │ ├── sleep_optimizer.py
│ │ ├── location_service.py
│ │ └── google_calendar_service.py
│ └── utils/ # Utilities
│ └── sleep_quotes.py
├── data/ # SQLite database
├── android/ # Android app (coming soon)
└── main.py # Application entry point
- Python 3.8+
- Virtual environment (venv)
- Google Cloud Platform account (for Calendar API)
-
Clone the repository
cd Sleepy -
Create and activate virtual environment
python -m venv venv # Windows venv\Scripts\activate # Linux/Mac source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Set up Google Calendar API
- Go to Google Cloud Console
- Create a new project
- Enable Google Calendar API
- Create OAuth 2.0 credentials (Desktop app)
- Download credentials.json
- Place it in
config/credentials.json
-
Run the application
python main.py
The API will start at
http://localhost:8000API documentation:http://localhost:8000/docs
GET /location/gps?latitude={lat}&longitude={lon}- Get location from GPSGET /location/city/{city_name}- Get location by city nameGET /location/last- Get last known location
POST /prayer-times- Get prayer times for location and date
POST /sleep-schedule- Calculate optimal sleep schedulePOST /sleep-schedule/full- Get complete schedule (location + prayers + optimization)GET /time-until-sleep- Get time remaining until sleep
GET /quotes/random- Random sleep quoteGET /quotes/supportive- Supportive quoteGET /quotes/urgent- Urgent quote
POST /calendar/authenticate- Authenticate with GooglePOST /calendar/create-sleep-block- Create sleep eventDELETE /calendar/event/{event_id}- Delete event
# Get full sleep schedule for Tashkent
curl -X POST "http://localhost:8000/sleep-schedule/full?latitude=41.2995&longitude=69.2401&create_calendar_event=true"{
"location": {
"city": "Tashkent",
"country": "Uzbekistan",
"latitude": 41.2995,
"longitude": 69.2401,
"timezone": "Asia/Tashkent",
"is_uzbekistan": true
},
"prayer_times": {
"date": "2025-01-15",
"fajr": "05:30",
"isha": "19:00",
...
},
"sleep_schedule": {
"date": "2025-01-15",
"sleep_start": "19:30",
"sleep_end": "04:00",
"duration_hours": 7.0,
"notes": "Wake early at 4:00 AM for maximum productivity before Fajr"
},
"time_until_sleep": "3 hours 15 minutes",
"notification_quote": "Your brain cells are begging for a reboot. Give them what they deserve!"
}Edit config/settings.py to customize:
DEFAULT_SLEEP_DURATION_HOURS: Target sleep duration (default: 7.0)OPTIMAL_WAKE_TIME_HOUR: Pivot wake time hour (default: 4)ISHA_BUFFER_MINUTES: Wait time after Isha (default: 30)PRAYER_TIMES_CACHE_DAYS: Cache duration (default: 30)
The Android app features a stunning UI with Studio Ghibli-inspired aesthetics:
- Studio Ghibli color palette: Warm, dreamy colors inspired by Ghibli films
- Canvas/painting texture: Subtle paper grain and watercolor-like backgrounds
- Solarized themes: Two eye-comfortable themes (Ghibli Meadow & Ghibli Twilight)
- Full-screen text layout: Twitter/X-style information density
- Organic elements: Hand-drawn dividers, soft shadows, painting-like vibes
- Native Kotlin with Jetpack Compose
- Home screen widget
- Sleep time notifications with 100 creative quotes
- Offline mode support
- GPS location detection
- Custom texture shaders for canvas feel
See ANDROID_GUIDE.md for full UI documentation and implementation details!
SQLite database stores:
- Cached prayer times (30-day rolling window)
- Last known GPS location
- Sleep schedule history
This is a personal project, but suggestions are welcome!
MIT License - see LICENSE file
- Prayer times from namozvaqti.uz
- International prayer times from Aladhan API
- Inspired by productivity principles of early risers like Demis Hassabis