Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
217a0b4
Add FoodFinder feature: AI-powered food identification for carb entry
taylorpatterson-T1D Feb 8, 2026
128c997
Add generative voice search: route mic input through AI analysis
taylorpatterson-T1D Feb 8, 2026
200a870
Detect keyboard dictation for generative AI search instead of mic button
taylorpatterson-T1D Feb 8, 2026
a338c8e
Fix pbxproj group hierarchy: attach orphaned FoodFinder groups
taylorpatterson-T1D Feb 8, 2026
5786e87
FoodFinder: fix barcode thumbnail loading, add secure API key storage…
taylorpatterson-T1D Feb 9, 2026
a9da314
FoodFinder: performance optimizations and debug print cleanup
taylorpatterson-T1D Feb 9, 2026
5b22e27
FoodFinder: consolidate files, fix long-title overflow, standardize h…
taylorpatterson-T1D Feb 9, 2026
f21361a
FoodFinder: add LoopInsights data hooks and 30-day retention option
taylorpatterson-T1D Feb 9, 2026
bb7dd68
FoodFinder: add data hooks and 30-day retention option
taylorpatterson-T1D Feb 9, 2026
95acc64
Merge remote-tracking branch 'myfork/feat/FoodFinder' into feat/FoodF…
taylorpatterson-T1D Feb 10, 2026
ebd6ff6
FoodFinder: realistic absorption times, fix OCR routing, inline Why hrs
taylorpatterson-T1D Feb 10, 2026
abf9319
FoodFinder: move Why hrs pill to right of absorption time value
taylorpatterson-T1D Feb 11, 2026
63c53fc
FoodFinder: increase maxFoodTypeLength from 20 to 50
taylorpatterson-T1D Feb 13, 2026
c2598c8
Record barcode and text-search products to MealArchive with thumbnails
taylorpatterson-T1D Feb 20, 2026
6649c3b
Populate nutritional data on barcode and text-search meal records
taylorpatterson-T1D Feb 20, 2026
b92d053
Record barcode products to MealArchive only once per selection
taylorpatterson-T1D Feb 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Documentation/Assigning a bundle identifier.png
Binary file not shown.
Binary file removed Documentation/Changing the app icon.png
Binary file not shown.
Binary file removed Documentation/Changing the display name.png
Binary file not shown.
99 changes: 99 additions & 0 deletions Documentation/FoodFinder/FoodFinder_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# FoodFinder for Loop

FoodFinder adds AI-powered food identification and nutrition lookup to Loop's carb entry workflow. It supports barcode scanning (via OpenFoodFacts), AI camera analysis, voice search, and text-based food search — all integrated with a minimal footprint into Loop's existing codebase.

## Features

- **Barcode Scanner** — Scan product barcodes to look up nutrition data from OpenFoodFacts
- **AI Camera Analysis** — Take a photo of food and get AI-powered carb estimates (supports Claude, OpenAI, Google Gemini, and custom BYO providers)
- **Voice Search** — Speak a food name to search for nutrition information
- **Text Search** — Type a food name for quick lookup
- **Favorite Food Thumbnails** — Saved favorites display thumbnail images for easy identification
- **Configurable AI Providers** — Choose between multiple AI backends or bring your own API endpoint

## Architecture

FoodFinder follows the **minimal footprint principle**: all feature logic lives in dedicated `FoodFinder/` subdirectories, with fewer than 30 lines added to existing Loop files.

### Directory Structure

```
Loop/Loop/
├── Views/FoodFinder/ (11 files — all UI components)
├── Models/FoodFinder/ (3 files — data models)
├── Services/FoodFinder/ (13 files — API clients, scanning, AI)
├── View Models/FoodFinder/ (2 files — state management)
├── Resources/FoodFinder/ (1 file — feature flags + settings keys)
└── Documentation/FoodFinder/ (this file)

Loop/LoopTests/FoodFinder/ (3 files — unit tests)
```

### Integration Touchpoints

Only 3 existing Loop files are modified, totaling ~29 lines:

| File | Lines Added | Purpose |
|------|-------------|---------|
| `CarbEntryView.swift` | ~9 | Inserts `FoodFinder_EntryPoint` view |
| `SettingsView.swift` | ~16 | Adds FoodFinder Settings navigation link |
| `FavoriteFoodDetailView.swift` | ~4 | Adds thumbnail display for favorites |

### Key Files

| File | Role |
|------|------|
| `FoodFinder_FeatureFlags.swift` | Central on/off toggle and all UserDefaults keys |
| `FoodFinder_EntryPoint.swift` | Self-contained carb entry UI (search, scan, results) |
| `FoodFinder_SearchViewModel.swift` | All search/scan/AI state management |
| `FoodFinder_SettingsView.swift` | AI provider configuration screen |

## Enabling/Disabling

FoodFinder is controlled by a single toggle in `FoodFinder_FeatureFlags.swift`:

```swift
FoodFinder_FeatureFlags.isEnabled // returns Bool
```

When disabled, all FoodFinder UI is hidden and no FoodFinder code executes. The feature can be toggled via the `foodSearchEnabled` UserDefaults key.

## AI Provider Configuration

FoodFinder supports multiple AI providers for food photo analysis:

1. **Claude** (Anthropic) — Requires API key
2. **OpenAI** (GPT-4 Vision) — Requires API key
3. **Google Gemini** — Requires API key
4. **BYO (Bring Your Own)** — Custom endpoint URL + API key

Providers are configured in Settings > FoodFinder Settings. API keys are stored in UserDefaults with `foodFinder_` prefixed keys.

## Portability

FoodFinder is designed for easy adoption into other Loop forks (Trio, IAPS, Tidepool Loop):

- **No LoopKit submodule changes** — All code lives under the Loop/ submodule
- **Self-contained feature flag** — Single file controls enable/disable
- **Prefixed naming** — All files use `FoodFinder_` prefix to avoid naming conflicts
- **Minimal touchpoints** — Only 3 files need small modifications in the host app
- **Script-installable** — The `FoodFinder/` directories can be copied and the 3 touchpoints applied programmatically

## Dependencies

FoodFinder uses only Apple frameworks available on iOS:

- `Vision` — Barcode detection
- `AVFoundation` — Camera access for scanning and AI analysis
- `Speech` — Voice search recognition
- `SwiftUI` / `UIKit` — User interface

No third-party dependencies are required.

## Testing

Unit tests are located in `LoopTests/FoodFinder/`:

- `FoodFinder_OpenFoodFactsTests.swift` — API response parsing tests
- `FoodFinder_BarcodeScannerTests.swift` — Barcode detection tests
- `FoodFinder_VoiceSearchTests.swift` — Voice recognition tests
Binary file removed Documentation/Screenshots/Phone Bolus.png
Binary file not shown.
Binary file removed Documentation/Screenshots/Phone Graphs.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Documentation/Screenshots/Watch Bolus.png
Binary file not shown.
Binary file removed Documentation/Screenshots/Watch Carb Entry.png
Binary file not shown.
Binary file removed Documentation/Screenshots/Watch Complication.png
Binary file not shown.
Binary file removed Documentation/Screenshots/Watch Menu.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Documentation/Testing/Images/mock_managers.png
Binary file not shown.
Binary file removed Documentation/Testing/Images/rewind.png
Binary file not shown.
Binary file removed Documentation/Testing/Images/scenarios_menu.png
Binary file not shown.
Binary file removed Documentation/Testing/Images/scenarios_url.png
Binary file not shown.
67 changes: 0 additions & 67 deletions Documentation/Testing/Scenarios.md

This file was deleted.

Binary file removed Documentation/User Icons/LoopingPump.png
Binary file not shown.
Loading