Generative UI in a health app: how much should the model decide?
We built VitalLoop, a health tracker whose screens arrive from Gemini as A2UI JSON and draw themselves in Flutter while they are still being written. Here is how it works, and where we put the limits.
VitalLoop in 60 seconds
VitalLoop is an open-source (Apache 2.0) demo health tracker from OakTree Apps. Its tracking screens are not pre-built in Dart. A Python agent gives Gemini a screen template for each step, Gemini replies in A2UI 1.0 JSON, and the Flutter app renders it with a2ui_flutter as the JSON streams in. Google’s A2UI 1.0 announcement lists it among the partner demos.
What you can log. Pain, symptoms, vitals, medications and food, followed by a daily summary with care nearby and a PDF report.
The components. 28 in total: 18 from the A2UI basic catalog and 10 written for this app.
The stack. Flutter, a2ui_flutter and a2ui_core, Python with Google’s Agent Development Kit (ADK), the A2A protocol, Gemini and Cloud Run.
Our rule. People design the screens, the model writes the content that changes, and Dart code assigns every status label on a vital sign.
VitalLoop is a demo. It is not medical software and it gives no medical advice.
Watch a pain check-in build itself
We recorded this against the live demo on 5 December 2026. The app is on the left. On the right is the wire inspector, which lists every A2UI message as it arrives.
What is A2UI?
A2UI is an open-source generative UI framework that lets an AI agent describe a user interface as data. The agent sends declarative JSON that names components your app already supports, and your app draws them with its own widgets. The agent does not send code for your app to run. The project is published under Apache 2.0 at a2ui.org.
Google announced A2UI 1.0 on 11 November 2026. The release made the protocol stable and added function calls in both directions, accessibility support and extensions for extra metadata. VitalLoop uses three of its core messages:
| A2UI message | What it does |
|---|---|
createSurface | Opens a new screen area and names the component catalog it uses. |
updateDataModel | Sets the values that components are bound to. |
updateComponents | Sends the components themselves, linked to each other by ID. |
Why try generative UI on a health tracker?
A health check-in changes with what you report. Lower back pain calls for a body map and a severity scale. A blood pressure reading calls for two rulers and a status label. A symptom list works better when it can change.
In VitalLoop each flow is a folder of JSON templates and a prompt on the server. The server reads them on every request, so we can reword a question or reorder a step without shipping a new app build, as long as the app already has the components.
Health software also has little room for surprises. A form that rearranges itself, a reading labelled one way today and another tomorrow, or a clinic that does not exist would each cost a user’s trust. So we built what we call template-guided generative UI: people write each screen as an A2UI template, and the model fills it in, writes the parts marked for it and streams the result.
What you can log in VitalLoop
| Flow | What you log or get | Custom components |
|---|---|---|
| Pain | Where it hurts, how much, when it started, notes | BodyMapPicker, SeverityInput |
| Symptoms | Symptoms from a list Gemini suggests, severity, notes | SeverityInput |
| Vitals | Blood pressure, heart rate, temperature, blood sugar | One input card for each reading |
| Medications | Medicine suggestions, dose and schedule | Mostly the basic catalog |
| Food | Meal type, items, serving size, meal time | IconBadge |
| Daily summary | Today’s entries, an overview written for your doctor, care nearby, a PDF to share | CareMap, CareList, PdfReport |
Finding care nearby
The daily summary can look for hospitals, clinics and doctors. You type a city or area, so the app never asks for your device location. What you logged that day decides the kinds of care it searches for: knee pain points to orthopedic clinics, while a very high blood pressure or a high fever puts emergency rooms first.
- The server finds the city’s centre with OpenStreetMap.
- Gemini searches with Grounding with Google Maps, on the same API key. There is no separate Maps key to set up.
- Gemini picks places and gives a short reason for each one.
- The map and the list share one value in the data model, so picking a place in the list also marks it on the map.
- The place you pick appears on the report screen. It is not written into the PDF.
CareMap pins each place and CareList shows the rating, the reason for the suggestion and the address. Map data © OpenStreetMap contributors.Listings come from Google Maps through Gemini and are not recommendations by OakTree Apps. A search can return an incomplete list or none at all. Call ahead, and in an emergency call your local emergency number.
How a screen gets made
- You tap a flow. The app sends a start message to that flow’s agent over A2A. Each flow has its own address, such as
/pain. - The agent briefs Gemini. It sends the flow’s instructions, the current time and the flow’s screen templates.
- Gemini writes the screen. It replies with the A2UI messages for that step, filling
{{placeholders}}with your earlier answers. - The app draws it as it arrives. a2ui_core processes each message and a2ui_flutter renders Flutter widgets.
- Your tap goes back as an action. The button sends its action name and the values bound to it, and the agent answers with the template mapped to that action.
Here is part of the first pain screen, abridged from the repository:
{
"version": "1.0",
"updateComponents": {
"surfaceId": "pain_step_1_body_area",
"components": [
{ "id": "map_card", "component": "Card", "child": "body_map" },
{ "id": "body_map", "component": "BodyMapPicker",
"value": { "@path": "/bodyAreas" } },
{ "id": "next", "component": "Button", "variant": "primary",
"child": "next_content",
"action": { "event": {
"name": "bodyAreasSelected",
"context": { "bodyAreas": { "@path": "/bodyAreas" } } } } }
]
}
}
@path binds a component to a value in the data model on the device. The picker writes your selection to /bodyAreas, and the button sends it only when you tap.
Where we want fresh content, the template says so. This is from the medication flow:
"options": {
"$ai": "6 common medicines people log at home ... Generic names only,
no doses. Pick a different, varied set each time.",
"example": [ { "label": "Paracetamol", "value": "Paracetamol" } ]
}
$ai is our own template convention and is not part of the A2UI specification. The example doubles as a fallback: if Gemini leaves a marked part unfilled, the server uses the example so the screen still works.
Streaming: the screen fills from the top down
Waiting for the complete JSON reply would leave the phone blank longer than needed. Our server reads the reply while Gemini is still writing it and forwards only what is safe to draw:
- It sends
createSurfacetogether with the first visible content, so you do not see an empty surface. - It sends only complete components that can be reached from the root.
- It cuts each container’s list of children at the first unfinished one, so no component points at something the app does not have yet.
- When Gemini finishes, it parses the whole reply and sends the final screen. If the JSON is broken, it asks once more.
In that run the first components reached the app about 8 seconds after the tap, and the surface then grew from 3 to 13 components in about 1.6 seconds. This is a single observation, not a benchmark. It does show that streaming helps once the model starts writing, and that you still need a good loading state before then.
What the model decides, and what it does not
| Part of the screen | Who decides | How |
|---|---|---|
| Components and their order | People | Templates in server/flows/, which Gemini is instructed to keep unchanged |
| Suggested symptoms and medicines, summary text | Gemini | Generated for each request |
| How a component looks and behaves | Flutter | Widgets in the app’s catalog |
| Status label on a vital sign | Dart code | Fixed ranges in lib/models/vitals/ |
| What you picked or typed | You | Held in the data model, sent when you tap a button |
| Clinics and hospitals listed | Google Maps, checked by the server | Places the search did not return are dropped |
Status labels stay in code
The blood pressure chip is not a model opinion. It is a plain Dart function, shortened here:
if (systolic < 90 || diastolic < 60) return 'Low';
if (systolic >= 140 || diastolic >= 90) return 'High · stage 2';
if (systolic >= 130 || diastolic >= 80) return 'High · stage 1';
if (systolic >= 120) return 'Elevated';
return 'Normal';
The ranges roughly follow the adult categories used by heart associations. In a demo they are a guide, not a diagnosis.
Places have to be real
For care nearby, Gemini calls a search tool that uses Grounding with Google Maps. In the screen it returns only an ID and a short reason for each place it picks. The server adds the name, address and position from the search results and drops any ID the search never returned, so an invented hospital cannot enter the place list.
The catalog is the contract
An A2UI catalog is the set of components and functions an app can render. Each component has a JSON schema for the properties it accepts. If a screen names something outside the catalog, the app has nothing to draw it with. These are the 10 we wrote:
| Component | What it is |
|---|---|
BodyMapPicker | Front and back body figure with tappable regions |
SeverityInput | 1 to 10 severity scale |
BloodPressureInput | Systolic and diastolic rulers with a status label |
HeartRateInput | Heart rate with an ECG-style trace and tap-your-pulse |
TemperatureInput | Thermometer slider with °C and °F |
BloodSugarInput | Glucose band with mg/dL and mmol/L |
IconBadge | Coloured icon used in rows and headers |
CareMap | Map of nearby care |
CareList | List of nearby care, with the reason for each |
PdfReport | The daily report as a PDF to share or print |
BloodPressureInput in the catalog site, which shows every component with a live preview, its JSON and its schema. Browsing it needs no API key.What we learned building it
1. Set exact values in code
Gemini sometimes shortened our catalog ID. A2UI 1.0 has no fallback catalog, so the app could not draw a screen carrying an ID it did not know. The server now writes the correct ID onto every createSurface itself.
2. “Keep this unchanged” is a request to the model
We ask Gemini to keep template text and layout as written, yet it still rewrites the whole screen on each step. For a production health product we would assemble the fixed parts in code and ask the model only for the parts that need generating, as we already do for place details.
3. Design the wait
Streaming cannot start before the model does. A screen needs a clear loading state, and an error path that tells the user what happened.
4. Pin versions and read the spec changes
On 11 November 2026 the A2UI specification renamed a button’s validation key from checks to @checks. The a2ui_core release we use does not read the new name yet, so our templates still say checks.
5. Leave the API key with its owner
The public demo uses your Gemini key, not ours. The browser keeps it for the tab’s session, it travels in a request header over HTTPS, and the server does not save it. A per-address rate limit protects the service.
A2UI, A2A, AG-UI and MCP Apps: which does what?
The names look alike and they solve different problems. You can combine them.
| Name | What it handles | In VitalLoop? |
|---|---|---|
| A2UI | Describes an interface as declarative data | Yes, version 1.0 |
| A2A | Lets agents and applications communicate. Started at Google and now under the Linux Foundation | Yes, carries the messages |
| AG-UI | Event protocol between an agent and a front end, and a documented transport for A2UI | No |
| MCP Apps | Lets an MCP server show its own HTML interface inside a host application, in a sandbox | No |
Run VitalLoop on your machine
You need Flutter 3.41 or newer, Python 3.11 or newer and a Gemini API key. Start the server first:
git clone https://github.com/oaktreeapps/vital-loop.git
cd vital-loop/server
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/python main.py
Then, in a second terminal:
cd vital-loop/client
flutter pub get
flutter run
The app asks for your key when it opens. The client and server test suites run offline, with no key.
Frequently asked questions
What is A2UI?
A2UI is an open-source generative UI framework under Apache 2.0. An AI agent describes an interface as declarative JSON that names components from a catalog, and the receiving app draws those components with its own widgets. Google announced version 1.0 on 11 November 2026.
What is VitalLoop?
VitalLoop is an open-source demo health tracker built by OakTree Apps with Flutter, A2UI 1.0, Google’s Agent Development Kit and Gemini. It logs pain, symptoms, vitals, medications and food, then writes a daily summary. It is listed among the partner demos in Google’s A2UI 1.0 announcement.
Does Gemini design the screens in VitalLoop?
No. People write each screen as an A2UI template. Gemini fills in earlier answers, writes the parts that are meant to change, such as suggestion lists and the daily summary, and streams the finished screen back.
How do you render A2UI in a Flutter app?
Add the a2ui_flutter and a2ui_core packages, define a catalog of the components your app supports, feed the agent’s messages into a2ui_core’s MessageProcessor and render the resulting surfaces. Button taps come back from the processor as actions that you send to your agent.
Is generative UI safe to use in a health app?
It depends on what the model is allowed to control. Keep clinical rules in tested code, restrict the model to a fixed component catalog, verify any real-world facts on the server and treat prompt instructions as guidance that still needs checking. A real product also needs clinical, privacy and regulatory review.
Is VitalLoop HIPAA compliant or medical software?
No. VitalLoop is a demo with no compliance claim. What you enter is sent to the Gemini API to build the next screen, and the city you type for care nearby is also sent to OpenStreetMap, so do not enter real patient information.
Do I need an API key to try it?
You need your own Gemini API key to run the flows, which you can create in Google AI Studio. The How it works page and the component catalog open without a key.
Thinking about generative UI for your product?
We build Flutter apps and the agent back ends behind them. Bring us a flow that changes often, and we will map out what a model should and should not touch.
- Google Developers Blog: A2UI 1.0 announcement, 11 November 2026.
- A2UI protocol specification, version 1.0.
- A2UI independent consultancy directory, which lists OakTree Apps and VitalLoop.
- VitalLoop source code on GitHub.
- a2ui_flutter and a2ui_core on pub.dev.
- Agent Development Kit documentation.
The A2UI project states that it does not endorse, rank or certify the companies in its directory. VitalLoop’s body map is adapted from the Daily Health Tracker project (Apache 2.0).
