Implemented system · v0.8.0 · 99/99 tests · open source

The ready system for patients to follow the plan

The patient care system of a nutrition practice, ready to run in your own environment: in-person and online scheduling with confirmation and follow-up, a meal plan with versions, a diary for meals, water and weight, opt-in reminders, a patient chat and a Telegram team desk. The bot never prescribes. Implemented on 19/10/2026: v0.8.0, 99 of 99 tests passing and the independent verification with Docker approved.

Atende Nutrição banner: in-person and online scheduling, meal plan, diary, opt-in reminders and a Telegram team desk
Video

Watch the explainer

The project explained in a few minutes.

What it is

An open system, built from the contract to 99 green tests

The repository ships the ready app (server, patient chat at /, team page at /equipe, Evolution, Telegram and Docker) together with the contract that defined it, the test suite that proves it and the guardrails that stopped the agent from cheating. It was built by an agent on a subscription, in a long run, up to 99 of 99 tests. Its sibling Atende Clínica, which it is based on, was built the same way and closed 93 of 93.

In-person and online scheduling, versioned meal plan, diary of meals, water and weight, opt-in reminders, 192 and 188 alerts, health-data privacy and a Telegram team desk

🥗 The system

Scheduling for first visits and follow-ups, in person or online (the team supplies the link), with no double booking. A meal plan entered by the nutritionist, with versions, and a bot that answers only what is in that patient's plan. Python 3 with the standard library only, plus SQLite, one practice per installation.

📦 The method, included

A 21-section specification, 99 black-box tests, 19 proposed decisions, a map to Raio-X, the /goal and headless-loop prompts used to build it, and the guardrails that froze the contract. Before the run, an adversarial validator fixed 10 problems in the plan, 1 of which would have blocked execution.

📈 Source: Raio-X de Margem

No-shows, follow-ups that never happen and idle slots are the leaks that scheduling attacks. The system returns atendimentos_mes, falta_pct, ocupacao_pct, clientes_novos_mes and retorno_atual_pct for the Raio-X de Margem dashboard, which is the source of the business rules.

🚨 Alerts in two lists

A physical sign (chest pain, fainting, vomiting that will not stop, hypoglycemia) is answered with 192 and the emergency room. Eating disorders and self-harm (binge eating, purging, laxatives, suicidal thoughts) are answered with 188 (CVV) and the nutritionist. Both open a high-priority queue entry, even while a human chat is open. 192 and 188/CVV are Brazilian emergency numbers: in another country, the practice must swap in its local emergency contacts.

🔒 Health-data privacy (LGPD)

The plan, diary and weight are sensitive data: a patient can export everything, and deletion erases it (it does not merely anonymize). "PARAR" (stop) blocks everything automatic. Campaigns need specific consent. LGPD is the Brazilian data protection law: in another country, the practice must apply its local health-data law.

⚠️ CFN rules: not researched yet

Raio-X researched the medical, dental and physiotherapy councils (CFM, CFO and COFFITO), not the nutritionists' council (CFN). The campaign guardrail is only the common minimum (promising results, before-and-after). The owner must confirm the CFN rules before publishing any campaign.

How it works

From "I want to book" to the everyday diary

This is the flow of the implemented system. A dependency-free Python server, SQLite in a data folder and Docker for the VPS. Evolution and Telegram come in only through environment variables; without them the outbox is simulated and no network call leaves the machine.

Site chat or WhatsApp (Evolution)→ Book: in person or online→ Confirmation 1/2 and waitlist→ Meal plan sent by the team→ Diary and opt-in reminders→ Scheduled follow-up and monthly numbers for Raio-X

Patient

Through the chat or WhatsApp the patient books, confirms with 1 or 2, asks for the online visit link, checks meu plano (my plan) or o que posso comer no lanche da tarde (what can I eat at the afternoon snack), logs 2 copos (2 glasses), pulei o almoço (I skipped lunch) or peso 82,5 (weight 82.5), gets FAQ answers, asks for a human and sends "PARAR" when they want no more messages. The bot's chat commands are in Portuguese.

Team on Telegram

Notices of new and cancelled bookings, and the commands /agenda, /alertas, /fila, /responder and /encerrar, also as a direct reply to the patient's message.

/equipe page

With a token: schedule, patients, meal plan, diary and adherence, weight series, FAQ, records, blocked time and the human queue.

Meal plan

Meals by time of day, with options and notes, in versions (the latest is the active one). The team reviews it and sends it to the patient. Outside the plan, "can I eat chocolate?" becomes "I don't advise outside the plan" and goes to a human. There is no nutrition calculation in v1.

Diary, weight and goals

Glasses of water against a goal, meals done or skipped, a meal photo (metadata only, no image is downloaded) and a weight series with the change. The reply to a weight is neutral and non-judgmental: the system never comments on progress.

Opt-in reminders

