A personal iOS app that combines Whoop and Apple Health data with a nutrition coach powered by Apple Intelligence, running 100% on-device.
Traditional nutrition plans are static. Ducode makes them adaptive based on your real physiological state and personal preferences:
- Combines recovery, strain, sleep and HRV from Whoop with weight, steps, active calories, vitals and workouts from Apple Health.
- Uses Foundation Models (the iOS 26 on-device language model) to generate context-aware daily meal plans.
- Includes a conversational chat coach that knows your full profile and answers questions about nutrition, recovery, training and motivation.
- Zero servers, zero analytics, zero third parties: your data never leaves your iPhone.
| Area | Detail |
|---|---|
| Onboarding | 3-page intro with authorship and privacy, followed by a guided 6-step flow. |
| Whoop | OAuth 2.0, 7-day historical sync, live metrics with persistent fallback snapshot. |
| Apple Health | Reads body composition, activity, vitals, sleep, workouts, logged nutrition. |
| Daily plan | Generated by Foundation Models with @Generable, sensitive to recovery, sleep and debt. |
| Coach AI | Streaming chat with LanguageModelSession. Knows your goal, preferences and daily data. |
| Preferences | Cuisines (8 styles), dietary restrictions, allergies, dislikes, free-form notes to the prompt. |
| Per-meal regen | Circular ↻ button on each meal in the plan: regenerates only that meal with a focused prompt. |
| Distribution | Fastlane + App Store Connect API → one command to ship to TestFlight. |
| Layer | Technology |
|---|---|
| Platform | iOS 26.0+ |
| UI | SwiftUI |
| Persistence | SwiftData (@Model reactive with @Query) |
| AI | On-device Foundation Models (Apple Intelligence) |
| Networking | URLSession + async/await |
| Health | HealthKit (HKHealthStore) |
| Auth | OAuth 2.0 with URL Scheme |
| Build | XcodeGen + xcconfig |
| Distribution | Fastlane + App Store Connect API + TestFlight |
| Language | Swift 5.9 |
ducode_app/
├── DucodeApp/
│ ├── App/
│ │ └── DucodeApp.swift Entry point, ModelContainer, scene phase
│ ├── Models/
│ │ ├── Alimento.swift Food inventory
│ │ ├── Objetivo.swift User goal (Mifflin-St Jeor TMB)
│ │ ├── DiaRegistro.swift Daily log + ComidaRegistro
│ │ ├── WhoopHistory.swift Daily snapshot + weekly analytics
│ │ ├── UserPreferences.swift Cuisines, restrictions, allergies, notes
│ │ └── ChatMessage.swift Coach message persistence
│ ├── Services/
│ │ ├── WhoopService.swift OAuth + Whoop API v2
│ │ ├── WhoopSyncService.swift Historical sync → SwiftData snapshots
│ │ ├── NutritionAIService.swift Foundation Models + @Generable
│ │ ├── HealthKitService.swift Apple Health reads
│ │ └── CoachChatService.swift LanguageModelSession with rich context
│ ├── Utilities/
│ │ └── Config.swift Central AppConfig
│ ├── Views/
│ │ ├── ContentView.swift TabView + onboarding fullScreenCover
│ │ ├── DashboardView.swift Metrics + plan + Health360Card
│ │ ├── Health360Card.swift Expandable Apple Health summary
│ │ ├── PreferenciasComidaView.swift Comidas tab (auto-save + regenerate)
│ │ ├── ObjetivoView.swift Goal editor
│ │ ├── WhoopHistoryView.swift Weekly history
│ │ ├── Coach/
│ │ │ ├── CoachView.swift
│ │ │ ├── ChatBubbleView.swift
│ │ │ └── MarkdownText.swift
│ │ └── Onboarding/
│ │ ├── IntroView.swift 3 pages: welcome / author / privacy
│ │ ├── OnboardingCoordinator.swift
│ │ ├── OnboardingComponents.swift
│ │ ├── OnboardingWelcomeView.swift
│ │ ├── OnboardingHealthStep.swift
│ │ ├── OnboardingObjetivoStep.swift
│ │ ├── OnboardingPreferencesStep.swift
│ │ ├── OnboardingInventarioStep.swift
│ │ └── OnboardingGeneratingStep.swift
│ ├── Assets.xcassets/ Icons
│ ├── DucodeApp.entitlements HealthKit
│ └── Info.plist
├── docs/ Documentation (this file)
├── envs/ .p8 keys (gitignored)
├── fastlane/ Fastfile, Appfile, .env (gitignored)
├── scripts/ archive.sh, upload.sh
├── Secrets.xcconfig Whoop credentials (gitignored)
├── Secrets.xcconfig.template Public template
├── project.yml XcodeGen
└── .gitignore
- macOS with Xcode 26+ installed
- iPhone with Apple Intelligence enabled (iPhone 15 Pro or later, iOS 26+)
- Active Whoop subscription
- (Optional, for distribution) Active Apple Developer Program
- XcodeGen:
brew install xcodegen
# 1. Clone
git clone <repo> ducode_app && cd ducode_app
# 2. Whoop credentials
cp Secrets.xcconfig.template Secrets.xcconfig
# Edit Secrets.xcconfig with your WHOOP_CLIENT_ID and WHOOP_CLIENT_SECRET
# (developer.whoop.com → Create App → Redirect URI: ducode://oauth/callback)
# 3. Generate Xcode project
xcodegen generate
# 4. Open in Xcode and run
open DucodeApp.xcodeproj
# Cmd+R on a physical device (HealthKit doesn't work in the simulator)For the full step-by-step flow (Apple Developer Portal, App Store Connect, TestFlight, capabilities, troubleshooting): see SETUP.md.
# Ship a new build to TestFlight (auto-bumps the build number)
fastlane beta
# With custom changelog
fastlane beta changelog:"Coach improvements and new dark mode"
# Local build only, no upload
fastlane build
# Show the latest build in TestFlight
fastlane latestDistribution to friends via TestFlight Internal Testing: up to 100 testers, no Beta App Review, instant. See DISTRIBUTION.md for the full flow.
| Data | Where it lives | Leaves device |
|---|---|---|
| Whoop tokens | iOS Keychain | No |
| Whoop metrics | SwiftData (WhoopDailySnapshot) |
No |
| Apple Health data | HealthKit (Apple) | No |
| Goals and preferences | SwiftData | No |
| Coach conversation | SwiftData (ChatMessage) |
No |
| AI generation | On-device Foundation Models | Never |
| Behavioral analytics | — | Doesn't exist |
The only network egress is the Whoop API (authenticated via OAuth 2.0). All AI inference runs on your iPhone's chip.
See PRIVACY_POLICY.md.
| Document | What it's for |
|---|---|
| ARCHITECTURE.md | System design, layers, data flows |
| DATA_MODELS.md | @Model types, structs, @Generable types |
| INTEGRATIONS.md | Whoop, HealthKit, Foundation Models |
| USER_FLOWS.md | Journeys: intro, onboarding, daily, chat |
| SETUP.md | Local setup + capabilities + troubleshooting |
| DISTRIBUTION.md | Fastlane, TestFlight, internal testing |
| COACH.md | On-device AI chat design |
| PRIVACY_POLICY.md | Privacy policy |
Ducode is a personal, non-commercial app. Built by Alejandro Duque for personal use and a small inner circle.
The code lives in this repository as a technical reference for integrating Foundation Models, HealthKit and Whoop in a modern SwiftUI app distributed via TestFlight.
Personal use. Do not redistribute without permission.