You are reading the documentation for an outdated Corteza release. 2024.9 is the latest stable Corteza release.

Automation System Overview

Automation system diagram

This will probably become a UML diagram; this one is for development (faster updates). @todo add some annotations and explanations on the diagram.

Sunset
Figure 1. Abstract representation of the automation system.

Automation system components

Corredor server

When Corredor server starts, it
  1. scans all search paths from configuration (.env) and load all scripts,

  2. scans all package.json files in all search paths, and install additional packages,

  3. runs file-change watchers for automation script reloading,

  4. runs file-change watchers for package.json files for dependency reloading.

Corteza server

When Corteza server starts, it
  1. connects to Corredor server and loads all server and client scripts,

  2. creates event handlers from server script triggers and registers them in the event bus,

  3. configures the scheduler system to trigger both onTimestamp and onInterval events once per minute at the minute.

When scheduling system on Corteza server ticks (once per minute), it
  1. dispatches event through the event bus,

  2. checks for registered events with compatible constraints,

  3. requests Corredor server to execute the relevant scripts.

When user indirectly runs automation script via some action on the server (implicitly triggered server scripts)
  1. raises a specific event (onSomething, beforeSomethingElse, afterSomethingElse) and dispatches it through the event bus,

  2. checks for registered events with compatible constraints,

  3. requests Corredor server to execute the relevant scripts.

When request is sent to /sink endpoint
  1. raises a onRequest event and dispatches it through the event bus,

  2. checks for registered events with compatible constraints,

  3. requests Corredor server to execute the relevant scripts.

Corteza web application

When Corteza web application loads in a browser, it
  1. fetches appropriate automation scripts from the Corteza server in the form of a bundle,

  2. registers client scripts from the bundle in the event bus and the ui hooks.

When user clicks on an automation button (explicitly triggered client script), it
  1. raises an event from the given configuration and the invocation context (related resource, user, custom arguments, …​),

  2. checks for registered events with compatible constraints,

  3. requests the script’s execution inside the browser context (client-side execution).

When user clicks on an automation button (explicitly triggered server script), it
  1. raises an event from the given configuration and the invocation context (related resource, user, custom arguments, …​),

  2. checks for registered events with compatible constraints,

  3. requests Corredor server to execute the relevant scripts via the Corteza server.

When user indirectly runs automation script via some action in the client app (implicitly triggered client scripts), it
  1. raises a specific event (onSomething, beforeSomethingElse, afterSomethingElse) and dispatches it through the event bus,

  2. checks for registered events with compatible constraints,

  3. requests the script’s execution inside the browser context (client-side execution).