The team sets up, at the visit, reminders for water and for the plan's meals, at the times the patient chose. There is a tolerance window: a late reminder does not pile up. parar lembretes (stop reminders) turns off reminders only.

Prerequisites

What you need

To run it locally you only need Python 3.10+ (pytest only for the tests). Docker comes in for the independent verification and the deploy; Evolution and Telegram are optional and yours. An agent on your subscription is only needed if you want to redo or adapt the system with the method.

Python 3.10+ and pytest

The tests use pytest (a development tool). The application itself has no dependencies.

# check
python3 --version
python3 -m pip install pytest

Claude Code or Codex (optional)

Only to redo or adapt it with the method, on your subscription, no paid API. For the headless loop, clone execucao-longa into ~/projetos.

# check
codex --version   # or: claude --version

Docker, Evolution and Telegram

Docker does the final build and the VPS deploy. An Evolution instance and a Telegram bot are needed only if you want those channels; credentials live in .env.

# check
docker --version
User guide · step by step

From clone to a running system, in your own environment

The commands below are the ones in the repository. The cycle: clone and check the tests, configure the practice, run it locally, confirm with the verifications and publish on your VPS.

1

Clone the repository and check the tests

The system is already implemented (v0.8.0). Check that the whole suite passes on your machine.

git clone https://github.com/inematds/atende-nutricao && cd atende-nutricao
python3 -m pytest -q tests/ | tail -n 1                # 99 passed
./atende --help                                     # serve, raiox, backup, restaurar
2

Configure your practice

Copy the example into a data folder and edit it: replace TROQUE-ESTE-TOKEN with your own secret and adjust the practice, professionals, services, hours and FAQ. Professionals, services and FAQ seed the database only on the first run; after that they are changed through the API or the /equipe page. Also read docs/DECISOES-ABERTAS.md: 19 default proposals already applied; items marked ⚠ (campaign guardrail, alert words, weight rules) need the owner's confirmation, including the CFN question in the box below.

mkdir -p dados && cp exemplos/nutricao.json dados/nutricao.json
less docs/DECISOES-ABERTAS.md
3

Run it locally

Start the server. The patient chat is at / and the team page at /equipe (X-Token header). Without the Evolution and Telegram variables, WhatsApp uses a simulated outbox and no network call leaves the machine. ATENDE_AGORA fixes the clock for tests only.

./atende serve --porta 8080 --dados dados
# open http://127.0.0.1:8080/ and http://127.0.0.1:8080/equipe
4

Confirm with the verifications

The same ones that closed the implementation. The first checks the guardrails (contract and tests intact, only in-scope files, no external dependency, no key, no 0.0.0.0). The second, which the agent never saw, looks for fixture values copied into the code, starts a practice that never appeared before (20-min slots, 40-min visits, follow-up in 15 days, no online care, a meal plan with differently named meals, another clock) and runs docker build with a healthcheck.

bash longrun/2026-10-05-nutri-v1/verificar-limites.sh               # LIMITES OK at close; now flags only guia/ and README.en/es (docs added later)
python3 longrun/2026-10-05-nutri-v1/verificar-independente.py      # INDEPENDENTE OK
5

Deploy on your VPS

The deploy is yours, with your own credentials, on a VPS with Docker and Compose. The published port stays on 127.0.0.1:8080 only, behind your HTTPS proxy (forward /, /equipe, /api/ and /webhook/). The ./dados volume keeps the database and configuration; ./backups receives the backups.

umask 077 && cp .env.exemplo .env && mkdir -p dados backups
test -f dados/nutricao.json || cp exemplos/nutricao.json dados/nutricao.json
chmod 700 dados backups && chmod 600 .env dados/nutricao.json
docker compose up -d --build && docker compose ps

Integrations, only the ones you will use, in .env: Evolution (EVOLUTION_URL, EVOLUTION_API_KEY, EVOLUTION_INSTANCIA, WEBHOOK_SEGREDO; webhook at /webhook/evolution/<secret>, event MESSAGES_UPSERT) and Telegram (TELEGRAM_*; setWebhook to /webhook/telegram with secret_token). Schedule a call to POST /api/tarefas/rodar every minute (confirmations, follow-ups, reminders) and the daily backup in cron.

docker compose exec -T atende ./atende backup --dados /dados --saida /backups/estado.sqlite3

The full walkthrough (proxy, webhooks, tasks, backup and restore) is in the "VPS deployment" section of the README.

6

What depends on you

The code is ready; the rest belongs to the practice owner: the real Evolution (WhatsApp) and Telegram bot credentials, the deploy on the VPS, the real data (hours, services, FAQ, meal plans), confirming the alert words with the nutritionist, and the CFN rules before any campaign.

7

How it was built (and how to redo or adapt it)

