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:
| Schema | Table |
|---|---|
User | users |
Category | categories |
BlogPost | blog_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 type | SQLite type | Example seed data |
|---|---|---|
string | TEXT | "Value 1" |
number | INTEGER | 100 |
integer | INTEGER | 100 |
boolean | INTEGER | 0 or 1 |
float | REAL | 1.5 |
double | REAL | 1.5 |
array | TEXT (JSON) | Stored as JSON string |
object | TEXT (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:
- Fields containing
emailget values likeuser1@example.com - Fields containing
nameget values likeExample 1 - Fields containing
activeorpublishedalternate between 0 and 1 - Relationship fields get valid IDs from the referenced table
- Other fields get generic values based on their type
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.