Models and Fields

Model management

Models are the foundation of every AuraBoot application. A model describes the business data you want to store or display. From that definition AuraBoot can create tables, expose dynamic APIs, render form fields, validate inputs, and bind permissions.

Model types

AuraBoot uses different model types for different data responsibilities:

TypePhysical tableTypical use
entityYesCustomer, order, task, invoice, lead
viewNoQuery-backed read-only list or detail projection
treeYesHierarchical data (categories, org structure)
virtualNoModel without a physical table

Most business modules start with entity models. View models become useful when you need read-optimized screens, reports, dashboards, or composed data from multiple sources.

Model definition

A simple entity model looks like this:

{
  "code": "crm_lead",
  "name": "Lead",
  "modelType": "entity",
  "tableName": "mt_crm_lead",
  "description": "Sales lead tracking",
  "fields": [
    { "code": "lead_name", "name": "Lead Name", "dataType": "string", "required": true },
    { "code": "email", "name": "Email", "dataType": "string", "unique": true },
    { "code": "status", "name": "Status", "dataType": "enum", "dictCode": "crm_lead_status" }
  ]
}
PropertyRequiredDescription
codeYesStable model identifier, usually snake_case
nameYesHuman-readable label
modelTypeYesentity, view, tree, or virtual
tableNameNoPhysical table name; can be generated
descriptionNoBusiness purpose and usage notes
fieldsYesField definitions rendered by API and UI

Field types

Data TypeStorageUI behaviorExample
stringvarcharSingle-line inputName, title
texttextMulti-line inputNotes, description
integerbigintNumber inputQuantity
decimalnumericDecimal inputAmount, price
moneynumericMulti-currency amountPrice, contract amount
booleanbooleanSwitch or checkboxActive flag
datedateDate pickerDue date
datetimetimestampDate-time pickerEvent time
enumvarcharSelect, radio, badge (with dictCode)Status
referencebigintSearchable pickerAssigned user
jsonjsonbStructured objectExtension attributes
computedvirtualRead-only displayTotal amount

The field type is not only a database decision. It also influences validation, generated UI controls, filters, sorting, display formatting, and API payload handling.

Dictionaries

Use dictionaries when a field has a controlled set of values:

{
  "code": "crm_lead_status",
  "name": "Lead Status",
  "items": [
    { "value": "new", "label": "New", "sortNo": 1 },
    { "value": "contacted", "label": "Contacted", "sortNo": 2 },
    { "value": "qualified", "label": "Qualified", "sortNo": 3 },
    { "value": "lost", "label": "Lost", "sortNo": 4 }
  ]
}

Dictionary values are useful for statuses, categories, priority, source, region, and other values that should be consistent across forms, lists, filters, dashboards, and workflows.

Reference fields

Reference fields connect models:

{
  "code": "assigned_to",
  "name": "Assigned To",
  "dataType": "reference",
  "referenceModelCode": "sys_user",
  "refDisplayField": "display_name"
}

References are used by list columns, detail pages, sub-tables, permissions, workflows, and reports. A common pattern is a parent model with child records:

crm_account
  -> crm_contact.account_id
  -> crm_opportunity.account_id
  -> crm_activity.account_id

System fields

AuraBoot adds standard system fields to managed entity tables:

FieldPurpose
idInternal primary key
pidStable public identifier
tenant_idTenant isolation
created_atCreation timestamp
updated_atLast update timestamp
created_byCreator user
updated_byLast modifier

Do not duplicate these fields in your model JSON. Use them in filters, audit views, and integrations when needed.

Design guidelines

  • Prefer stable, business-readable model codes such as crm_lead or pm_task.
  • Keep field codes stable after data exists. Renaming fields is a migration.
  • Use dictionaries for states that drive workflows.
  • Use reference fields instead of copying display names across records.
  • Add descriptions for fields that have business meaning beyond their label.
  • Start with entity models; introduce view models only when a screen or report needs a composed projection.

Next steps