Core Concepts
Yama is built around a few core concepts that work together to create powerful APIs with minimal code.
Schemas
Schemas define the structure and validation rules for your data. They’re reusable definitions that can be referenced throughout your configuration.
schemas:
User:
type: object
properties:
id:
type: string
format: uuid
email:
type: string
format: email
name:
type: stringEntities
Entities represent database tables and provide automatic CRUD operations. They’re built on top of schemas and add database-specific configuration.
entities:
User:
table: users
crud:
enabled: true
fields:
id:
type: uuid
primary: trueEndpoints
Endpoints define your API routes. They can use handlers for custom logic or leverage automatic CRUD operations from entities.
endpoints:
- path: /users
method: GET
handler: handlers/listUsers
response:
type: UserArrayLearn more about Endpoints →
Handlers
Handlers contain your business logic. They’re TypeScript functions that receive a context object with database access, authentication, and more.
export async function listUsers(context: HandlerContext) {
const users = await context.entities.User.findAll();
return users;
}How They Work Together
- Schemas define your data structure
- Entities add database operations to schemas
- Endpoints expose your data via HTTP
- Handlers implement custom business logic
This separation allows you to:
- Define structure in YAML (version-controlled, AI-friendly)
- Write logic in TypeScript (type-safe, testable)
- Let Yama handle routing, validation, and code generation
Last updated on