Skip to content
AtMyApp Docs
Go to AtMyApp
Open with AI

Schema Model

The canonical schema model lives in @atmyapp/structure and is re-exported from @atmyapp/core.

Use schemas to describe what clients can edit, what data your app can read, and what the platform should validate before publishing.

AtMyApp supports two main content definition shapes:

  • defineCollection() for repeatable content such as posts, authors, products, or case studies.
  • defineDocument() for singletons such as home page copy, navigation, settings, or SEO defaults.
import {
defineCollection,
defineDocument,
defineSchema,
s,
} from "@atmyapp/structure";
export default defineSchema({
definitions: {
posts: defineCollection({
fields: {
title: s.string({ min: 3 }),
slug: s.slug({ source: "title" }),
cover: s.image({ optional: true }),
publishedAt: s.date({ optional: true }),
},
}),
settings: defineDocument({
fields: {
theme: s.string({ default: "light" }),
supportEmail: s.string({ format: "email" }),
},
}),
},
});

Fields describe validation, editor behavior, and generated platform payloads. Common field types include strings, dates, images, objects, and references.

The CLI finds atmyapp.schema.*, validates it, compiles it with @atmyapp/structure, writes normalized canonical JSON to .ama/definitions.json, and uploads that same contract during atmyapp migrate. The platform stores it as .structure.json; legacy input is converted at the compatibility boundary. Schema changes belong to the website repository and CLI workflow.

  • @atmyapp/structure owns schema authoring, compilation, validation, and introspection.
  • @atmyapp/core owns runtime client access and re-exports schema helpers.
  • @atmyapp/cli connects local schemas to the hosted AtMyApp platform.
  • @atmyapp/astro provides Astro-specific helpers.

Follow schema design for a full model, field types for every option, and JavaScript setup to render content. A schema defines editable data; your website code defines its presentation.