LabelLens

How LabelLens is built

I’m Aditya Kanbargi. I built LabelLens end to end: a tested data pipeline over a million US food labels, a knowledge graph, an AI agent that is measured before it ships, and a connector that puts the same data inside Claude.

LinkedInGitHubThe codeDecision notes

US products through the pipeline
1M
data tests on every build
94
evals, each with a published report
8
model spend for the whole project
~$6

The architecture

  1. Source

    One bulk file, never the live API.

    • Open Food Facts exportfood.parquet, 8 GB, every product in the world
  2. Pipeline

    Runs in Dagster; everything is rebuilt from the snapshot.

    • IngestA dated snapshot, resumable, never edited
    • dbt on DuckDBStaging, intermediate and mart models with 94 data tests
    • EnrichmentClaude Haiku on the Batch API: categories and explainers, cached
  3. Storage

    Postgres tables are swapped in whole on each load.

    • Neon PostgresServing tables, full-text search, pgvector for explainers
    • Neo4j AuraDBProducts, brands, categories, additives and ingredients
  4. API

    One service for every client.

    • FastAPI on Cloud RunTyped endpoints from an OpenAPI contract, deployed on merge
  5. Apps

    Three ways to use the same data.

    • WebsiteNext.js on Vercel: search, labels, compare, basket, dashboard, graph
    • Ask agentClaude with SQL, graph and search tools; traced in Langfuse
    • Claude connectorAn MCP App: four tools and a label card inside Claude

The pipeline, step by step

  1. Data. The US subset of the Open Food Facts export goes through staging, intermediate and mart models in dbt, with tests on every key, range and relationship. Duplicate barcodes and impossible nutrient values are handled there, once.
  2. Enrichment. Claude fills in a category for the products that Open Food Facts’ tags leave unplaced, and writes an explainer for each additive and common ingredient. It runs through the Batch API and its outputs are committed, so a rerun costs nothing.
  3. Serving. Postgres holds the serving tables, swapped in atomically on each load, with full-text search and pgvector for explainer search. Neo4j holds a subset of the products as a graph, capped to fit the free tier.
  4. Apps. One FastAPI service serves the website, the ask agent and the MCP server. The API’s schema is checked against a written OpenAPI contract, and the web’s types are generated from the same file.
  5. Operations. GitHub Actions runs every check on each pull request, deploys the API on merge without stored keys, smoke-tests production every 6 hours, and reruns the connector eval when its tools change.

The stack

What each layer is built with
LayerBuilt with
DataDuckDB, dbt, Dagster, Python (uv, Ruff, Pyright, pytest)
AIClaude Haiku for the agent, enrichment and label reading; Claude Sonnet as eval judge; Voyage AI embeddings; Langfuse tracing
StorageNeon Postgres with pgvector, Neo4j AuraDB
APIFastAPI on Google Cloud Run, with the MCP server mounted at /mcp
WebNext.js 16, React, Tailwind CSS v4, Vitest, on Vercel

How it’s measured

Every AI feature is measured against a baseline before it ships, and each report lists its misses next to its wins. The ask agent scores 0.98 for facts against 0.26 for search alone.

Ask agent
Fact score 0.98 on 43 answerable questions, against 0.26 for an explainer-only baseline. All 5 requests for advice refused.
Category suggestions
90.0% of 200 products put in the right category (target 90%). The labels were written by an AI model, not a person.
Claude connector tool choice
Claude picked the right tool with the right arguments for 29 of 30 requests (target 90%).
Search speed
95% of searches answered within 175 ms on the public API (target 300 ms).
Graph and swaps speed
95% of graph neighbourhoods within 406 ms and swap lists within 233 ms on the public API (target 1 s).
Page speed
Lighthouse performance 100 on home, 98 on a product page and 100 on the dashboard (target 90).
Reading labels
98% of nutrient values read correctly from 30 real label photos (95–99%), checked against the photos; every value right on 85% of labels.
Waking up
After a quiet spell, the first request takes 7 to 10 s while the API starts (it was 22.6 s); the next ones take under 0.1 s. A ping every 5 minutes now keeps it awake most of the time.

What these numbers don’t show

  • The category labels came from a larger AI model, not from a person, so that result compares two models.
  • I wrote both the ask eval’s questions and the agent’s prompt.
  • The samples are small, so each report gives a range. Read it before comparing two numbers.

Problems I hit, and the fixes

The agent’s SQL is safe because of the database, not a parser
The agent writes its own SQL, but runs it as a role that can read five tables and nothing else, in a read-only transaction with a 3-second timeout and a 50-row cap. Only rows a tool actually returned can be cited, so an invented source is dropped.
The eval caught a regression the demo hid
Telling the agent to list each product once also made it de-duplicate counts: 1,178 cereals instead of 1,323, and the fact score fell to 0.88. The fix was scoped to lists, and the score went back to 0.98.
Only 1 of 11 production runs reached the trace log
Cloud Run samples a few requests for its own tracing, and OpenTelemetry’s default sampler followed that decision, so the rest were silently dropped. Each run now starts a trace of its own.
“Healthier swaps” offered restaurant menus
Open Food Facts lists menu items under 16- to 24-digit codes, and 34,200 of them qualified as swaps. A barcode check-digit test now keeps swaps to real packaged products.
Prompt caching was measured before it was trusted
Caching the fixed prompt and tools made a run 64% cheaper across 10 questions, with the same answers.

The reasoning behind each major choice, with what was rejected, is in the decision notes.

What it costs

  • Model calls: about $6 for the whole project. $5.18 of that was the one-off category fill, 604,507 inputs through the Batch API.
  • Evals are cached, so rerunning one costs $0. A paid run prints an estimate first and only sends when confirmed.
  • Hosting runs on free tiers: Neon, AuraDB, Cloud Run, Vercel, Langfuse and Voyage AI.
  • The public ask agent is limited to 10 questions an hour per visitor and $0.50 a day overall. Past that it shows recorded runs.

How I worked

I built LabelLens in four days, phase by phase against a written spec and design system, with Claude Code writing most of the code. I made the calls on scope, design, hosting and spending. Every change went through a pull request with automated checks, and I approved each merge after seeing its test output and screenshots. The README says where I overruled it.

  • Every feature ships with a test or an eval.
  • No paid model call runs without a limit and a printed cost estimate.
  • The interface uses only the tokens in the design system.
  • Every interface change is checked with screenshots at phone, laptop and wide-screen widths.

Try it

Search a product, read a label from a photo, ask the agent a question, or add the connector to Claude with this address. It needs no sign-in.

https://labellens-api-1036759996795.us-east4.run.app/mcp

What LabelLens is for, where its data comes from and what happens to a question are on the About page.