Skip to content

ohuc/CaffeineHealth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Caffeine Health logo

Caffeine Health

Track your caffeine. Protect your sleep.

Platform Min SDK Kotlin Compose License


Caffeine Health is a beautifully designed Android app that helps you understand how your caffeine intake affects your body throughout the day β€” and whether that late-afternoon espresso might cost you sleep tonight.

Log drinks from a curated catalog, watch your active caffeine level in real time on a 24-hour curve, and get a personalized sleep forecast based on your unique metabolism.

πŸ“± Screenshots

Set your baseline
Onboarding
Profile Ready
Profile Ready
Home Dashboard
Dashboard
Caffeine by Source
Source Analytics

✨ Features

🏠 Dashboard

  • Live caffeine curve β€” a smooth 24-hour chart showing your active caffeine level, updated in real time
  • Emoji markers β€” each logged drink appears on the chart with its emoji for quick visual reference
  • Sleep forecast β€” see how much caffeine will still be active at your bedtime and whether it crosses your safe threshold
  • Today's total β€” at-a-glance milligram count for everything consumed today
  • Drink detail sheet β€” tap any logged drink to see its contribution curve, peak level, current level, and total impact over time
  • Quick actions β€” edit, duplicate, or delete entries directly from the detail sheet

β˜• Drink Catalog

  • Curated drink database β€” browse drinks across categories like coffee, tea, energy drinks, soda, and more
  • Search & filter β€” Material 3 search bar with expressive category filter chips
  • One-tap logging β€” log a drink with a single tap and get snackbar confirmation
  • Custom serving sizes β€” adjust caffeine amount and timing before logging

🧬 Personalized Onboarding

  • Guided profiling flow β€” set your age range, weight, bedtime, sleep sensitivity, lifestyle factors, and relevant medications
  • Pharmacokinetic modeling β€” the app calculates a personalized caffeine half-life based on real-world factors (smoking, alcohol, CYP1A2 inhibitors)
  • Science-backed sources β€” every lifestyle adjustment links to its pharmacological source
  • Skip-friendly β€” sensible defaults if you prefer to get started immediately

βš™οΈ Settings

  • Half-life tuning β€” fine-tune your caffeine metabolism rate
  • Bedtime configuration β€” set your typical sleep time for accurate forecasts
  • Sleep threshold β€” define the milligram level you consider safe before bed
  • Appearance β€” theme and display preferences
  • Date & time format β€” 12-hour / 24-hour clock, date format customization

πŸ—οΈ Architecture

com.uc.caffeine
β”œβ”€β”€ MainActivity.kt          # Root scaffold, bottom nav, Navigation 3
β”œβ”€β”€ MainNavigation.kt        # Navigation destinations
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ model/               # Room entities (DrinkPreset, ConsumptionEntry, DrinkUnit)
β”‚   β”œβ”€β”€ dao/                 # Room DAOs
β”‚   β”œβ”€β”€ CaffeineDatabase.kt  # Room database with JSON preset seeding
β”‚   β”œβ”€β”€ SettingsRepository.kt # DataStore-backed user preferences
β”‚   └── UserSettings.kt      # Settings data class
β”œβ”€β”€ ui/
β”‚   β”œβ”€β”€ screens/
β”‚   β”‚   β”œβ”€β”€ HomeScreen.kt     # Dashboard with chart, sleep forecast, log
β”‚   β”‚   β”œβ”€β”€ AddScreen.kt      # Drink catalog with search & filter
β”‚   β”‚   └── settings/         # Settings sub-screens (appearance, profile, etc.)
β”‚   β”œβ”€β”€ components/           # Reusable UI: chart, scaffold, haptics, shimmer
β”‚   β”œβ”€β”€ onboarding/           # Multi-step profiling flow
β”‚   β”œβ”€β”€ theme/                # Material 3 color scheme, Montserrat typography
β”‚   └── viewmodel/            # Shared CaffeineViewModel (MVVM)
└── util/
    β”œβ”€β”€ CaffeineCalculator.kt # One-compartment pharmacokinetic model
    β”œβ”€β”€ ChartDataGenerator.kt # 24-hour curve + contribution chart data
    └── CategoryUtils.kt     # Drink category helpers & icons

