Skip to content

Mantle Cloud starting examples ​

Read this before calling create_site. Match the user's work to a row, then pass the name as preset. The first commit already contains the matching Mantle files. Read and extend that repository. For an existing site, reuse it. For an application with a supplied custom Manifest, pass manifest by itself.

PresetWorkflowTypical uses
recipesRecipe site: English and Traditional Chinese editions, reviewed revisions with preview, switch and rollback, cover images, and a save button for members.publishing, content, translations
intakeMembers submit requests; staff triage (assign, priority by category), work and resolve or reject them.support desks, applications, internal requests
reservationStaff open slots; members request seats (waitlisted when full); staff confirm or decline; members cancel their own.appointments, classes, room and equipment booking
transactionCatalog and orders: placing an order takes stock; staff mark paid, ship and complete, or refund; members cancel unpaid orders.member ordering, order intake, fulfilment
procurementPurchase requests against department budgets: small ones approved at once, large ones wait for an admin; every approval spends the budget.purchase approvals, budget control, internal ordering

Omitting both preset and manifest starts Recipes. A supplied manifest gets Admin, the generated API and a landing page, unless it is exactly a preset's Manifest, which gets that preset's files.

Recipes includes the complete public site and Admin revision workflow below. Intake, Reservation, Transaction and Procurement share the Builder's workflow Manifests and seed Admin, the generated API and a landing page. Add visitor pages in the seeded repository when needed.

The Cloud examples start on @aotter/mantle@0.2.3-alpha.4. The OSS sources and design guides are the SDK examples, Recipes, generated web() and content revisions. For existing projects, use the docs and examples packaged with their installed SDK version.

Recipes ​

Choose this preset for editorial content, localized public pages, cover images, and changes that need review before going live. This example uses Mantle's manifest, generated Views and Procedures, Admin, and Cloud Media. Keep those in place while adapting the fields and styling.

  1. In /admin, create a Recipe with a slug and language. Choose New revision from its entry, then fill title, summary, ingredients and steps in the nested Recipe revisions collection (one item or step per line). For a cover, use the site's Media Library with purpose cover and paste the committed public HTTPS URL in cover_url. JPEG, PNG and WebP are capped at 5 MB. The MCP equivalent is upload_media with purpose cover through the site's tools; discover the host-supported upload flow before trying to send bytes.
  2. In the recipe workspace open Preview and switch revisions, select the revision and choose Preview selected revision, then Switch to reviewed revision. The preview uses the authenticated Admin API and freezes both versions for that switch. Publish the parent to make /recipes/<locale>/<slug> public.
  3. Choose New revision again to copy the live one. Edit and preview the copy. The public URL still shows the previously selected content. Switch after reviewing to publish the edit at the same URL. Switch to an earlier sealed revision to roll back. For a translation, create a Recipe with the same slug and the other locale and follow the same flow.

manifests/site.yaml owns the data, public Views and editor operations. src/handlers.ts makes the version-checked switch atomic. src/routes.tsx renders the pages with React and the kit (src/recipes.tsx, through page()) and uses generated web() for canonical and Markdown links, /llms.txt, /sitemap.xml and Markdown alternates. Recipe pages add JSON-LD and links to published language editions. Signed-in members save a recipe with the button on its page (src/client/client.tsx, PUT /api/saved-recipes/{recipe}), or ask their AI to, through the site's MCP tools. The Admin preview is outside the public index. src/site-config.ts defines the upload policy. For how public pages and their caching work, read mantle help public-pages and mantle help caching.

Who may do what ​

This site lets every editor change every recipe. A business app usually splits the work. In a shop, for example: auditors only read, staff edit products and orders for their own brands, and an owner approves prices. Express it with three Mantle tools:

  • Which operations: authorize(target, caller) in src/service.ts. Check caller.kind first (staff are host, members user), then caller.roles against target.kind and target.name. On Cloud, Mantle Access gives the roles: maintainer or viewer per person or per team (change_access setSite), and owner with full access. authorize can read only roles and the user fields that some scope or restrict term names or a kind: UserField manifest declares; any other attribute never reaches the site.
  • Which rows: scope: "brand IN auth.user('brands')" on the Schema; restrict: { products: "brand IN auth.user('manageBrands') OR auth.user('allBrands')" } on a Procedure. The bare auth.user('allBrands') term makes allBrands a true-or-false field. Give values per person or per team with change_access setAttributes, where "*" means all: every brand for brands, true for allBrands. Never give "*" for manageBrands: a restrict never accepts "every value", so that caller is refused (AUTH_DENIED); give allBrands "*" instead. Owners (full access) get every brand without any of these.
  • No approving your own change: UPDATE price_changes SET state = 'approved' WHERE id = input.id AND author_id <> auth.uid(). Keep the create Procedure staff-only (requires: { auth: { all: [ctx.admin] } }): a staff member's auth.uid() is host:<id>, the same person's as a member <id>.

Create rows in a field-scoped Schema with a Procedure INSERT … VALUES: leave the scope column out when the caller has one value, or set it from an input of the column's type (or a matching literal) inside the caller's set. Only system callers may run INSERT … SELECT into a field-scoped Schema or one that writes a reference to a scoped Schema, or any insert into a field-scoped Schema the Procedure restricts; without a field scope, an insert under an IN or OR restrict fails at generation. For those rows use a ref handler that inserts through ctx.store. ctx.store applies the Schema scope but not the Procedure's restrict (a ref handler cannot have one), so the handler enforces the row rule itself. For the example above: allow owner in caller.roles; otherwise allow allBrands when it is true, or require the row's brand in manageBrands. A list field given "*" arrives as { all: true }. Only fields some scope or restrict names, or a kind: UserField manifest declares, are available. Keep these rules in the manifest, authorize and handlers, not in database triggers or functions in migrations/. Details: node_modules/@aotter/mantle/docs/handbook/reference/authorization.md.

Run the generated repo's npm run generate, npm run check, npm run build and npm test before pushing changes.