Skip to content

Mo7medRef3t/Slumber

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ™ Slumber – Smart Sleep Tracker

A professional Flutter mobile application designed to help users improve their sleep quality through intelligent tracking, personalized insights, ambient sleep sounds, and smart reminders.

Built with Clean Architecture, Firebase, and Bloc (Cubit) state management.


πŸ“Έ Screenshots


✨ Features

πŸ›οΈ Sleep Tracking

  • Start/Stop sleep tracking with a live timer
  • Persistent tracking – survives app termination using local storage
  • Ongoing notification while tracking is active
  • Active session banner on dashboard with live elapsed time
  • Automatic session recovery on app relaunch

πŸ“Š Smart Analytics & Insights

  • Sleep Score Algorithm based on duration + consistency + bedtime
  • Weekly sleep trends with interactive charts (FL Charts)
  • Average sleep duration with goal comparison
  • Sleep debt detection and tracking
  • Best sleep day identification
  • Average bedtime & wake-up time statistics

🎡 Sleep Sounds (Relax Module)

  • 12 ambient sounds (Rain, Ocean, Forest, Fireplace, White Noise, etc.)
  • Auto-loop playback
  • Sleep timer (15/30/60 min auto-stop)
  • Integrated within Sleep Tracking screen via Bottom Sheet
  • Sound automatically stops when sleep tracking ends

πŸ”” Smart Notifications

  • Bedtime reminders using Android AlarmManager (works even when app is killed)
  • Persistent sleep tracking notification
  • Notification tap navigates to active tracking session
  • Reminders automatically reschedule daily

πŸ† Achievements System

  • 6 achievement types (First Sleep, 7-Day Streak, Perfect Sleeper, etc.)
  • Real-time progress tracking
  • Animated unlock dialog
  • Reactive calculation based on sleep history

πŸ‘€ Profile & Settings

  • Edit profile (Name, Age, Sleep Goal)
  • Theme switching (Light / Dark / System) with persistence
  • Bedtime reminder configuration
  • Account management (Sign Out / Delete Account)
  • App info (Version, Privacy Policy, Contact)

πŸ” Authentication

  • Email & Password (Sign Up / Sign In)
  • Google Sign-In
  • Firebase Authentication
  • Auto-login on app restart

πŸ—οΈ Architecture

Clean Architecture + Feature-Based Structure
lib/
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ notifications/        # AlarmManager + Local Notifications
β”‚   β”œβ”€β”€ services/             # Sleep Session persistence
β”‚   β”œβ”€β”€ theme/                # Theme Cubit + Service
β”‚   β”œβ”€β”€ user/                 # User Cubit (Global)
β”‚   β”œβ”€β”€ utils/                # Router, Theme, Colors, Assets
β”‚   β”œβ”€β”€ widgets/              # Shared widgets
β”‚   └── firestore_service.dart
β”‚
β”œβ”€β”€ features/
β”‚   β”œβ”€β”€ auth/                 # Sign In / Sign Up / Auth Service
β”‚   β”œβ”€β”€ home/                 # Dashboard + widgets
β”‚   β”œβ”€β”€ sleep_tracking/       # Tracking View + Sound Sheet
β”‚   β”œβ”€β”€ sleep/                # Insights + History + Score Calculator
β”‚   β”œβ”€β”€ relax/                # Sound Cubit + Models
β”‚   β”œβ”€β”€ achievements/         # Rules + Cubit + UI
β”‚   β”œβ”€β”€ profile/              # Profile + Edit + Settings
β”‚   β”œβ”€β”€ onbording/            # Onboarding screens
β”‚   └── splash/               # Splash screen
β”‚
β”œβ”€β”€ screens.dart              # Main navigation shell
└── main.dart                 # App entry point

πŸ› οΈ Tech Stack

Technology Usage
Flutter Cross-platform UI framework
Firebase Auth Authentication (Email + Google)
Cloud Firestore Real-time database
Bloc / Cubit State management
GoRouter Declarative navigation
FL Charts Data visualization
AudioPlayers Ambient sound playback
Android AlarmManager Scheduled notifications (survives app kill)
Flutter Local Notifications Push notifications
SharedPreferences Local persistence
ScreenUtil Responsive design
Google Fonts Typography
Package Info Plus App version info

πŸš€ Getting Started

Prerequisites

  • Flutter SDK (3.7.2+)
  • Firebase project configured
  • Android Studio / VS Code

Installation

# Clone the repository
git clone https://github.com/YOUR_USERNAME/slumber.git

# Navigate to project
cd slumber

# Install dependencies
flutter pub get

# Run the app
flutter run

Firebase Setup

  1. Create a Firebase project at console.firebase.google.com
  2. Enable Authentication (Email/Password + Google)
  3. Enable Cloud Firestore
  4. Download google-services.json (Android) and GoogleService-Info.plist (iOS)
  5. Place them in the appropriate directories

πŸ“± Firestore Structure

users/{uid}
β”œβ”€β”€ id
β”œβ”€β”€ name
β”œβ”€β”€ email
β”œβ”€β”€ age
β”œβ”€β”€ sleepGoalHours
└── bedtime

users/{uid}/sleepHistory/{docId}
β”œβ”€β”€ startTime
β”œβ”€β”€ endTime
└── duration

🎯 Key Technical Highlights

  • Persistent Sleep Tracking: Sessions survive app termination using SharedPreferences
  • AlarmManager Integration: Bedtime reminders fire even when the app is completely killed
  • Reactive Achievements: Auto-calculated based on real-time sleep data streams
  • Sleep Score Algorithm: Multi-factor scoring (duration + consistency + bedtime timing)
  • Audio Loop Management: Seamless ambient sound playback with auto-stop timer
  • Live UI Updates: Active session banner updates every second across screens
  • Theme Persistence: User theme preference saved and restored on app launch

πŸ§ͺ Comprehensive Unit Testing

To ensure the highest level of reliability and accuracy, the core business logic is heavily tested:

  • Algorithms Tested: SleepScoreCalculator, AchievementsRules, and SleepSessionService.
  • Test Coverage: Validates edge cases like day-overlapping sleep sessions, accurate sleep debt calculations, and precise achievement progress tracking.
  • Status: 42/42 Tests Passing βœ….

πŸ“„ License

This project is for portfolio/educational purposes.


Built with ❀️ using Flutter

About

πŸŒ™ A smart sleep tracking Flutter app built with Clean Architecture & Bloc. Features persistent background tracking (AlarmManager), custom Sleep Score analytics, ambient sounds, and a reactive achievements system via Firebase.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors