ObjectStackObjectStack

ObjectUI — the UI protocol specification

ObjectUI, the server-driven UI protocol: define layouts, forms and dashboards as JSON or YAML metadata that renderers turn into working interfaces.

ObjectUI is ObjectStack's UI abstraction layer that treats interfaces as data. Instead of hardcoding React/Vue components, you define layouts, forms, and dashboards as JSON/YAML configurations that renderers interpret at runtime.

The Core Problem

Traditional frontend development chains you to specific frameworks and platforms:

  • UI Changes Require Deployments: Change a form layout? Rebuild, test, redeploy, wait for app store approval
  • Platform Fragmentation: Build the same form 3 times (Web React, iOS SwiftUI, Android Jetpack Compose)
  • Business User Lock-out: Analysts can't configure dashboards—they must file tickets and wait for developer sprints
  • Validation Duplication: Same validation rules written 3 times (Frontend, Backend, Database)
  • Framework Lock-in: Switching from React to Vue requires months of rewrites

Result: 6-week lead time to add a single field to a form. Business agility destroyed by technical constraints.

The ObjectUI Solution

Deploy UI in Seconds

Update forms, dashboards, and reports without rebuilding apps. Change JSON metadata, refresh page—done.

One Definition, Every Screen

The Console renders one JSON definition on desktop and on phones, in a browser or inside the ObjectStack mobile app, which hosts the same Console.

Empower Business Users

Non-technical users configure dashboards and reports themselves. IT enables, doesn't gatekeep.

Consistent UX Guarantee

Same form layout on every platform. Validation enforced everywhere automatically. Zero drift.

Architecture Overview

┌─────────────────────────────────────────────────────────────┐
│                     Application Layer                        │
│  Business Users configure dashboards, forms, actions         │
└─────────────────────────────────────────────────────────────┘
                            ↓
┌─────────────────────────────────────────────────────────────┐
│                   ObjectUI Protocol (JSON)                   │
│  Layout DSL • Widget Contract • Action Definitions           │
└─────────────────────────────────────────────────────────────┘
                            ↓
┌─────────────────────────────────────────────────────────────┐
│                    Console (the renderer)                    │
│  Reads the JSON • Paints forms, lists, dashboards            │
└─────────────────────────────────────────────────────────────┘
                            ↓
        ┌───────────────────┴────────────────────┐
        ↓                   ↓                     ↓
  ┌──────────┐      ┌──────────┐         ┌──────────────┐
  │ Desktop  │      │  Phone   │         │  Mobile app  │
  │ browser  │      │ browser  │         │  (hosts the  │
  │          │      │          │         │   Console)   │
  └──────────┘      └──────────┘         └──────────────┘

Key Insight: The protocol is the contract. The Console is the renderer that ships, and it paints the same definition on every screen; the ObjectStack mobile app is a native shell that hosts the Console, not a second renderer.

Core Components

Quick Example

Traditional Approach (React)

// CustomerForm.tsx (300+ lines of code)
import { useState, useEffect } from 'react';
import { TextField, Select, Button } from '@mui/material';

function CustomerForm({ customerId }) {
  const [data, setData] = useState({});
  const [loading, setLoading] = useState(true);
  
  useEffect(() => {
    fetch(`/api/customers/${customerId}`)
      .then(res => res.json())
      .then(data => { setData(data); setLoading(false); });
  }, [customerId]);
  
  const handleSubmit = async () => {
    if (!data.name || data.name.length < 3) {
      alert('Name must be at least 3 characters');
      return;
    }
    await fetch(`/api/customers/${customerId}`, {
      method: 'PUT',
      body: JSON.stringify(data)
    });
  };
  
  return (
    <form onSubmit={handleSubmit}>
      <TextField
        label="Customer Name"
        value={data.name || ''}
        onChange={e => setData({...data, name: e.target.value})}
        required
        minLength={3}
      />
      <Select
        label="Status"
        value={data.status || 'active'}
        onChange={e => setData({...data, status: e.target.value})}
      >
        <option value="active">Active</option>
        <option value="inactive">Inactive</option>
      </Select>
      <Button type="submit">Save</Button>
    </form>
  );
}

Problems:

  • 300+ lines for a 2-field form
  • Validation logic duplicated (frontend + backend)
  • Change field order? Edit code, rebuild, redeploy
  • Mobile app? Rewrite entire form in Swift

ObjectUI Approach

# customer.formview.yml (15 lines)
name: customer_edit
object: customer
mode: edit
layout:
  sections:
    - name: basic_information
      label: Basic Information
      columns: 2
      fields:
        - name
        - status
actions:
  - type: standard_save
    label: Save

Benefits:

  • 15 lines vs 300 lines (95% reduction)
  • Validation inherited from customer.object.yml (no duplication)
  • Change field order? Edit YAML, refresh page (5 seconds)
  • Mobile app? The Console renders the same YAML file on a phone, in a browser or inside the ObjectStack mobile app (zero code)

Result: What took 2 days now takes 2 minutes.

Server-Driven UI Flow

