Skip to content
erick.dev
← All projects

Equivale

SMAE exchange-list diet planning for nutritionists: from patient assessment to a plan exported as PDF, Word or Excel, with no server.

Role
Design & development
Year
2026
Status
In production
Type
App
JavaScriptVitejsPDFSheetJSJSZipDockernginxDokploy
01Problem
SMAE exchange-based meal planning is done by hand or in spreadsheets, and an early mistake ends up in the patient's plan.
02Solution
Open source web app that goes from assessment to menu and exports the plan to PDF, Word and Excel, with no server.
03Result
In production and used by nutritionists as an assistant for meal planning.

The problem

In Mexico, meal plans are usually built with the SMAE (the Mexican food exchange system): you estimate energy needs, turn the macronutrient split into exchanges per food group, spread them over five meals and then put together a menu that matches. In practice it’s often done in spreadsheets or by hand. Every step depends on the previous one, so an early mistake ends up in the plan the patient takes home.

That’s why I built Equivale and released it as free and open source: any nutritionist can use it in the browser, with no account or install.

The solution

Equivale walks through a consultation in five steps: assessment, diet calculation, distribution, menu and final plan. From weight, height, age, sex and activity level it computes BMI, waist-to-hip ratio, ideal and adjusted weight, and energy expenditure with four equations (Harris-Benedict, FAO/WHO, Mifflin-St Jeor and IOM), including the extra for pregnancy or breastfeeding. Given the calorie target and macro split, it proposes exchanges for each of the 19 groups, distributes them across meals and lets you build the menu from a 527-food catalog. A renal mode checks sodium, potassium, phosphorus and protein per kilo against their limits.

The plan exports to PDF, Word and Excel with the nutritionist’s details. Everything lives in the browser: no accounts, no server, and data is backed up and restored as a file.

How it’s built

It started as a single-file HTML prototype, which I migrated to Vite with ES modules split by responsibility.

  • calc.js: SMAE groups, equations and pure calculations, no DOM.
  • state.js: state, debounced saving to localStorage and data migrations between versions.
  • outputs.js: every derived value is recomputed on each change and written into nodes tagged with data-o, without re-rendering the view.
  • exports.js: jsPDF + autotable, SheetJS and JSZip are loaded on demand with import(), so they stay out of the initial bundle.
  • Deployment: a multi-stage Dockerfile (Node builds, nginx serves dist/) on Dokploy, with immutable caching for hashed assets.

Technical challenges

  • Proposing exchanges that add up. autoEq sets a base (vegetables, fruit, milk, legumes) and then adjusts grains, animal protein and fats over up to eight iterations, rounding to half exchanges, until it lands within 3% of the calorie target. In vegetarian mode protein comes from legumes, capped so carbs don’t overshoot.
  • Splitting without losing half exchanges. Per-meal distribution works in half-exchange units and uses the largest-remainder method, so each group’s meals always sum to its total.
  • Word files without a Word library. The .docx is built by hand: I write the WordprocessingML (paragraphs, tables, borders) and zip it with JSZip.
  • Updating the catalog without overwriting user data. The catalog is versioned; when the version goes up, the migration adds new foods by id and leaves alone anything the nutritionist edited, hid or created. The extended catalog documents its sources (SMAE for portions, USDA FoodData Central for composition) and flags estimates.

Status and next steps

It’s in production at equivale.orion-consultoria.tech, redeployed automatically on every push. The main limitation comes from the design itself: data is tied to the browser and the domain, which is why the app reminds you to back up. Syncing across devices would need a backend and accounts, which it doesn’t have today.

Nutritionists already use it today as an assistant to plan their patients’ meals.

Next project →Vaciado

Contact

Got a project in mind?

Tell me what you need. I'll reply within 48 hours with questions or a proposal.

Or reach me on

WhatsApp