The system was built with the long-run execution method: first the contract (docs/ESPECIFICACAO.md) and the 99 tests, then a hash freeze (congelar.sh), and then an agent on a subscription worked in cycles until 99 passed, LIMITES OK and INDEPENDENTE OK. Want to adapt it to another practice or change a rule marked ⚠? The method is still in the repository: edit the specification and the tests, freeze again and run the headless loop (loop-longrun.sh) or /goal in Claude Code or Codex, following the prompts in longrun/2026-10-05-nutri-v1/.

bash longrun/2026-10-05-nutri-v1/congelar.sh
~/projetos/execucao-longa/tools/loop-longrun.sh longrun/2026-10-05-nutri-v1

⚠️ Before publishing any campaign: the CFN

The advertising rules for nutritionists, set by the Brazilian Federal Council of Nutritionists (CFN), have not been researched in this project yet. The campaign guardrail (section 11 of the specification) is the minimum common to the medical, dental and physiotherapy councils: it blocks promessa_resultado (guaranteed, guaranteed result, 100%) and antes_depois (before and after). No CFN article is cited, on purpose. The practice owner confirms the CFN rules (price, promotions, testimonials, before and after) before publishing any campaign; if there is an extra rule, it enters as a new code and changes the contract (decision 4 in docs/DECISOES-ABERTAS.md).

What's in the kit

Contract, tests and guardrails, with the real numbers

Everything the agent used to build the system, and everything that stopped it from pretending it had. It stays in the repository so you can redo or adapt it.

99 acceptance tests

Black-box, over HTTP and the command line, in 11 files.

test_agenda.py                16
test_integracoes.py           15
test_conversa.py              13
test_cadastros.py             10
test_diario.py                10
test_lembretes.py              9
test_plano.py                  8
test_basico.py                 6
test_campanhas.py              5
test_docker.py                 4
test_lgpd_raiox.py             3

A 21-section specification

docs/ESPECIFICACAO.md: execution, nutricao.json, scheduling rules, authentication, HTTP API, conversation, waitlist, confirmation and reminders, meal plan, diary and weight, campaigns, export to Raio-X, LGPD, what stays out of v1, pages, records, schedule management, database, Evolution, Telegram and Docker. Nutrition calculation, photo analysis, payments, insurance billing and multiple practices are explicitly out.

Anti-shortcut guardrails

A frozen hash of tests/, pytest.ini, the specification and the two verifiers. File scope: the agent only touches the code and its own records. No external dependency, no API key, no external URL, no media download and no 0.0.0.0 in the code. verificar-limites.sh checks all of that and prints LIMITES OK.

Independent verification

Level 4, hidden from the agent: it looks for fixture values in the code, brings up a practice it has never seen, with every argument explicit, and runs docker build and a container healthcheck. Only that makes "99 passed" prove general logic.

19 decisions already proposed

Language, channels, the campaign guardrail, what the bot answers, alert signs, neutral weight replies, opt-in reminders, the meal plan, photos as metadata only, online visits, follow-ups, LGPD, Raio-X and one practice per installation. Only the items marked ⚠ change the contract.

Validated by an adversarial agent

A validator that had not seen the planning checked tests against the specification, redid the arithmetic and tried to get around the guardrails. It found and fixed 10 problems: 1 blocked execution, 6 got in the way and 3 were cosmetic. The full account is in docs/VALIDACAO.md and each fix has a line in FALHAS.md.

The business rules come from Raio-X

No-shows, follow-ups that never return and idle slots: docs/MAPA-RAIO-X.md links each leak in the clinica package to a v1 piece or to the reason it stays out. More in the Raio-X de Margem guide.

Brazilian rules built in

LGPD for health data (confirmation, follow-up, reminders and the plan as health care; campaigns only with consent; export and erase) and Brazil's emergency contacts: 192 and 188 (CVV). All of these are Brazilian: in another country, the practice must swap in its own emergency contacts and privacy law. The CFN rules are still to be confirmed, as in the notice box at the end of the user guide.

Roadmap

Where it stands and where it is going

Plan and implementation are done: the system was built on 19/10/2026 with the execucao-longa method, like Atende Clínica, which closed 93 of 93. The next step is a pilot in a real practice.

Plan ✅
Specification, tests and guardrails validatedA 21-section contract, 99 acceptance tests, proposed decisions, a map to Raio-X and an adversarial validation completed on 05/10/2026.
Build ✅
v0.8.0 deliveredBackend, patient chat at /, /equipe page, Evolution, Telegram, Docker and VPS instructions. 99 of 99 tests, LIMITES OK and INDEPENDENTE OK (with docker build and healthcheck) on 19/10/2026.
Pilot
In a real practiceSet up real hours, services, FAQ and meal plans, plug in the real Evolution and Telegram credentials, confirm the alert words and the CFN rules with the nutritionist, publish on the VPS and track no-shows, occupancy and follow-up in the Raio-X Recovery Dashboard.
Later
Outside v1Nutrition calculation, photo analysis, payments, insurance billing, multiple practices, an LLM in the replies and a UI in EN/ES are left for a later version, behind a human gate.