Forma, a private nutrition and training coach

I’d find myself in the kitchen trying to guess how many grams of pasta were in the pot, or coming back from a workout and opening three different apps to reconstruct the day. Meals sat half-logged in a notes app, and estimating calories and macros by hand was tedious. I wanted something that would fit my calendar, and keep health data on my own infrastructure.

I built Forma, a private coach in Grok Bot, with a dashboard on my Cloudflare account and an app that reads Apple Health. I send it a photo of lunch and get an estimate back, I ask what to eat before tennis, and in the evening I glance at the dashboard.

I’ve now published a template of the bot. You can install it on your account and use it the same way, with your data on your Cloudflare account. I cover what it is, how to install it, how to set up the dashboard and Forma Sync, and where the data stays.

How the data gets there You chat with the Forma bot in Grok Bot, which posts meals to a Cloudflare Worker with D1. Forma Sync posts Apple Health data to the same Worker. The password-protected dashboard reads from there. Calendar and email, if connected, reach the bot as read-only. How the data gets there You, in chat photo, menu or text Forma bot in Grok Botcalendar and email:read-only iPhone Apple Health Forma Sync CloudflareWorker + D1 Dashboard password-protected POST /api/ingest/mealsbearer POST /api/ingest/healthbearer How the data gets there You chat with the Forma bot in Grok Bot, which posts meals to a Cloudflare Worker with D1. Forma Sync posts Apple Health data to the same Worker. The password-protected dashboard reads from there. Calendar and email, if connected, reach the bot as read-only. How the data gets there You, in chat photo, menu or text iPhoneApple Health Forma Sync Forma bot in Grok Botcalendar and email:read-only CloudflareWorker + D1 POST /api/ingest/mealsbearerPOST /api/ingest/healthbearer Dashboard password-protected
Apple Health arrives through Forma Sync, meals through the bot in Grok Bot. Both end up in the Cloudflare Worker and D1, and the password-protected dashboard reads from there.

What Forma is

Forma is a private nutrition and training coach. You talk to it in chat, in Italian or in the language you choose in the first conversation.

It keeps your meal diary. You can send a photo of the plate, a menu, a receipt, or describe what you ate. Forma estimates calories, protein, fat, carbs and fiber, and marks those numbers as estimates. If you correct a meal, it updates the existing entry, without creating a second one.

Logging a meal You send a photo, a menu or a description. Forma estimates calories, macros and fiber, marks the numbers as an estimate, writes them to the diary and the dashboard updates. If you correct the meal, it updates the same entry, without creating a second one. Logging a meal You send a photo,a menu or adescription Forma estimateskcal, macrosand fiber marked as estimate Writes to the diary The dashboardupdates If you correct it,it updates thesame entry no duplicate Logging a meal You send a photo, a menu or a description. Forma estimates calories, macros and fiber, marks the numbers as an estimate, writes them to the diary and the dashboard updates. If you correct the meal, it updates the same entry, without creating a second one. Logging a meal You send a photo,a menu or adescription Forma estimateskcal, macrosand fiber marked as estimate Writes to the diary The dashboardupdates If you correct it,it updates thesame entry no duplicate
If you correct a meal that's already logged, Forma updates the same entry, without creating a second one.

It prepares meal plans and a shopping list, with a budget you give it. It suggests workouts that fit your calendar. You can turn on meal reminders: they stay paused until you ask. For plans and decision records it can use a knowledge base of your choice.

Daily targets are dynamic. When the dashboard and the sync app are connected, the day’s calories follow energy expenditure measured by Apple Health. You set protein, fat, carbs and fiber yourself, or Forma calculates provisional values, for a professional to confirm. Starting references, as an example and not a prescription, are about 1.6-2 g of protein per kilogram of body weight, fat at 25-30% of calories, and 30 g of fiber.

An example day, 2,400 kcal A synthetic example: 2,400 kcal from Apple Health energy expenditure, split into 150 g of protein (600 kcal, you set this), fat at 25% (67 g, 600 kcal, within the 25-30% range) and carbs for the remainder (300 g, 1,200 kcal). Fiber is a separate 30 g target. This is not advice, and these are not real targets. An example day, 2,400 kcal EXAMPLE Protein, 150 g 600 kcal · you set this Fat, 67 g 600 kcal · 25%, within 25-30% Carbs, 300 g 1,200 kcal · the remainder 2,400 kcal · Apple Health energy expenditure Fiber: 30 g, a separate target, not a slice of the calories An example day, 2,400 kcal A synthetic example: 2,400 kcal from Apple Health energy expenditure, split into 150 g of protein (600 kcal, you set this), fat at 25% (67 g, 600 kcal, within the 25-30% range) and carbs for the remainder (300 g, 1,200 kcal). Fiber is a separate 30 g target. This is not advice, and these are not real targets. An example day, 2,400 kcal EXAMPLE 2,400 kcal Apple Health energy expenditure Protein, 150 g 600 kcal · you set this Fat, 67 g 600 kcal · 25%, within 25-30% Carbs, 300 g 1,200 kcal · the remainder Fiber: 30 g,a separate target, not a slice of the calories
An example day of 2,400 kcal. This is not advice, and these are not my targets: you set protein, fat is at 25% (within the 25-30% range), carbs fill the remainder, and fiber is a separate 30 g target.

