Files
ask-form/examples/data-model/spec.json
gabrielvidalandClaude Opus 5.5 ffce9e1fd6 feat(examples): mockup choices in the demo forms, a team-vote demo
New project (home screen), Code review (the invoice table on a phone) and
API keys (pricing page) each get a mockup choice, the same ones the landing
shows. /examples/team-vote is a multi-answer form with an optional email.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 11:10:15 +01:00

168 lines
5.9 KiB
JSON

{
"title": "Comments: the data model",
"order": 6,
"summary": "Design review: the schema drawn as a diagram, the endpoints in a table, then the open choices: threading, IDs, deletion, pagination.",
"description": "Comments on posts, with replies and reactions. Here is the schema and the API as I'd build them. A few choices are yours; my picks are pre-selected, with why.",
"fields": [
{
"type": "html",
"group": "The model",
"label": "Schema",
"html": "<svg viewBox=\"0 0 420 250\" xmlns=\"http://www.w3.org/2000/svg\" style=\"display:block;width:100%;max-width:560px;height:auto;margin:0 auto;font:12.5px ui-monospace,SFMono-Regular,Menlo,monospace\">\n<g fill=\"hsl(var(--card))\" stroke=\"hsl(var(--border))\"><rect x=\"6\" y=\"20\" width=\"118\" height=\"86\" rx=\"10\"/><rect x=\"6\" y=\"140\" width=\"118\" height=\"70\" rx=\"10\"/></g>\n<rect x=\"150\" y=\"6\" width=\"134\" height=\"238\" rx=\"10\" fill=\"hsl(var(--primary) / .08)\" stroke=\"hsl(var(--primary))\"/>\n<rect x=\"306\" y=\"40\" width=\"108\" height=\"98\" rx=\"10\" fill=\"hsl(var(--primary) / .08)\" stroke=\"hsl(var(--primary))\"/>\n<g font-weight=\"700\" fill=\"hsl(var(--foreground))\" font-family=\"system-ui,sans-serif\" font-size=\"14\"><text x=\"18\" y=\"42\">posts</text><text x=\"18\" y=\"162\">users</text><text x=\"162\" y=\"28\">comments</text><text x=\"318\" y=\"62\">reactions</text></g>\n<g fill=\"hsl(var(--muted-foreground))\">\n<text x=\"18\" y=\"64\">id</text><text x=\"18\" y=\"82\">author_id</text><text x=\"18\" y=\"100\">…</text>\n<text x=\"18\" y=\"184\">id</text><text x=\"18\" y=\"202\">name</text>\n<text x=\"162\" y=\"52\">id</text><text x=\"162\" y=\"72\">post_id</text><text x=\"162\" y=\"92\">parent_id</text><text x=\"162\" y=\"112\">author_id</text><text x=\"162\" y=\"132\">body</text><text x=\"162\" y=\"152\">created_at</text><text x=\"162\" y=\"172\">edited_at</text><text x=\"162\" y=\"192\">deleted_at</text><text x=\"162\" y=\"212\">reply_count</text>\n<text x=\"318\" y=\"84\">comment_id</text><text x=\"318\" y=\"104\">user_id</text><text x=\"318\" y=\"124\">emoji</text></g>\n<g fill=\"none\" stroke=\"hsl(var(--muted-foreground))\" stroke-width=\"1.4\"><path d=\"M124 60H136V68H150\"/><path d=\"M124 180H136V108H150\"/><path d=\"M284 48H296V80H306\"/><path d=\"M284 88C300 88 300 100 284 100\"/></g>\n<text x=\"210\" y=\"236\" fill=\"hsl(var(--muted-foreground))\" font-family=\"system-ui,sans-serif\" font-size=\"11\" text-anchor=\"middle\">parent_id → comments.id (a reply)</text>\n</svg>"
},
{
"type": "markdown",
"group": "The model",
"label": "Endpoints",
"text": "| Route | Does |\n|---|---|\n| `GET /posts/:id/comments` | list, newest first, paged |\n| `POST /posts/:id/comments` | add; `parent_id` for a reply |\n| `PATCH /comments/:id` | edit, author only |\n| `DELETE /comments/:id` | delete, author or post owner |\n| `PUT /comments/:id/reactions/:emoji` | toggle a reaction |"
},
{
"key": "threading",
"label": "How deep do replies go?",
"type": "radio",
"required": true,
"group": "The model",
"default": "one-level",
"help": "One level reads well on a phone and keeps the list a single query.",
"options": [
{
"value": "one-level",
"label": "One level",
"description": "Replies under a comment, no replies to replies (like Slack threads)"
},
{
"value": "tree",
"label": "A full tree",
"description": "Any depth (like Reddit); needs a recursive query"
},
{
"value": "flat",
"label": "No replies",
"description": "Drop parent_id"
}
]
},
{
"key": "ids",
"label": "ID type",
"type": "radio",
"required": true,
"group": "The model",
"default": "uuid7",
"options": [
{
"value": "uuid7",
"label": "UUID v7",
"description": "Sortable by time, safe to show in URLs"
},
{
"value": "serial",
"label": "Auto-increment integers",
"description": "What posts use today; leaks the comment count"
},
{
"value": "ulid",
"label": "ULID strings"
}
]
},
{
"key": "deletion",
"label": "What happens when someone deletes a comment?",
"type": "radio",
"required": true,
"group": "Behaviour",
"default": "soft",
"options": [
{
"value": "soft",
"label": "It shows “deleted”, replies stay",
"description": "Soft delete: the row keeps deleted_at, the body is wiped"
},
{
"value": "cascade",
"label": "It goes, with its replies"
},
{
"value": "orphan",
"label": "It goes, replies move up"
}
]
},
{
"key": "edit_window",
"label": "How long can a comment be edited? (minutes, 0 = always)",
"type": "number",
"group": "Behaviour",
"min": 0,
"step": 5,
"default": 15
},
{
"key": "reactions",
"label": "Which reactions?",
"type": "multiselect",
"group": "Behaviour",
"default": [
"👍",
"❤️",
"😂",
"🎉"
],
"options": [
"👍",
"❤️",
"😂",
"🎉",
"😮",
"👀"
]
},
{
"key": "notify",
"label": "Email the post's author about new comments (batched, at most hourly)",
"type": "checkbox",
"group": "Behaviour",
"default": true
},
{
"key": "pagination",
"label": "Paging the list",
"type": "radio",
"required": true,
"group": "API",
"default": "cursor",
"options": [
{
"value": "cursor",
"label": "Cursor",
"description": "`?after=<id>`: stable while new comments arrive"
},
{
"value": "offset",
"label": "Page numbers",
"description": "`?page=3`: can repeat or skip a comment"
}
]
},
{
"key": "json_case",
"label": "Field names in the JSON",
"type": "radio",
"group": "API",
"default": "camel",
"help": "The rest of your API uses camelCase.",
"options": [
{
"value": "camel",
"label": "camelCase (createdAt)"
},
{
"value": "snake",
"label": "snake_case (created_at)"
}
]
}
]
}