Skip to content

The backend.fast language

A project contains backend.fast. It declares one app, its models, input/output types, events and annotated functions. The compiler generates a Go HTTP server and a deployment image. It compiles checked bodies; it does not infer behavior from route names.

Download a complete checked example before writing a new project. The feature matrix is the exact support record. A partial feature supports only the boundary in its notes.

app "simple-counter"
model Counter {
id ID
name string @unique
value int = 0
owner UserID @index
updatedAt Time = now()
}
type CreateCounterInput struct {
name string @min(1) @max(80)
}

Every model needs an immutable, non-optional ID. Model @unique and @index create SQLite indexes. String/text @min, @max and @enum validate supported records. Lengths count Unicode code points. Numeric and array constraints remain unsupported. The compiler rejects invalid, duplicate and contradictory constraints.

Supported shapes include selected scalar types, IDs, time/date/duration values, optional T? values, arrays, defaults and record literals. Broader expression and response lowering remains partial. Use the matrix for the exact boundary.

// @api POST /counters
// @auth user
// @cache invalidate ListCounters
func CreateCounter(input CreateCounterInput) Counter {
return database.counters.create(Counter{
name: input.name,
owner: auth.user.id,
value: 0,
})
}

Annotations live in comments above a function. HTTP methods and paths must be unambiguous. System-reserved routes cannot be overridden. A function that reads auth.user needs a user-bearing auth rule.

Annotation Purpose
@api METHOD /path Expose a checked HTTP handler
@auth none, user, admin Select access rules
@auth user owns Model.field Enforce ownership
@cache 30s key=user,params Cache a supported GET response
@cache invalidate FunctionName Invalidate a declared GET cache after success
@on EventName Handle a durable event
@once key=e.field Deduplicate supported local event effects
@job hourly, daily, every 1d Schedule persisted app work

Only include params when applicable; the semantic checker requires it for cached routes that take API parameters. User-auth caches require user. Ownership routes reject TTL caching.

This language is not unrestricted Go. Arbitrary imports, package calls, filesystem/network access, goroutines, channels, defer, panic/recover, pointers, interfaces and reflection are outside the approved surface. Unsupported bodies fail before deployment. A Go-compatible shape alone does not make code supported.

Use the supplied model, query, auth, File and background-work primitives. Do not embed a second web server or database driver. General external integrations and Apple login require additional product work.

The portable CLI deploys through the remote compiler. The local development watcher is not implemented. Follow models and queries and the examples for currently executable programs.