How to get started

The bot template is installed from Grok Bot: Forma on Grok Bot.

In the first conversation Forma walks you through, one question at a time:

  1. What you want to call it, and which language it should write in.
  2. Your profile: date of birth, height, weight, goal.
  3. Dietary constraints and, if you have one, a nutritionist’s plan.
  4. Training, any physical limits, and whether you use an app like Hevy.
  5. Supplements.
  6. Usual meal times.
  7. Where you shop, the budget, and for how many people.
  8. A knowledge base, if you want to use one.
  9. Your calendar, read-only.
  10. Your email, also read-only.

Then it saves the profile, calculates provisional targets and creates the reminder routines, leaving them paused. The diary starts with the first meal you send.

When the dashboard is ready, you give it the site address and save INGEST_SECRET as a bot secret, never in the chat text.

Setting up Forma The six steps: install the bot template, go through the first conversation (ten questions), deploy the dashboard on Cloudflare, build Forma Sync in Xcode, connect with INGEST_SECRET, do the first sync. Setting up Forma 1 Install thebot template 2 First conversation(10 questions) 3 Deploy thedashboard onCloudflare 4 Build Forma Syncin Xcode 5 Connect withINGEST_SECRET 6 First sync Setting up Forma The six steps: install the bot template, go through the first conversation (ten questions), deploy the dashboard on Cloudflare, build Forma Sync in Xcode, connect with INGEST_SECRET, do the first sync. Setting up Forma 1 Install thebot template 2 First conversation(10 questions) 3 Deploy thedashboard onCloudflare 4 Build Forma Syncin Xcode 5 Connect withINGEST_SECRET 6 First sync
The six steps, from installing the bot to the first sync.

The dashboard on your Cloudflare

The diary and Health data live on a site of yours, served by a Cloudflare Worker with a D1 database in your account. The template is public, with no medical records or credentials: forma-dashboard-template. Access is password-protected.

You need a Cloudflare account with Workers and D1, Node.js 20 or later (the README recommends 22.13+, and that’s the version required for the included SQLite tests), npm and Git. Python is not required.

The commands, as in the template README:

npm install
npx wrangler login
npx wrangler d1 create forma-health
cp wrangler.example.toml wrangler.toml

You copy the database_id printed by d1 create into wrangler.toml, choose a Worker name that belongs to you, and align database_name. Then you create the empty schema and set the three secrets, each at its own prompt, without putting them in the TOML file or in the code:

npm run db:migrate:remote
npx wrangler secret put SITE_PASSWORD
npx wrangler secret put SESSION_KEY
npx wrangler secret put INGEST_SECRET

For SESSION_KEY and INGEST_SECRET the README suggests, as an example, openssl rand -base64 48. Keep the values in your password manager. Then:

npm run deploy

The default address is https://<name>.<your-subdomain>.workers.dev. If you want your own domain, uncomment the routes block at the top of wrangler.toml and replace dash.example.com with your domain: the DNS zone must belong to your account. Alternatively, add the domain from Workers → Settings → Domains & Routes, and deploy again.

On a phone the same interface reads as a single column, like the iPhone screenshots below.

The screenshots below are my dashboard at forma.jaack.me. They’re real data, used as a visual reference. The template reproduces the same interface, empty, on your account.

Dashboard: Oggi view and meal diary, on iPhone
On the left, the Oggi view; on the right, the meal diary, on forma.jaack.me.

Details, tests with synthetic data and optional variables are in the template README. If this page and the README disagree, the README wins.

Forma Sync, the iPhone app

To send Apple Health data to the dashboard there’s Forma Sync. You build it yourself on a Mac with Xcode and install it on the phone, without TestFlight. The code is public: forma-sync. The full guide is in docs/INSTALL-XCODE.md.

You need a Mac with Xcode, an iPhone running iOS 17 or later, an Apple ID (a free one is fine), Homebrew, and a dashboard that’s already working. Then, from Terminal:

brew install xcodegen
git clone https://github.com/iJaack/forma-sync.git
cd forma-sync
cp Config/Local.xcconfig.example Config/Local.xcconfig

