# Structure SDK

> **Section:** [Reference](https://docs.atmyapp.com/reference.md)
> **Related:** [Astro API reference](https://docs.atmyapp.com/reference/astro.md) · [CLI Reference](https://docs.atmyapp.com/reference/cli.md) · [Core SDK](https://docs.atmyapp.com/reference/core.md) · [Field types and options](https://docs.atmyapp.com/reference/fields.md)
> **Also:** [HTML version](https://docs.atmyapp.com/reference/structure) · [Docs index](https://docs.atmyapp.com/llms.txt)

---
`@atmyapp/structure` provides schema authoring and tooling. For examples, read [Define your content schema](/guides/structure/). For every builder option, use the [field reference](/reference/fields/).

## Authoring exports

`defineSchema`, `defineCollection`, `defineDocument`, `defineFile`, `defineImage`, `defineSystemConfig`, `defineSubmission`, `defineEvent`, and `defineBasicEvent` construct canonical definitions. `s` contains the field builders.

A schema contains `definitions` and optional `description`, `localization`, `events`, `args`, `mdx`, and `submissions`. `defineSchema` supplies canonical version 1. `args` is application-specific metadata; it does not create an SDK environment-variable loader.

## Compile and validate

```ts
import {
  compileSchema,
  validateContent,
  validateSchemaDocument,
} from "@atmyapp/structure";
import schema from "../atmyapp.schema";

const schemaResult = validateSchemaDocument(schema);
if (!schemaResult.valid) {
  throw new Error(JSON.stringify(schemaResult.issues));
}
const compiled = compileSchema(schema);
const result = validateContent(compiled, "home", { headline: "Hello" });
if (!result.valid) {
  console.error(result.issues); // Each issue has a path and message.
}
```

Compilation builds definition/path lookups, flattened field information, references, assets, system fields, and the legacy platform structure. It does not upload your content. The CLI performs compilation as part of migration.

Local validation checks supported schema and value constraints. It is not a substitute for platform checks against existing entries, reference targets, or unique indexes. Read the field reference's validation limits before using a hint as a hard constraint.

## Advanced tooling

The package also exports inference types, introspection helpers, migration planning, framework presets, and legacy conversion utilities. Use these when building schema tooling; ordinary websites generally need the authoring helpers and Core's typed reads. Migration plans describe compatibility work rather than automatically completing every content transformation.