SS.← All Projects

Data Engineering · Case Study

USDA Ingredient Pipeline

An 8-phase Python pipeline that transformed 13k+ raw USDA food records into 1,900+ production-ready ingredients — organized into a 3-tier category hierarchy and tagged for dietary restrictions at 95%+ accuracy.

13k+

Raw USDA records in

1,900+

Production ingredients out

95%+

Diet-tag accuracy

17

Top-level categories

29

Mid-level groups

10+

Diet patterns tagged

The Problem

USDA's food datasets — FoodData Central and the legacy FNDDS — contain over 13,000 records. They include raw whole foods, processed variants, industrial compounds, laboratory standards, and dozens of near-duplicate entries at varying levels of specificity.

The startup needed a clean, categorized ingredient database for recipe matching, nutrition display, and dietary restriction filtering. No off-the-shelf dataset matched the shape we needed, and manual curation at this scale would have taken weeks and introduced inconsistencies.

The pipeline needed to be reproducible, auditable, and fast enough to re-run as the USDA data or category schema evolved.

The 8-Phase Pipeline

01Ingestion

Load and parse raw USDA CSV exports — FoodData Central and legacy FNDDS datasets — into a unified in-memory structure.

02Deduplication

Identify equivalent entries across USDA's overlapping datasets using name normalization and fuzzy matching. Merge and retain the richest record.

03Filtering

Remove industrial compounds, laboratory standards, and non-food entries. Strip highly specific sub-forms that have no practical recipe utility.

04Normalization

Standardize names (e.g. "APPLES,RAW,WITH SKIN" → "Apple"), strip measurement units from descriptions, and resolve capitalization inconsistencies.

05Hierarchy Classification

Use the Anthropic API to classify each ingredient into the 3-tier category system: 17 top-level categories and 29 mid-level groups.

06Diet Tag Inference

Automatically tag each ingredient across 10+ dietary patterns — vegan, vegetarian, gluten-free, keto, paleo, and more. Achieves 95%+ accuracy vs. manual review.

07Validation

Cross-check category assignments and diet tags for internal consistency. Flag statistical outliers and edge cases for targeted human review.

08Production Export

Write production-ready records to structured CSVs consumed by the Ingredient Seeder, which seeds PostgreSQL via idempotent upserts.

3-Tier Ingredient Hierarchy

Level 117 categories

e.g. Proteins · Grains · Produce · Dairy · Fats & Oils

Level 229 groups

e.g. Leafy Greens · Root Vegetables · Citrus · Tree Fruits

Level 31,900+ ingredients

e.g. Spinach · Carrot · Lemon · Granny Smith Apple

The hierarchy was designed for the product's filtering UI: Level 1 powers broad dietary filters ("Show me Proteins"), Level 2 drives subcategory browsing, and Level 3 is what appears in recipe ingredient lists and search.

Before & After

Before

13,000+ raw USDA records
Duplicates across datasets
Non-food & lab entries
Inconsistent naming
No category structure
No dietary tags

After

1,900+ production ingredients
Deduplicated & merged
Food-only, recipe-relevant
Standardized names & forms
3-tier category hierarchy
95%+ automated diet tags

Product Demo

Demo video coming soon

A walkthrough of the pipeline and the product it powers is being prepared.

Tech Stack

PythonAnthropic API (Claude)CSV / PandasPostgreSQLRust / Loco (downstream seeder)
← Back to ProjectsGet in touch →