The third short about Fud AI, my open-source food diary, is about the one logging feature that uses no AI at all: scan a packet's barcode and the nutrition fills itself in. A blueberry asks a granola cluster how many calories it is. The granola has no idea, but it does have a barcode.

The problem: the Simulator has no camera

I record app footage in the iOS Simulator, because every take is clean and repeatable. A barcode scanner is the one screen that can't be recorded that way: there is no camera to point at a packet.

So I split the feature at its natural seam:

  1. The scan is a cartoon. The blueberry holds a phone up to a barcode sticker on the granola, a red line sweeps the frame and a beep plays. Nobody will mistake that for app footage, which is the point.
  2. Everything after the scan is the real app. For the recording I added a capture-only launch argument to a throwaway copy of the app. It passes a barcode number to the same function the scanner calls when it reads a code. From there it is the normal flow at real speed: the "Looking up barcode..." sheet, the network request, the result, the Log button, and the Home total going from 1,149 to 1,583 kcal.

That hook was never committed. It lived in a scratch worktree for one recording and was deleted with it. The app's permanent screenshot scenes use the same idea, guarded so they can't ship:

#if DEBUG && targetEnvironment(simulator) // read a launch argument, then open the screen being captured #endif 

What the lookup does

There is no model in this path. The app sends the barcode digits to Open Food Facts, a public, crowd-sourced product database:

GET https://world.openfoodfacts.org/api/v2/product/5060201625643.json?fields=product_name,brands,serving_size,nutriments,... 

A few details that turned out to matter:

  • Ask only for the fields you use. The fields parameter keeps the response small.
  • Identify your app. Fud AI sends a User-Agent with its name, version and website.
  • A 404 is an answer, not a failure. A valid barcode that isn't in the database comes back as HTTP 404 with a JSON body. The app says the product wasn't found and suggests scanning the nutrition label instead.
  • Found is not the same as usable. Some products exist with no calories or macros. That gets its own message and the same fallback.
  • Validate before building the URL. Digits only, 24 characters at most, so a malformed code never becomes a request.

Because no AI is involved, barcode scan is free and needs no AI key. It works only when the product is listed, and the data is as good as what contributors entered, so the app shows the result for review before anything is saved.

The punchline is a real edge case

Open Food Facts gives nutrition per 100 g, and per serving when the product has a serving size. The app uses the per-serving values when they exist. When there is no serving size, it falls back to 100 g.

The product in the video is a raisin and almond granola with no serving size listed, so the result reads 434 kcal and 15.5 g of protein for 100 g. Hence the granola's objection at the end: "That's per hundred grams!" It is right. A barcode identifies the product. It doesn't measure your portion, so you still set how much you ate.

Picking a product that is safe to show

  • The entry has no brand field, so no brand name appears in the video.
  • The product photo is hidden in the recording. Photos on Open Food Facts are CC BY-SA, and I didn't want someone else's packaging shot in a promo.
  • The end card and the video description credit Open Food Facts for the data.

The cartoon

Same approach as the earlier episodes: illustrated poses instead of generated video, edited by one Python script (Pillow draws each frame and pipes it into ffmpeg). The poses are AI-illustrated from my existing character art, the voices are ElevenLabs, and the diary in the footage is demo data.

Try it

Fud AI runs on iPhone and Android, and core tracking needs no account.