On this page
Conventions
Naming
| Thing | Convention | Example |
|---|---|---|
| Group, app, registration key | No .; PascalCase for declarations, camelCase for app | core, UserProfile |
| Properties | Describe the value, not the field | UserId, Email, Timestamp |
| Schema fields | camelCase | externalCustomerId |
| Operations | Verb then noun | CreateUser, ListUsers |
| Events | Past tense | UserCreated |
| Policies | Describe the requirement | CurrentUser, CanRead |
Packs derive every casing (kebab, snake, pascal, camel) from the semantic name, so choose a name that reads well as plain words. See Naming for the formal rules.
Structure
- One group per bounded area (
users,billing) and features inside it when you need a finer registration scope. A declaration belongs to one group and at most one feature. - Shared values in a
sharedgroup (Id,Email,Timestamp) so every schema reuses one definition. - Separate the stored shape from the API shapes. Declare one
entityschema with astoragefacet, then deriveUserRead,CreateUserRequest,UpdateUserRequestandUserQuerywith projections instead of copying fields. - Give operations a
role(create,detail,list,update,delete). Packs use roles to choose HTTP verbs, status codes and handler shapes.
Modelling habits
- Mark system fields (
.system()): ids and timestamps the client must not send. - State query ability on the field (
.query({ filter: ["equal"], sort: true })) instead of in the API layer. - Prefer registered properties to inline types so constraints live in one place.
- Say what is sensitive (
.sensitive()), so packs can redact it in logs and docs. - Declare failures and events an operation can produce; packs map them to error responses and messages.
- Keep policies semantic. A policy says "needs a current user with an id"; it is not middleware.
What not to do
- Do not put framework concepts (decorators, column types, controllers) in contracts.
- Do not reference a raw definition: register it first.
- Do not encode behaviour in names that packs must parse.
- Do not rely on file order or hidden defaults. If a pack needs a fact, state it.