In Config/Local.xcconfig you enter your Team ID and a unique bundle ID, for example com.yourname.formasync. That file stays on your Mac and Git ignores it. Then:

xcodegen generate
open FormaSync.xcodeproj

In Xcode you choose the FormaSync scheme and your iPhone, check signing in Signing & Capabilities, and leave Automatically manage signing on. On the phone you turn on Developer Mode (Settings → Privacy & Security) and, if iOS asks, trust the developer in Settings → General → VPN & Device Management. Press ▶, open the app and allow access to Health. Forma Sync only reads: it does not write to Apple Health.

With a free Apple ID (Personal Team) the development profile expires after 7 days. The app stops opening and no longer syncs, until you reconnect the iPhone and press ▶ in Xcode again, with the same team and the same bundle ID. With the Apple Developer Program the profile lasts a year.

Free Apple ID, every 7 days With a free Apple ID the development profile expires after 7 days. The app stops opening and no longer syncs, until you reconnect the iPhone and press Run in Xcode again, with the same team and the same bundle ID. Free Apple ID, every 7 days You buildand install Reconnect the iPhoneand press ▶ Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 Day 7 expires Same team and same bundle ID Free Apple ID, every 7 days With a free Apple ID the development profile expires after 7 days. The app stops opening and no longer syncs, until you reconnect the iPhone and press Run in Xcode again, with the same team and the same bundle ID. Free Apple ID, every 7 days You buildand install Day 1 Day 2 Day 3 Day 4 Day 5 Day 6 Day 7, expires Reconnect the iPhoneand press ▶ Same team and same bundle ID
With a free Apple ID the profile expires on day 7: reconnect the iPhone and press ▶ in Xcode, with the same team and the same bundle ID.

To connect the dashboard, in the app go to Configura connessione. You can paste or scan a QR with this JSON, replacing the placeholders locally and without sharing the file:

{
  "url": "https://<your-site>/api/ingest/health",
  "client_id": "unused",
  "client_secret": "unused",
  "bearer": "<INGEST_SECRET>"
}

url must use https. If you only give the site root, the app appends /api/ingest/health. bearer is the same INGEST_SECRET set on the Worker, without the brackets. client_id and client_secret must be present: unused is fine when the dashboard only asks for the bearer.

After saving, press Prova connessione. Then, with the iPhone unlocked and the app open, press Sincronizza ora and check recent days on your dashboard, after logging in. Sleep, HRV and resting heart rate come from Apple Health and show up in the Recupero chapter.

Over time the dashboard also fills the Direzione chapter: weight, average balance and training consistency.

Dashboard: Recupero and Direzione chapters, on iPhone
On the left, the Recupero chapter, after Apple Health data; on the right, the Direzione chapter.

Don’t use online QR generators: the configuration contains a secret. The commands to create the QR locally, and the most common error cases, are in the install guide.

Privacy, and a note

Health data and the meal diary stay in your Cloudflare account. The dashboard template contains no medical records, meal history or credentials. It has no analytics, no export to third parties, and no external fonts.

The bot does not send messages, publish or trigger anything on its own. The calendar, if you connect it, is read-only. Email, if you connect it, is also read-only.

Forma is not a doctor. Meal estimates and provisional targets are there to keep you organized. Decisions about diet, supplements and training stay yours, and it’s worth having a professional confirm them.

The screenshots in this guide come from forma.jaack.me, my instance, and are only there to show the interface. The site is password-protected: it is not a shared service you can sign up for.

Short questions

Do I need my own domain? No. You can use the workers.dev address Cloudflare assigns you.

Do I have to pay Apple to install the app? No. With a free Apple ID the app installs from Xcode. The limit is the profile expiring after 7 days, and at most three apps with free provisioning on the device.

Is TestFlight required? No. You build the app from Xcode and install it on your iPhone.

Can I correct a meal that’s already logged? Yes. Tell Forma: it updates the existing entry, it doesn’t create a second one.

Do the reminders arrive on their own? No. They stay paused until you turn them on.

Where are the technical details? In the dashboard template README and in Forma Sync’s docs/INSTALL-XCODE.md. For the format the bot uses to write meals, there’s also docs/forma-agent.md.

The starting point is the bot template, together with those two repositories. If something looks off after install, start there.

Giacomo Barbieri

Giacomo Barbieri

DevRel at Team1, working with builders across Avalanche. Independent builder of native apps and AI systems. Former Head of Growth at Routescan.DevRel in Team1, al fianco dei builder su Avalanche. Sviluppo app native e sistemi AI indipendenti. In precedenza Head of Growth in Routescan.

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google pinterest medium vimeo stackoverflow reddit quora quora