# Basic Concepts

This section cover the basic concepts to understand of Kumologica and explains the technical details of how Kumologica works.

# Flows and Nodes

A Kumologica API or service integration can be represented as a connected network of nodes, each node is responsible to take a message (request) and produce zero or many outputs, which in turn becomes the input to the next node.

Each node can be seen as a "black-box" or function that manipulates the message and produces some desirable side-effects: writing into an external database, send an email or SMS, etc.

There are three type of nodes:

  • Inbound nodes: They are listening to external events: API requests, Queues, Topics, DB Triggers. The become the entry points to the flows, the main role is to convert those external events into an standard Kumologica message (msg). You can recognize these nodes as they have no explicit inputs defined in the designer.
  • Standard nodes: They are connected to other standard nodes, and they are responsible to accept messages and produce one or many outputs based on their internal logic. You can recognize these nodes as they have one explicit input and one or many outputs in the designer.
  • Outbound nodes: As the standard nodes, they are connected to other standard nodes, but unlike those ones, their role is to produce a valid response (HTTP response) to the source of the event (original trigger of the flow).You can recognize these nodes as they have one explicit input and zero outputs in the designer.

# Message

A message, encoded as the internal object msg, represents a piece of information that nodes use to communicate with each other. Inbound nodes convert external trigger events into a msg and it will pass it to its connected nodes. Outbound nodes will convert a msg into a HTTP response back to the client. In between, standard nodes will performed their predefined logic based on the received msg and they they will modify the msg accordingly.

The basic structure of a msg is as follows:

  • _msgid: Unique execution identifier created for each execution. During local development this id will be equal to the testCaseId.
  • error: This property will hold the error being caught by the Error Node. Refer to Error Handling section for more details.
  • header: This property is an object hold metadata added by a node. Information contained in this object should not be modified by other nodes.
  • payload: This property is an object hold information added by node. Unlike the header property, this property is meant to be mutable, and it has a special meaning for some nodes. For example: the body of HTTP Response produced by the EventListenerEnd node is taken from the payload object.

# Predefined Variables

As we have seen in the previous section, a msg can hold information that can be exchanged between nodes. In addition to msg there are other two variables that can be used to store information at the level of the flow.

These two variables are:

  • vars
  • env

Kumologica is not prescriptive of when to use one over the other, but it is considered a good practice to hold information about the environment in env, and use vars for temporary and non business related information.

For AWS Lambda execution environments, env variable will hold all the environment variables passed to the lambda function during deployment.

WARNING

Unlike msg variable. Both variables: env and vars will keep their state across multiple invocations. Thus, be extra careful when you mutate these variables.

# Dynamic Expression

Nodes are defined as a set of properties. Sometimes these properties are defined not as a static value (string or number) but as a dynamic expression. What it means is that the value will be computed dynamically at runtime.

This is very useful when the value of a property is dependant of another property that is only known during the execution of the flow.

For example, the name of a database name is suffixed with the name of the stage where this flow is executed: "my-database-dev", "my-database-test", "my-database-uat", "my-database-prod".

The developer can recognized fields accepting dynamic expressions in Kumologica Designer, as they will be highlighted in purple as the image below:

The format of the dynamic expression follows the one defined in JSONata string expressions. Keep in mind that the variables: msg, var and env are available during the composition of those expressions.

String literals must be enclosed with either double quotes " or single quotes '.

In the event of a parsing error of the dynamic expression, the field will return the same value entered as an input.

Examples:

  • "my-database-" & env.stage: Suffix the name of the database with the stage is running in.
  • "Message payload: " & msg.payload & " received": Inject the payload in the middle of a string. Useful for logging purposes.