Workflows

Business logic you can see, built from your own model

Snap blocks together in Fractal Studio to describe what a command does or what should happen when something changes. The editor only offers entities, fields and services that exist in your model, checks the workflow before it can run, and the generator turns it into readable code in your repository.

What the workflow editor does

A visual language for the logic that usually ends up hand-written in every command.

  • A visual editor

    Drag blocks into place and nest them: if/else, loops, try/except, set and increase values, fetch, find, create, save and delete records, publish an event, call a service. Each block reads like a sentence, so the logic can be reviewed by people who do not write code.

  • Built from your own model

    Pickers in the editor list the entities, fields, enumerations and services of your project, and nothing else. A "find" filter is built from the entity's fields and becomes a real database query. Record changes go through the same service layer as the rest of the app, with its permissions and audit trail.

  • Attached to commands

    Bind a workflow to a command and that command runs it, with the command's input mapped onto the workflow's inputs and its outputs written back. One workflow can serve several commands.

  • Started by events

    A workflow can also start itself when a record is added, updated or deleted, or when a command has run. An optional condition on the event decides whether it runs at all, and it runs as the user who caused the event.

  • Checked before it runs

    A check validates every block against the model: references, required values, which variables exist on every path, outputs that are always set, and loops between workflows that would trigger each other. Problems are shown on the blocks themselves, and the generator refuses a bound workflow that does not pass.

  • Runs in the background or in the request

    An event-started workflow runs as a background job by default, so a failure there never undoes the change that triggered it. Choose to run it inside the request instead when the outcome has to be part of it.

Example: follow up on an overdue invoice

An illustration of how a workflow reads in the editor, block by block.

  1. Step 1:When an invoice is updated

    The trigger listens for the Invoice entity's updated event, with a condition: only when its status is "overdue". It runs in the background, so saving the invoice never waits for it.
  2. Step 2:Fetch the customer

    A fetch block loads the invoice's customer. The editor offers the Customer entity and its fields from your model, so there is nothing to type and nothing to misspell.
  3. Step 3:Check for an account manager

    An if/else block tests whether the customer has an account manager. Both branches are visible side by side.
  4. Step 4:Act on the outcome

    With an account manager, a create block adds a follow-up task assigned to them. Without one, a call block hands the invoice to your email service to send a reminder.
  5. Step 5:Check, generate, run

    The check confirms every reference and variable before generation. The generated code runs as the user who changed the invoice, inside their account, with their permissions.

Visual, but not a black box

Much of the code behind a command follows the same pattern: load a record, check a condition, change a few values, save it, let the rest of the system know. Writing that by hand for every command is slow, and the logic disappears into files that only developers read.

Workflows put that logic in the model, next to the entities and commands it works on. Because the editor knows the model, it can check a workflow the way a compiler checks code, before anything is generated.

What comes out is ordinary code in your repository, not a configuration interpreted at runtime. You can read it, review it and test it like the rest of the application. When something cannot be expressed in blocks, a custom step hands over to a method you write yourself, so the workflow stays the backbone and hand-written code has a clear place.

One event, many consumers

When a command succeeds, it emits a domain event. That one event has many consumers: workflows triggered on the event, metrics counted from it, signed webhooks to other systems and projections that keep read models up to date. They all run in the background, off the request path, so the user gets a fast response and adding a consumer never slows down the command.

A command produces one domain event that workflows, metrics, signed webhooks and projections consume in the background, off the request path.

Workflow questions

Is a workflow interpreted at runtime?

No. The generator compiles each workflow into code in your repository, so it runs like the rest of your application. A change to a workflow reaches the app on its next regeneration.

What if something cannot be built from blocks?

Use a custom step. It calls a method you implement in the command's own code, which can read and change everything the workflow has gathered so far.

What starts a workflow?

A command it is bound to, or an event: a record being added, updated or deleted, or a command having run. A workflow bound to a command also runs when that command is scheduled through the scheduled tasks module.

Can workflows trigger each other in an endless loop?

The check looks for chains in which a workflow, through the events it raises, ends up starting itself again, and refuses them. At runtime a chain of events is also cut off at a maximum depth.

Do workflows bypass permissions?

No. A workflow started by an event runs as the user who caused it, within their account, and its record changes go through the same service layer as any other change.

Who is the editor for?

It is what we use to build your business logic: it speeds up the common cases, and the result is ordinary code in your repository that your developers can read, review and extend. Because the blocks read as plain sentences, product owners and analysts can follow and discuss the logic with us too.

See a workflow go from blocks to code

We will build a workflow on your own domain in the session and show the check and the generated code.

Book a demo