# RapidUI

> Agent-first platform for generating, validating, and storing RUIs — JSON documents that describe app screens, blocks, and data bindings. Not React code.

RapidUI v0.1 helps external agents produce **valid RUIs** via a validate → correct → save loop. Fetch the schema, author JSON, validate until `valid: true`, then persist with `POST /api/specs`.

## Instructions

- **Emit a RUI** (`.rui.json`) — never React, JSX, or component code
- **Read** `GET /api/schema` before authoring; use only v0.1 blocks (`Metric`, `Table`, `Text`) and read (`GET`) bindings
- **Validate** with `POST /api/validate`; fix every item in `errors[]` using `code`, `message`, and `hint`
- **Retry** until `valid: true`; use `normalizedRui` as the canonical validated artifact
- **Save** with `POST /api/specs` — returns **201** flat SavedSpec (`specId`, `url`, `viewUrl`, audit fields, `normalizedRui`); re-validates inline
- **Handoff (v0.1):** share **`viewUrl`** with the user for human block-tree review; use `url` for programmatic retrieve via `GET url`
- **Naming:** say **RUI** in prose; `/api/specs` is the HTTP resource for a stored RUI (a spec is a stored RUI)
- **Demo:** for the support dashboard eval, bind `GET /api/tickets` (table, `valuePath: "items"`) and `GET /api/tickets/stats` (metrics, scalar `valuePath` per field)
- **Reference:** compare against `examples.supportDashboard.goldenRui` in `GET /api/docs`

## Documentation

- [Agent documentation (JSON)](https://rapidui.dev/api/docs)
- [Vocabulary / schema](https://rapidui.dev/api/schema)

## API

- [POST /api/validate](https://rapidui.dev/api/validate) — validate a RUI; retry on `errors[]` until `valid: true`
- [POST /api/specs](https://rapidui.dev/api/specs) — persist validated RUI; returns **201** flat SavedSpec (`specId`, `url`, `viewUrl`, `normalizedRui`)
- [GET /api/specs/:id](https://rapidui.dev/api/specs/{specId}) — retrieve saved spec by `specId` (JSON)
- [GET /specs/:id](https://rapidui.dev/specs/{specId}) — human RUI inspector (type-colored block tree)
