A full-featured health & fitness tracking Android application built with Java, Firebase, and the Gemini AI API — inspired by HealthifyMe.
| Feature | Details |
|---|---|
| 🔐 Authentication | Email/Password + Google Sign-In via Firebase Auth |
| 👤 User Profiles | Onboarding wizard, BMR/TDEE auto-calculation |
| 🍽 Food Logging | Meal tracking with full macro breakdown |
| 🤖 AI Food Scan | Photo or gallery image → Gemini auto-detects food & nutrition |
| 🔍 Food Search | Type a food name → Gemini returns nutrition info |
| 💪 Workout Logging | Exercises, sets, reps, weight, duration, calories burned |
| 📊 Daily Dashboard | Calorie ring, macro bars, water tracker, workout summary |
| 📈 Progress Charts | 7/14/30-day calorie trend, macro bar chart, workout duration |
| ☁️ Real-time Sync | Firestore real-time listeners — data never lost |
| 🗃 Offline-ready | Firestore offline persistence built-in |
- Go to Firebase Console and create a new project.
- Add an Android app with package name:
com.healthtracker - Download
google-services.jsonand place it at:app/google-services.json - Enable Authentication → Sign-in methods:
- Email/Password ✅
- Google ✅ (copy the Web Client ID — you'll need it)
- Enable Cloud Firestore → Start in production mode
- Deploy Firestore security rules from
firestore.rules
In app/src/main/res/values/strings.xml, replace:
<string name="default_web_client_id">YOUR_WEB_CLIENT_ID_HERE</string>with your actual Web Client ID from Firebase Console → Authentication → Google → Web SDK configuration.
- Get a free key at Google AI Studio
- Add it to your
local.propertiesfile (never commit this file!):TheGEMINI_API_KEY=AIzaSy...your_key_herebuild.gradlereads it automatically viaBuildConfig.GEMINI_API_KEY.
Some queries require composite indexes. Firestore will show error logs with direct links to create them. Create indexes for:
food_entries:userId ASC+dateString ASC+createdAt ASCworkout_entries:userId ASC+dateString ASCdaily_summaries:userId ASC+dateString ASC
In your root build.gradle, add Jitpack to allprojects.repositories:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // ← ADD THIS
}
}app/src/main/java/com/healthtracker/
├── activities/
│ ├── SplashActivity.java # Entry point
│ ├── LoginActivity.java # Email + Google auth
│ ├── RegisterActivity.java # New account creation
│ ├── OnboardingActivity.java # 3-step profile setup
│ ├── MainActivity.java # Bottom nav host
│ ├── FoodLogActivity.java # Log food + AI scan
│ └── WorkoutLogActivity.java # Log workout + exercises
├── fragments/
│ ├── DashboardFragment.java # Home screen
│ ├── FoodFragment.java # Food log list
│ ├── WorkoutFragment.java # Workout list
│ ├── ProgressFragment.java # Charts & stats
│ └── ProfileFragment.java # User profile
├── models/
│ ├── User.java # User + BMR/TDEE calc
│ ├── FoodEntry.java # Meal entry
│ ├── WorkoutEntry.java # Workout session
│ ├── Exercise.java # Exercise + ExerciseSet
│ └── DailySummary.java # Aggregated daily data
├── repositories/
│ ├── FirebaseRepository.java # All Firestore operations
│ └── GeminiRepository.java # Gemini Vision API calls
├── viewmodels/
│ └── DashboardViewModel.java # LiveData + business logic
└── adapters/
├── FoodEntryAdapter.java # RecyclerView for food
├── WorkoutEntryAdapter.java # RecyclerView for workouts
└── ExerciseAdapter.java # Exercises + set rows
UI (Activities/Fragments)
↓ observes LiveData
ViewModel (DashboardViewModel)
↓ calls
Repositories (FirebaseRepository, GeminiRepository)
↓ reads/writes
Firebase Firestore + Gemini REST API
- MVVM pattern with LiveData for reactive UI updates
- Real-time listeners via
addSnapshotListener— dashboard updates instantly on any device - Firestore transactions for atomic daily summary updates (no race conditions)
- Gemini 1.5 Flash for fast, cost-effective food image recognition
users/{uid}
- name, email, age, weightKg, heightCm
- gender, activityLevel, goal
- dailyCalorieGoal, dailyProteinGoalG, dailyCarbGoalG, dailyFatGoalG
food_entries/{autoId}
- userId, foodName, mealType, dateString
- calories, proteinG, carbsG, fatG, fiberG, sugarG, sodiumMg
- servingSize, servingUnit, aiGenerated
workout_entries/{autoId}
- userId, workoutName, workoutType, dateString
- durationMinutes, caloriesBurned, intensityLevel
- exercises: [ { name, category, sets: [{setNumber, weightKg, reps}] } ]
daily_summaries/{uid_YYYY-MM-DD}
- userId, dateString
- totalCaloriesConsumed, totalCaloriesBurned
- totalProteinG, totalCarbsG, totalFatG
- calorieGoal, workoutCount, workoutMinutes, waterLitres
| Library | Purpose |
|---|---|
| Firebase Auth | User authentication |
| Firebase Firestore | Real-time cloud database |
| Google Play Services Auth | Google Sign-In |
| Gemini 1.5 Flash API | AI food image recognition |
| MPAndroidChart | Progress charts |
| Glide | Image loading |
| CircleImageView | Profile picture |
| Material Components 3 | UI components |
| OkHttp + Gson | HTTP client for Gemini |
| Room | Local caching (optional extension) |
The app uses the Mifflin-St Jeor equation for BMR and adjusts for activity level (TDEE):
- Sedentary → ×1.2
- Light → ×1.375
- Moderate → ×1.55
- Active → ×1.725
- Very Active → ×1.9
Goals adjust TDEE:
- Lose Weight: TDEE − 500 cal
- Maintain: TDEE
- Gain Muscle: TDEE + 300 cal
- Android 8.0 (API 26) or higher
- Internet connection for Firebase + Gemini
- Camera permission for AI food scanning