Flexkit Schema Documentation
Flexkit schemas define your data model in code. A schema describes:
- Structure: what entities exist (
product,deal,invoice, etc.) - Attributes: what fields each entity has (
name,price,status, etc.) - Semantics: how data is stored (
dataType) and edited (inputType) - Relationships: how entities connect (
singleormultiple) - Scope behavior: whether a value is global, local, or relational
The same definition drives Studio, the generated GraphQL API, and every agent that reads your project: a knowledge graph of the business, expressed as entities and relationships. A first schema that stores records faithfully is a strong start. The schema that answers weekly commercial questions is usually a later revision — see iterating your schema.
Quick Start
import { defineConfig, defineEntity } from '@flexkit/studio';
const products = defineEntity({
name: 'product',
plural: 'products',
display: 'name',
menu: { label: 'Products', group: 'catalog' },
attributes: [
{
name: 'name',
label: 'Name',
scope: 'local',
dataType: 'string',
inputType: 'text',
searchable: true,
defaultValue: '',
validation: (z) => z.string().min(1, { message: 'Name is required' }),
options: {
comment: 'Public product name',
size: 260,
},
},
{
name: 'sku',
label: 'SKU',
scope: 'global',
dataType: 'string',
inputType: 'text',
unique: true,
defaultValue: '',
},
{
name: 'price',
label: 'Price',
scope: 'local',
dataType: 'float',
inputType: 'number',
defaultValue: '',
validation: (z) => z.number().min(0, { message: 'Price must be >= 0' }),
options: {
comment: 'Current selling price',
min: 0,
},
},
],
});
export default defineConfig({
title: 'My Project',
projectId: 'myprojectid',
basePath: '/studio',
scopes: [
{ name: 'default', label: 'Default', isDefault: true },
{ name: 'es', label: 'Spain' },
{ name: 'fr', label: 'France' },
],
schema: [products],
});Core Model
- Project config (
defineConfig) wires project settings, scopes, extensions, andschema. - Entity (
defineEntity) is a collection/table-like model. - Attribute config defines storage type, form input type, validation, and behavior flags.
- Relationship attributes link entities through
relationship.entity,relationship.mode, andrelationship.field.
A living model
Chat and automations query only what the schema exposes. If an agent can count order lines but cannot name a bestseller, the records are present and the question is not yet modeled — an inverse relationship, a sortable total, or a field comment is often the missing piece.
Treat those gaps as the next design pass. Give a coding agent the question, the agent’s reply, and your schema files; deploy the change; backfill the new fields; ask again. The walkthrough is in iterating your schema.
Teams new to Flexkit often expect the first deploy to answer every prompt. The intended path is the opposite: ship a usable model, work with real questions, then add the data points those questions need.