┌──────────┐                                    ┌──────────┐
│  Client  │                                    │  Server  │
└────┬─────┘                                    └────┬─────┘
     │                                               │
     │  1. Request Layout                            │
     │  GET /api/v1/meta/view/customer               │
     │──────────────────────────────────────────────>│
     │                                               │
     │                                     2. Resolve Layout
     │                              (Merge: Base + Admin Config + User Prefs)
     │                                               │
     │  3. Return Layout JSON                        │
     │  { type: 'form', fields: [...] }              │
     │<──────────────────────────────────────────────│
     │                                               │
4. Render Layout                                     │
(Traverse JSON, instantiate components)              │
     │                                               │
     │  5. User Interaction (Click Save)             │
     │                                               │
     │  6. Submit Data                               │
     │  POST /api/v1/data/customer                   │
     │──────────────────────────────────────────────>│
     │                                               │
     │                                   7. Validate & Save
     │                              (Run validation rules from schema)
     │                                               │
     │  8. Return Success                            │
     │<──────────────────────────────────────────────│
     │                                               │
9. Update UI                                         │
(Show success toast, refresh list)                   │

View Types

FormView: Record Editing

import { defineView } from '@objectstack/spec/ui';

defineView({
  form: {
    type: 'tabbed', // or 'simple' | 'wizard' — the layout; where it opens is the caller's choice
    data: { provider: 'object', object: 'project' },
    // In tabbed forms each section renders as its own tab.
    sections: [
      { name: 'basic_info', label: 'Basic Info', columns: 2, fields: ['name', 'status'] },
      { name: 'dates', label: 'Dates', columns: 2, fields: ['start_date', 'end_date'] },
      { name: 'team', label: 'Team', fields: ['manager', 'team_lead'] }
    ]
  }
});

Renders as: a tabbed form in the Console, one tab per section. The same definition drives the Console on desktop and on a phone.

ListView: Data Tables

import { defineView } from '@objectstack/spec/ui';

defineView({
  list: {
    type: 'grid', // or 'kanban' | 'gallery' | 'calendar' | 'timeline' | 'gantt' | 'map' | 'chart' | 'tree'
    data: { provider: 'object', object: 'project' },
    columns: [
      { field: 'name', width: 200, sortable: true },
      { field: 'status', width: 120 },
      { field: 'due_date', width: 150, sortable: true }
    ],
    filter: [{ field: 'status', operator: 'in', value: ['active', 'pending'] }],
    // Actions reference registered Action IDs. Row actions are top-level;
    // toolbar buttons live under `userActions`.
    userActions: { buttons: ['new_project'] },
    rowActions: ['edit']
  }
});

Features:

  • Sorting, filtering, pagination (all server-side)
  • Bulk actions (select multiple rows)
  • Inline editing (double-click cell)
  • Export to CSV/Excel

Dashboard: Analytics Composition

import { Dashboard } from '@objectstack/spec/ui';

Dashboard.create({
  name: 'sales_overview',
  label: 'Sales Overview',
  columns: 12,          // 12-column grid
  gap: 4,
  // Flat widget list. Each widget binds to a semantic-layer `dataset`
  // (ADR-0021) and picks its `dimensions`/`values` by name; position via
  // `layout: { x, y, w, h }` (omit to auto-flow).
  widgets: [
    // Row 1: KPI metric cards
    { id: 'revenue', type: 'metric', title: 'Revenue', dataset: 'sales_summary', values: ['revenue'], layout: { x: 0, y: 0, w: 3, h: 2 } },
    { id: 'deals', type: 'metric', title: 'Deals', dataset: 'sales_summary', values: ['deal_count'], layout: { x: 3, y: 0, w: 3, h: 2 } },
    { id: 'win_rate', type: 'metric', title: 'Win Rate', dataset: 'sales_summary', values: ['win_rate'], layout: { x: 6, y: 0, w: 3, h: 2 } },
    { id: 'avg_deal', type: 'metric', title: 'Avg Deal', dataset: 'sales_summary', values: ['avg_deal'], layout: { x: 9, y: 0, w: 3, h: 2 } },
    // Row 2: charts
    { id: 'revenue_trend', type: 'line', title: 'Revenue Trend', dataset: 'sales_by_month', dimensions: ['month'], values: ['revenue'], layout: { x: 0, y: 2, w: 8, h: 4 } },
    { id: 'by_stage', type: 'pie', title: 'By Stage', dataset: 'pipeline_by_stage', dimensions: ['stage'], values: ['amount'], layout: { x: 8, y: 2, w: 4, h: 4 } },
    // Row 3: tabular block
    { id: 'closing_soon', type: 'table', title: 'Closing Soon', dataset: 'opportunities_closing_soon', dimensions: ['name'], values: ['amount'], layout: { x: 0, y: 6, w: 12, h: 4 } }
  ]
});

