Data models

Define your data once under schemas. Akuma turns each schema into a real SQLite table, seeds it with example rows, and serves it through database queries.

Defining a schema

A schema is a named set of properties. Each property maps a field name to a type.

schemas:
  User:
    properties:
      id: number
      name: string
      email: string
      active: boolean

Table names

Each schema becomes a SQLite table named by converting the schema name to snake_case and pluralizing it:

SchemaTable
Userusers
Categorycategories
BlogPostblog_posts

Schema names can be capitalized (User) or lowercase (user); both map to the same table. Reference a schema by its exact name from your endpoints.

Supported types

YAML typeSQLite typeExample seed data
stringTEXT"Value 1"
numberINTEGER100
integerINTEGER100
booleanINTEGER0 or 1
floatREAL1.5
doubleREAL1.5
arrayTEXT (JSON)Stored as JSON string
objectTEXT (JSON)Stored as JSON string
<schema name>INTEGER (FK)Valid ID from referenced table

A property typed as another schema name is a relationship. Akuma turns it into a foreign key.

Smart field seeding

Akuma seeds each table with three example rows, generating contextual data based on column names:

Where the data lives

Data is stored in .akuma/<server-name>.db (SQLite). You can query it directly:

sqlite3 .akuma/my-api.db "SELECT * FROM users"

To serve a schema over HTTP, point an endpoint at it. See Endpoints.

Common mistakes

Two schemas map to the same table

Table names are snake_cased and pluralized, so User and user both become users. Akuma refuses to start rather than silently merge them:

Error: Schemas 'User' and 'user' both map to table 'users'. Rename one of them.

A misspelled type becomes text

Types are case-sensitive and lowercase (string, not String). An unrecognized type is stored as text, with a warning at startup:

Schema 'User' property 'name' has unknown type 'String'; treating it as text.