SShortSingh.
Back to feed

Why food databases store nutrition per 100 grams instead of by serving size

0
·6 views

People estimate a 'serving' inconsistently, so the same portion of rice can vary by dozens of grams and tens of calories. Nutrition labels use standardized serving sizes meant for packaging rather than real plates. A food database built for a nutrition app therefore stores each item's calories and macronutrients per 100 grams, which allows exact linear scaling to any quantity. The approach also handles raw versus cooked foods separately and treats liquids with density notes, while branded labels override generic entries. The founder says this normalization lets meal plans be expressed as precise gram-based shopping lists.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Replaying Recorded AI Agent Conversations to Test Prompt Changes Offline

A walkthrough shows how a one-sentence edit to a production AI agent's system prompt can break multi-turn behavior, such as shifting JSON field types or wiping protected keys, even when single-turn tests pass. The approach records each turn as an append-only checkpoint and freezes historical tool outputs so that replaying a candidate prompt never triggers live API calls or external messages. A Python 3.10+ harness using only the standard library compares a baseline prompt against a candidate prompt in a concrete construction work-order scenario, which contains deliberate regressions. The method evaluates deterministic state-machine differences rather than live model latency, and it is meant to run as a gate before prompt or model changes are promoted.

0
ProgrammingDEV Community ·

Recording Model Provenance for Green CI Gates Before Merge

The article argues that a passing gate is only valuable if a team can later reconstruct what produced its verdict. It proposes making gate provenance a required build artifact containing the model ID, prompt revision, fixture commit, config hash, timestamp, and verdict. The author stresses this is lineage supporting audit and rollback, not proof that outputs are correct, and notes that frameworks such as W3C PROV-DM and SLSA treat provenance as history rather than certification. Suggested implementation details include storing one write-once record per source commit and gate run ID, failing the merge check when a record is missing, and testing by running the gate twice with only the prompt changed. The piece also warns against relying on a mutable model name, editable PR comments, or treating provenance as an approval.

0
ProgrammingDEV Community ·

Why an AI patch rollback may not undo database or config changes

A Kubernetes Deployment rollback restores only the Pod template from an earlier revision, not other changes such as database migrations. The article argues that teams should define the recovery unit before merging an AI-assisted patch that may mix code, manifests, configs, flags and schema changes. Each affected artifact should be inventoried, given a named recovery action and owner, and checked for whether it affects runtime or persisted data. It recommends rehearsing recovery in a disposable environment, since a template can revert successfully while full application recovery remains unproven. The piece also references the voluntary NIST AI RMF, whose Manage 4.1 calls for monitoring and recovery planning for deployed AI.

0
ProgrammingDEV Community ·

Kafka Architecture Explained: Brokers, Partitions and KRaft

A Kafka cluster is a group of brokers that store topics, with each topic divided into partitions that are replicated across several brokers. A controller quorum holds cluster metadata, tracking which brokers are alive and which replica leads each partition. Producers write to partition leaders, typically choosing a partition by hashing the record key, while consumers in groups read partitions in order using offsets. The article walks through this design using output from a three-node Kafka 4.4 test cluster, including a demonstration of failover after stopping one broker. It also explains that ordering is guaranteed only within a partition, and that partitions set the limit on parallel consumption within a group.