Widget Types (each widget's type is a chart type):

  • Metric / KPI: single-value cards (metric, kpi, gauge, bullet)
  • Chart: bar, column, line, area, pie, donut, funnel, scatter, radar, treemap, sankey
  • Tabular: table, pivot

Design Principles

1. Declarative Over Imperative

// ❌ Imperative (React)
function TaskList() {
  const [tasks, setTasks] = useState([]);
  const [loading, setLoading] = useState(true);
  
  useEffect(() => {
    fetch('/api/tasks').then(res => res.json()).then(data => {
      setTasks(data);
      setLoading(false);
    });
  }, []);
  
  return loading ? <Spinner /> : <Table rows={tasks} />;
}

// ✅ Declarative (ObjectUI)
defineView({
  list: {
    data: { provider: 'object', object: 'task' },
    columns: [{ field: 'title' }, { field: 'status' }]
  }
});

Why: Declarative definitions are:

  • Easier to understand: No lifecycle logic, just "what" not "how"
  • Easier to maintain: Change a field? Edit one line
  • Easier to test: Validate JSON schema instead of testing React hooks

2. Configuration Over Code

UI changes should never require rebuilding:

flowchart LR
    subgraph T["Traditional — 2–14 days"]
      direction LR
      C1["Change Code"] --> B1["Build"] --> Te1["Test"] --> D1["Deploy"] --> A1["(iOS) App Store wait"]
    end
    subgraph O["ObjectUI — 5 seconds"]
      direction LR
      C2["Change Config"] --> R2["Refresh Page"]
    end

Why: Business requirements change daily. Code deployment cycles are weekly at best.

3. Responsive by Default

All layouts use a 12-column grid that adapts automatically:

sections:
  - name: contact_info
    label: Contact Info
    columns: 2  # Desktop: 2 columns, Tablet: 1 column, Mobile: 1 column
    fields:
      - email
      - phone

Breakpoints (auto-applied):

  • Desktop: columns: 2 → 2 columns
  • Tablet: columns: 2 → 1 column
  • Mobile: columns: 2 → 1 column (stacked)

4. Type-Safe by Default

ObjectUI definitions are Zod schemas:

import { FormViewSchema } from '@objectstack/spec/ui';

// Runtime validation
const config = FormViewSchema.parse(userConfig);

// TypeScript inference
type FormView = z.infer<typeof FormViewSchema>;

Benefits:

  • Catch errors at configuration time, not runtime
  • IDE autocomplete for all properties
  • Auto-generated documentation

Integration with ObjectQL

ObjectUI is tightly integrated with ObjectQL:

# 1. Define Object (ObjectQL)
# customer.object.yml
name: customer
fields:
  name:
    type: text
    required: true
    maxLength: 100
  email:
    type: email
    unique: organization
  status:
    type: select
    options:
      - { value: active, label: Active }
      - { value: inactive, label: Inactive }
    default: active

# 2. Define Form (ObjectUI)
# customer.formview.yml
name: customer_edit
object: customer  # ← References ObjectQL schema
layout:
  sections:
    - name: basic_information
      fields: [name, email, status]  # ← Fields auto-validated

What ObjectUI Inherits from ObjectQL:

  • Field Types: text → Text input, select → Dropdown
  • Validation Rules: required, maxLength, unique
  • Default Values: Pre-populate forms
  • Relationships: lookup field → Searchable modal
  • Permissions: Hide fields user can't see

Result: Zero duplication. Define once in ObjectQL, UI auto-configures.

Real-World Use Cases

Multi-Tenant SaaS Customization

Challenge: You sell a CRM to 500 customers. Each wants custom branding (logo, colors) and slightly different form layouts.

ObjectUI Solution:

// Tenant A gets blue theme with 3-column layout
tenantA.formview.yml:
  layout: { columns: 3 }
  theme: { primary: '#0066CC' }

// Tenant B gets green theme with 2-column layout
tenantB.formview.yml:
  layout: { columns: 2 }
  theme: { primary: '#00AA00' }

Value:

  • Same codebase serves all 500 customers
  • Launch new tenant in 10 minutes (not 2 weeks)
  • $2M/year saved on custom development

Regulatory Compliance Agility

Challenge: Fintech operates in 50 countries. EU requires GDPR consent checkbox, India requires Aadhaar number, USA requires SSN.

ObjectUI Solution:

# EU variant
formview.eu.yml:
  fields: [name, email, gdpr_consent]

# India variant
formview.in.yml:
  fields: [name, email, aadhaar]

# USA variant
formview.us.yml:
  fields: [name, email, ssn]

Value:

  • New regulation? Update YAML, deploy instantly
  • Avoided $500K regulatory fine
  • Market entry time: 1 week (was 3 months)

Field Teams on Phones

Challenge: Field service technicians need the same forms on their phones that the office uses at a desk.

ObjectUI Solution: nothing extra to define. The Console renders the same customer.formview.yml in a phone browser, and the ObjectStack mobile app hosts that same Console. There is no separate mobile renderer and no mobile-only metadata.

Value:

  • One definition to maintain: the phone and the desk show the same fields in the same order
  • A layout change on the server reaches the phone without a new app release

What's Next?

Additional Resources

For Implementers

Building a renderer for ObjectUI?

For Users

Using ObjectUI to build applications?

On this page