The app follows a single-activity MVVM pattern:

Layer Responsibility
View Jetpack Compose screens + reusable components
ViewModel CaffeineViewModel β€” shared state, actions, caffeine math orchestration
Data Room database for drinks & entries, DataStore for user settings
Util Pure calculation logic (pharmacokinetics, chart data generation)

πŸ§ͺ Tech Stack

Component Technology
Language Kotlin
UI Framework Jetpack Compose
Design System Material 3 with Expressive motion
Navigation Navigation 3
Local Database Room
Preferences DataStore
Charts Vico (Compose + M3 theming)
Image Loading Coil 3
Typography Montserrat (Google Fonts)
Min SDK 31 (Android 12)
Target SDK 36

πŸ”¬ Caffeine Science

The app uses a one-compartment oral pharmacokinetic model:

  • Absorption phase β€” linear ramp from ingestion to peak based on drink-specific absorption rate
  • Elimination phase β€” exponential decay governed by your personal half-life setting
  • Half-life personalization β€” computed from age, weight, smoking, alcohol, liver health, and CYP1A2-inhibiting medications during onboarding

This keeps the curve and sleep forecast grounded in real pharmacology while remaining practical for daily use.


πŸš€ Getting Started

Prerequisites

  • Android Studio Ladybug (2024.3) or newer
  • JDK 11+
  • Android SDK 36 installed via SDK Manager

Build & Run

# Clone the repository
git clone https://github.com/ohuc/CaffeineHealth.git
cd CaffeineHealth

# Open in Android Studio and sync Gradle, or build from CLI:
./gradlew assembleDebug

# Install on a connected device / emulator:
./gradlew installDebug

Note: The app requires Android 12 (API 31) or higher. compileSdk targets API 36 β€” use an emulator with API 31+ to run it.

Project Structure

CaffeineHealth/
β”œβ”€β”€ app/                    # Main application module
β”‚   β”œβ”€β”€ src/main/
β”‚   β”‚   β”œβ”€β”€ assets/         # Drink preset JSON database
β”‚   β”‚   β”œβ”€β”€ java/           # Kotlin source code
β”‚   β”‚   └── res/            # Resources (drawables, fonts, values)
β”‚   └── build.gradle.kts    # App-level dependencies
β”œβ”€β”€ build.gradle.kts        # Project-level config
β”œβ”€β”€ settings.gradle.kts     # Module includes
└── gradle/                 # Gradle wrapper & version catalog

🎨 Design

Caffeine Health is built with Material 3 Expressive principles:

  • Dynamic Color β€” adapts to your device wallpaper on Android 12+ with a curated espresso-toned fallback palette
  • Expressive Motion β€” MotionScheme.expressive() for fluid, personality-rich transitions
  • Montserrat typography β€” clean, modern font family throughout the entire app
  • Haptic feedback β€” tactile responses on key interactions across dashboard, catalog, and settings
  • Dark mode β€” full dark theme support with carefully tuned surface/container colors

🀝 Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Guidelines

  • Follow existing code style and architecture patterns
  • Keep the shared ViewModel pattern β€” avoid per-screen ViewModels unless there's a strong reason
  • Use Material 3 components and the app's existing design tokens
  • Test on API 31+ emulator before submitting

⭐ Star History

Star History Chart

πŸ“„ License

This project is licensed under the GNU General Public License v3.0 β€” see the LICENSE file for details.


πŸ™ Acknowledgments

  • Vico β€” beautiful charting library for Compose
  • Coil β€” fast image loading for Kotlin
  • Material 3 β€” Google's latest design system
  • Montserrat β€” typeface by Julieta Ulanovsky

Made with β˜• and Kotlin

About

Track your caffeine. Protect your sleep. A privacy-first Material 3 Expressive Android app that shows your active caffeine level in real time and tells you if that late espresso will cost you tonight.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages