An iOS app that uses your camera and machine learning to estimate the calories in your food — meal by meal, day by day.
Point your camera at a plate. The app identifies the food, shows the calorie count and macros, lets you adjust the portion, and logs it. At the end of the day you see exactly what you ate and how close you were to your goal. At the end of the month you see a colour-coded calendar of every day.
- Food recognition — photograph any meal, get an instant food label and calorie estimate
- Portion control — slide between ½ and 2½ servings before logging
- Meal tagging — Breakfast, Lunch, Dinner, or Snacks, auto-suggested by time of day
- Daily dashboard — calorie ring, macro breakdown (protein / carbs / fat), per-meal sections with subtotals
- Monthly calendar — 30-day grid showing daily totals, colour-coded green / yellow / red vs. your goal
- Day detail — tap any calendar cell to see every meal logged that day
- Personalised welcome — asks your name once on first launch, greets you with a time-aware message and a new funny food quote every day
- Fully offline — food database and ML model run on-device, no account or internet required
| Layer | Choice |
|---|---|
| Language | Swift 5.9+ |
| UI | SwiftUI |
| Persistence | SwiftData (iOS 17+) |
| Camera | AVFoundation + PHPickerViewController |
| ML | CoreML + Vision framework |
| ML model | EfficientNet-B3 fine-tuned on Food101 (mock in dev) |
| Async | Swift Concurrency (async/await) |
CalorieLens/
├── CalorieLensApp.swift
├── MainTabView.swift
├── Models/
│ ├── MealEntry.swift # SwiftData model
│ ├── MealType.swift # breakfast / lunch / dinner / snack
│ ├── FoodNutrition.swift # calorie + macro data shape
│ ├── FoodPrediction.swift # ML result
│ └── Extensions.swift # kDailyGoal, [MealEntry] helpers, Calendar helpers
├── Services/
│ ├── CalorieService.swift # looks up food_calories_db.json
│ └── CalendarAggregator.swift
├── Resources/
│ └── food_calories_db.json # 101 foods with calories and macros
└── Features/
├── Welcome/ # onboarding, welcome screen, UserStore
├── Camera/ # AVFoundation capture, gallery picker
├── FoodRecognition/ # CoreML wrapper + mock classifier
├── Results/ # result card, portion picker, macro chart
├── Dashboard/ # home screen, calorie ring
├── History/ # monthly calendar, day detail
└── Shared/ # MealSectionView, MealRowView
- Xcode 15+
- iOS 17+ deployment target
- iPhone 16 (or any iPhone running iOS 17+) recommended — the camera flow requires a real device
1. Create the Xcode project
Xcode → File → New → Project
→ iOS → App
→ Product Name: CalorieLens
→ Interface: SwiftUI | Storage: SwiftData | Language: Swift
2. Add the source files
Delete the files Xcode generates, then drag the entire CalorieLens/ folder from this repo into the project navigator. Check Copy items if needed and Add to target: CalorieLens.
3. Add camera and photo permissions
In Info.plist add:
NSCameraUsageDescription
→ CalorieLens needs camera access to photograph your food.
NSPhotoLibraryUsageDescription
→ CalorieLens needs photo access to import food images.
4. Sign the app
Project navigator → CalorieLens target → Signing & Capabilities
→ Team: your Apple ID
→ Bundle Identifier: com.yourname.calorielens
5. Run
Select your iPhone 16 in the device picker and press ▶.
Settings → Privacy & Security → Developer Mode → On(requires restart)- Plug in via USB → Trust This Computer when prompted
Xcode → Settings → Accounts→ add your Apple ID if not already added- Select your device in the top bar → ▶ Run
The app ships with a mock classifier that simulates a 1.2 s inference delay and returns a random food from the database — enough to build and test the full UI flow without a real model.
To plug in a real model:
- Fine-tune EfficientNet-B3 on the Food101 dataset (PyTorch or TensorFlow)
- Convert to CoreML:
import coremltools as ct
mlmodel = ct.convert(
torch_model,
inputs=[ct.ImageType(shape=(1, 3, 224, 224), bias=[-1,-1,-1], scale=1/127.5)]
)
mlmodel.save("Food101Classifier.mlmodel")- Add
Food101Classifier.mlmodelto the Xcode project (target membership: CalorieLens) - Uncomment the six lines in
FoodClassifier.swiftmarked// Uncomment once you export...
The mock is bypassed automatically once the model file is present.
food_calories_db.json covers all 101 categories from the Food101 dataset with per-serving calories, protein, carbs, and fat. Values are approximate averages for a standard serving.
To add a food, append an entry to the "foods" object:
"dal_rice": {
"display_name": "Dal Rice",
"calories_per_serving": 300,
"serving_description": "1 plate (300g)",
"protein": 10,
"carbs": 55,
"fat": 4
}The key must match the label your CoreML model outputs (snake_case).
The default daily calorie goal is 2,000 kcal, defined as kDailyGoal in Models/Extensions.swift. Change it there to update the ring, calendar colours, and progress bars everywhere at once.