Skip to content

A Developer's First Look

The best way to understand the power of Simple is to see it in action. Let's build a real feature — a task management system that automatically sets a due date — in just a few moments.

Step 1: Define the Data in SCL

First, we define our task table in an SCL file. This is the complete blueprint for our data. There's no complex ORM mapping or database migration script to write. Just a clear, human-readable definition of our business entity.

ruby
# file: tables.scl

table task, tasks {
  default :id, :timestamps

  required title, :string {
    length 255
  }

  required status, :enum {
    values ToDo, InProgress, Done
    default ToDo
  }

  optional due_date, :date
}

Step 2: Add Business Logic with a Record Behavior

Next, we attach a Record Behavior to the task table. This is a simple JavaScript script that runs in a secure sandbox on both the client and the server. This script will automatically set the due_date to 7 days in the future if one isn't provided.

typescript
// file: task_behavior.js

export default async ($form, $db, $user) => {
  // This logic runs whenever a new Task is being created,
  // both in the UI form and programmatically on the server.
  if ($form.event === 'load' && !$form('due_date').value()) {
    const today = new Date()
    const futureDate = new Date(today.setDate(today.getDate() + 7))

    // Set the 'due_date' field to one week from today.
    $form('due_date').set(futureDate.toISOString().split('T'))
  }
}

Step 3: Deploy and Run

You commit these two files. That's it.

The Simple Platform automatically:

  1. Provisions the task table in your tenant's database with the correct columns and constraints.
  2. Updates your GraphQL API with new queries and mutations for task and tasks.
  3. Deploys your Record Behavior to the Logic Runtime, making it instantly available.

When a user opens the "New Task" form, the logic runs on the client, and the due_date field is pre-populated. If a new task is created via an API call without a due_date, the exact same logic runs on the server to ensure the default is set authoritatively.

What You Didn't Have to Do

  • Write a database migration.
  • Define an API endpoint or a REST route.
  • Map data between an ORM and your application code.
  • Write separate validation logic for the client and server.

This is the power of the Simple Platform: focus on your business model and logic, and let the platform handle the rest.

Ready to see how it all works? Dive into the Architectural Blueprint.