# mrdbourke/nutrify architecture

> Architecture diagram of the GitHub repository mrdbourke/nutrify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrdbourke/nutrify
- Repository: https://github.com/mrdbourke/nutrify

## Overview

Nutrify combines food-photo collection, a browser-based food/nutrition prototype, and a FoodVision model-training and labeling workflow. The main user path is a photo upload to cloud storage with metadata recorded separately; the prototype retrieves nutrition data and accepts correctness feedback. The README also describes the broader image-data flywheel and USDA nutrition exploration. Some links reflect README documentation or the source index rather than fully sampled implementations, so uncertain connections are omitted.

Main entry points: [`foodvision/utils/wandb_utils.py`](https://github.com/mrdbourke/nutrify/blob/main/foodvision/utils/wandb_utils.py) (Artifact helpers), [`foodvision/train.py`](https://github.com/mrdbourke/nutrify/blob/main/foodvision/train.py) (Model training), [`get_data.js`](https://github.com/mrdbourke/nutrify/blob/main/get_data.js) (Food data access), [`foodvision/autocorrect_and_merge_labels.py`](https://github.com/mrdbourke/nutrify/blob/main/foodvision/autocorrect_and_merge_labels.py) (Label correction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Image collection"]
  node_collector["Collector app"]
  node_image_upload["Image upload helper<br/>[utils.py]"]
  node_image_store[("Google Cloud Storage")]
  node_metadata_writer["Metadata writer<br/>[save_to_gsheets.py]"]
  node_sheets[("Google Sheets")]
end

subgraph group_prototype["Food lookup prototype"]
  node_browser_app["Browser app<br/>[script.js]"]
  node_food_data_client["Food data access<br/>[get_data.js]"]
  node_supabase_client["Supabase client<br/>[supabaseClient.js]"]
  node_nutrition_db[("Nutrition database")]
  node_food_classifier["Food classifier"]
end

subgraph group_vision["FoodVision modeling"]
  node_train_job["Model training<br/>[train.py]"]
  node_data_loader["Image data loader<br/>[data_loader.py]"]
  node_training_engine["Training engine<br/>[engine.py]"]
  node_evaluation["Model evaluation<br/>[evaluate.py]"]
  node_label_correction["Label correction"]
  node_label_studio_merge["Label Studio merge"]
  node_label_fixes["Label fixes<br/>[fix_labels.py]"]
  node_vision_config["Training config<br/>[default_config.py]"]
  node_gcp_helpers["Cloud helpers<br/>[gcp_utils.py]"]
  node_wandb_helpers["Artifact helpers<br/>[wandb_utils.py]"]
  node_wandb[("Weights &amp; Biases")]
end

subgraph group_data["Nutrition data"]
  node_usda_exploration["USDA data exploration"]
  node_usda_data[("FoodData Central files")]
end

node_contributor(("Photo contributor"))
node_food_user(("Food lookup user"))

node_contributor -->|"uploads photo"| node_collector
node_collector -->|"calls upload"| node_image_upload
node_image_upload -->|"stores image"| node_image_store
node_collector -->|"records metadata"| node_metadata_writer
node_metadata_writer -->|"writes metadata"| node_sheets
node_food_user -->|"uses lookup"| node_browser_app
node_browser_app -->|"calls data access"| node_food_data_client
node_food_data_client -->|"queries through"| node_supabase_client
node_supabase_client -->|"connects to"| node_nutrition_db
node_food_data_client -->|"shows nutrition"| node_food_user
node_food_classifier -.->|"feeds food lookup"| node_food_data_client
node_train_job -->|"loads datasets"| node_data_loader
node_train_job -->|"runs training"| node_training_engine
node_train_job -->|"uses artifacts"| node_wandb_helpers
node_train_job -->|"uses cloud helpers"| node_gcp_helpers
node_evaluation -->|"loads datasets"| node_data_loader
node_evaluation -->|"uses artifacts"| node_wandb_helpers
node_label_correction -->|"reads settings"| node_vision_config
node_label_correction -->|"uses cloud helpers"| node_gcp_helpers
node_label_correction -->|"uses artifacts"| node_wandb_helpers
node_label_studio_merge -->|"reads settings"| node_vision_config
node_label_studio_merge -->|"uses cloud helpers"| node_gcp_helpers
node_label_studio_merge -->|"uses artifacts"| node_wandb_helpers
node_label_fixes -->|"uses artifacts"| node_wandb_helpers
node_wandb_helpers -->|"loads and logs artifacts"| node_wandb
node_usda_exploration -.->|"explores data"| node_usda_data

click node_collector "https://github.com/mrdbourke/nutrify/blob/main/food_image_collector.py"
click node_image_upload "https://github.com/mrdbourke/nutrify/blob/main/utils.py"
click node_metadata_writer "https://github.com/mrdbourke/nutrify/blob/main/save_to_gsheets.py"
click node_browser_app "https://github.com/mrdbourke/nutrify/blob/main/script.js"
click node_food_data_client "https://github.com/mrdbourke/nutrify/blob/main/get_data.js"
click node_supabase_client "https://github.com/mrdbourke/nutrify/blob/main/supabaseClient.js"
click node_food_classifier "https://github.com/mrdbourke/nutrify/blob/main/models/2022-01-13-nutrify_model_100_foods_v0.tflite"
click node_train_job "https://github.com/mrdbourke/nutrify/blob/main/foodvision/train.py"
click node_data_loader "https://github.com/mrdbourke/nutrify/blob/main/foodvision/data_loader.py"
click node_training_engine "https://github.com/mrdbourke/nutrify/blob/main/foodvision/engine.py"
click node_evaluation "https://github.com/mrdbourke/nutrify/blob/main/foodvision/evaluate.py"
click node_label_correction "https://github.com/mrdbourke/nutrify/blob/main/foodvision/autocorrect_and_merge_labels.py"
click node_label_studio_merge "https://github.com/mrdbourke/nutrify/blob/main/foodvision/merge_labels_from_label_studio.py"
click node_label_fixes "https://github.com/mrdbourke/nutrify/blob/main/foodvision/fix_labels.py"
click node_vision_config "https://github.com/mrdbourke/nutrify/blob/main/foodvision/configs/default_config.py"
click node_gcp_helpers "https://github.com/mrdbourke/nutrify/blob/main/foodvision/utils/gcp_utils.py"
click node_wandb_helpers "https://github.com/mrdbourke/nutrify/blob/main/foodvision/utils/wandb_utils.py"
click node_usda_exploration "https://github.com/mrdbourke/nutrify/blob/main/data_exploration/usda_food_data_exploration.ipynb"
click node_usda_data "https://github.com/mrdbourke/nutrify/tree/main/data_exploration/data"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_collector,node_image_upload,node_image_store,node_metadata_writer,node_sheets,node_food_user toneBlue
class node_browser_app,node_food_data_client,node_supabase_client,node_nutrition_db,node_food_classifier toneAmber
class node_train_job,node_data_loader,node_training_engine,node_evaluation,node_label_correction,node_label_studio_merge,node_label_fixes,node_vision_config,node_gcp_helpers,node_wandb_helpers,node_wandb toneMint
class node_usda_exploration,node_usda_data toneRose
class node_contributor toneIndigo
```

## Components

### Image collection

- [Collector app](https://github.com/mrdbourke/nutrify/blob/main/food_image_collector.py): `food_image_collector.py`
- [Image upload helper](https://github.com/mrdbourke/nutrify/blob/main/utils.py): `utils.py`
- **Google Cloud Storage**
- [Metadata writer](https://github.com/mrdbourke/nutrify/blob/main/save_to_gsheets.py): `save_to_gsheets.py`
- **Google Sheets**

### Food lookup prototype

- [Browser app](https://github.com/mrdbourke/nutrify/blob/main/script.js): `script.js`
- [Food data access](https://github.com/mrdbourke/nutrify/blob/main/get_data.js): `get_data.js`
- [Supabase client](https://github.com/mrdbourke/nutrify/blob/main/supabaseClient.js): `supabaseClient.js`
- **Nutrition database**
- [Food classifier](https://github.com/mrdbourke/nutrify/blob/main/models/2022-01-13-nutrify_model_100_foods_v0.tflite): `models/2022-01-13-nutrify_model_100_foods_v0.tflite`

### FoodVision modeling

- [Model training](https://github.com/mrdbourke/nutrify/blob/main/foodvision/train.py): `foodvision/train.py`
- [Image data loader](https://github.com/mrdbourke/nutrify/blob/main/foodvision/data_loader.py): `foodvision/data_loader.py`
- [Training engine](https://github.com/mrdbourke/nutrify/blob/main/foodvision/engine.py): `foodvision/engine.py`
- [Model evaluation](https://github.com/mrdbourke/nutrify/blob/main/foodvision/evaluate.py): `foodvision/evaluate.py`
- [Label correction](https://github.com/mrdbourke/nutrify/blob/main/foodvision/autocorrect_and_merge_labels.py): `foodvision/autocorrect_and_merge_labels.py`
- [Label Studio merge](https://github.com/mrdbourke/nutrify/blob/main/foodvision/merge_labels_from_label_studio.py): `foodvision/merge_labels_from_label_studio.py`
- [Label fixes](https://github.com/mrdbourke/nutrify/blob/main/foodvision/fix_labels.py): `foodvision/fix_labels.py`
- [Training config](https://github.com/mrdbourke/nutrify/blob/main/foodvision/configs/default_config.py): `foodvision/configs/default_config.py`
- [Cloud helpers](https://github.com/mrdbourke/nutrify/blob/main/foodvision/utils/gcp_utils.py): `foodvision/utils/gcp_utils.py`
- [Artifact helpers](https://github.com/mrdbourke/nutrify/blob/main/foodvision/utils/wandb_utils.py): `foodvision/utils/wandb_utils.py`
- **Weights & Biases**

### Nutrition data

- [USDA data exploration](https://github.com/mrdbourke/nutrify/blob/main/data_exploration/usda_food_data_exploration.ipynb): `data_exploration/usda_food_data_exploration.ipynb`
- [FoodData Central files](https://github.com/mrdbourke/nutrify/tree/main/data_exploration/data): `data_exploration/data`

### Other components

- **Photo contributor**
- **Food lookup user**

## Connections

- Photo contributor → Collector app: uploads photo (evidence: `README.md`)
- Collector app → Image upload helper: calls upload (evidence: `food_image_collector.py`)
- Image upload helper → Google Cloud Storage: stores image (evidence: `README.md`)
- Collector app → Metadata writer: records metadata (evidence: `food_image_collector.py`)
- Metadata writer → Google Sheets: writes metadata (evidence: `README.md`)
- Food lookup user → Browser app: uses lookup (evidence: `README.md`)
- Browser app → Food data access: calls data access (evidence: `script.js`)
- Food data access → Supabase client: queries through (evidence: `get_data.js`)
- Supabase client → Nutrition database: connects to (evidence: `supabaseClient.js`)
- Food data access → Food lookup user: shows nutrition (evidence: `get_data.js`)
- Food classifier → Food data access: feeds food lookup
- Model training → Image data loader: loads datasets (evidence: `foodvision/train.py`)
- Model training → Training engine: runs training (evidence: `foodvision/train.py`)
- Model training → Artifact helpers: uses artifacts (evidence: `foodvision/train.py`)
- Model training → Cloud helpers: uses cloud helpers (evidence: `foodvision/train.py`)
- Model evaluation → Image data loader: loads datasets (evidence: `foodvision/evaluate.py`)
- Model evaluation → Artifact helpers: uses artifacts (evidence: `foodvision/evaluate.py`)
- Label correction → Training config: reads settings (evidence: `foodvision/autocorrect_and_merge_labels.py`)
- Label correction → Cloud helpers: uses cloud helpers (evidence: `foodvision/autocorrect_and_merge_labels.py`)
- Label correction → Artifact helpers: uses artifacts (evidence: `foodvision/autocorrect_and_merge_labels.py`)
- Label Studio merge → Training config: reads settings (evidence: `foodvision/merge_labels_from_label_studio.py`)
- Label Studio merge → Cloud helpers: uses cloud helpers (evidence: `foodvision/merge_labels_from_label_studio.py`)
- Label Studio merge → Artifact helpers: uses artifacts (evidence: `foodvision/merge_labels_from_label_studio.py`)
- Label fixes → Artifact helpers: uses artifacts (evidence: `foodvision/fix_labels.py`)
- Artifact helpers → Weights & Biases: loads and logs artifacts (evidence: `foodvision/utils/wandb_utils.py`)
- USDA data exploration → FoodData Central files: explores data (evidence: `README.md`)
