Skip to Content
SchemaSchema Examples

Schema Examples

These examples are intentionally varied and concise. Adapt them to your own domain.

1) E-commerce: Catalog + Orders

React
import { defineEntity } from '@flexkit/studio';
 
export const product = defineEntity({
  name: 'product',
  plural: 'products',
  menu: { label: 'Products', group: 'catalog' },
  attributes: [
    {
      name: 'name',
      label: 'Name',
      scope: 'local',
      dataType: 'string',
      inputType: 'text',
      isPrimary: true,
      isSearchable: true,
      defaultValue: '',
    },
    {
      name: 'sku',
      label: 'SKU',
      scope: 'global',
      dataType: 'string',
      inputType: 'text',
      isUnique: true,
      defaultValue: '',
    },
    {
      name: 'price',
      label: 'Price',
      scope: 'local',
      dataType: 'float',
      inputType: 'number',
      defaultValue: '',
    },
    {
      name: 'category',
      label: 'Category',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'single', entity: 'category', field: 'name' },
    },
  ],
});

2) CRM: Deals + Contacts

React
export const deal = defineEntity({
  name: 'deal',
  plural: 'deals',
  menu: { label: 'Deals', group: 'sales' },
  attributes: [
    {
      name: 'name',
      label: 'Deal Name',
      scope: 'global',
      dataType: 'string',
      inputType: 'text',
      isPrimary: true,
      defaultValue: '',
    },
    {
      name: 'stage',
      label: 'Stage',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'single', entity: 'pipelineStage', field: 'name' },
    },
    {
      name: 'contacts',
      label: 'Contacts',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'multiple', entity: 'contact', field: 'firstName' },
    },
    {
      name: 'amount',
      label: 'Amount',
      scope: 'global',
      dataType: 'float',
      inputType: 'number',
      defaultValue: '',
    },
  ],
});

3) ERP: Procurement + Inventory

React
export const purchaseOrder = defineEntity({
  name: 'purchaseOrder',
  plural: 'purchaseOrders',
  menu: { label: 'Purchase Orders', group: 'operations' },
  attributes: [
    {
      name: 'number',
      label: 'PO Number',
      scope: 'global',
      dataType: 'string',
      inputType: 'text',
      isPrimary: true,
      isUnique: true,
      defaultValue: '',
    },
    {
      name: 'supplier',
      label: 'Supplier',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'single', entity: 'supplier', field: 'name' },
    },
    {
      name: 'status',
      label: 'Status',
      scope: 'global',
      dataType: 'string',
      inputType: 'select',
      defaultValue: 'draft',
      options: {
        list: [
          { label: 'Draft', value: 'draft' },
          { label: 'Approved', value: 'approved' },
          { label: 'Received', value: 'received' },
        ],
      },
    },
    {
      name: 'deliveryDate',
      label: 'Delivery Date',
      scope: 'global',
      dataType: 'date',
      inputType: 'datetime',
      defaultValue: '',
    },
  ],
});

4) Healthcare: Appointments

React
export const appointment = defineEntity({
  name: 'appointment',
  plural: 'appointments',
  menu: { label: 'Appointments', group: 'operations' },
  attributes: [
    {
      name: 'patient',
      label: 'Patient',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'single', entity: 'patient', field: 'fullName' },
    },
    {
      name: 'doctor',
      label: 'Doctor',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'single', entity: 'doctor', field: 'fullName' },
    },
    {
      name: 'startAt',
      label: 'Start',
      scope: 'global',
      dataType: 'datetime',
      inputType: 'datetime',
      defaultValue: '',
    },
    {
      name: 'isFollowUp',
      label: 'Follow-up',
      scope: 'global',
      dataType: 'boolean',
      inputType: 'switch',
      defaultValue: '',
    },
  ],
});

5) Education: LMS Courses

React
export const course = defineEntity({
  name: 'course',
  plural: 'courses',
  menu: { label: 'Courses', group: 'catalog' },
  attributes: [
    {
      name: 'title',
      label: 'Title',
      scope: 'local',
      dataType: 'string',
      inputType: 'text',
      isPrimary: true,
      defaultValue: '',
    },
    {
      name: 'description',
      label: 'Description',
      scope: 'local',
      dataType: 'string',
      inputType: 'editor',
      defaultValue: '',
    },
    {
      name: 'instructor',
      label: 'Instructor',
      scope: 'relationship',
      dataType: 'string',
      inputType: 'relationship',
      defaultValue: '',
      relationship: { mode: 'single', entity: 'instructor', field: 'name' },
    },
    {
      name: 'published',
      label: 'Published',
      scope: 'global',
      dataType: 'boolean',
      inputType: 'switch',
      defaultValue: '',
    },
  ],
});

Example Design Checklist

  • Define one clear primary field per entity (isPrimary).
  • Use relationships for reusable dimensions.
  • Choose local scope for localized/regional values.
  • Keep IDs, SKUs, and core references global and stable.
Last updated on

© 2026