Build behaviour (Flow-Driven Development)
Logic
Build what a system does by connecting nodes on a canvas: endpoint logic for an API, event logic for a user action, and functions you reuse.
Open Logic in the appWhat logic is
Logic is what a system does, built from steps on a canvas instead of typed as code. It starts at one starting point, runs its steps one after another along the arrows, and ends by answering or returning. Because it is a model, you can test it in the editor, read it as text steps and generate code from it.
Each logic belongs to one system, or to none when it is reusable. It has a key such as LOGIC-AUTH-LOGIN-001, and each of its steps has a key too.
This guide is an overview. The logic editor reference covers every panel, tab, shortcut and node in detail.
With another environment picked in the header, Logic lists the logic of the releases running there, each at the revision deployed there, read-only. See Logic and flows in an environment.
Three kinds
You pick the kind when you create it. Ask what starts it.
The kinds work together: a login button's event logic calls the login API, whose endpoint logic checks the password with a function it shares with the sign-up API. See Which kind to choose.
Create logic
- Open Logic under Behaviour in the sidebar and press New logic, or open a system's Logic tab and press + Logic.
- In New logic, pick the Kind and the System, and name it.
- List What it takes and What it gives back. You can change both later.
- Press Create and open.
For an API that has no logic yet, open the API and press Implement with logic. The new endpoint logic takes exactly the API's request and must return one of its declared responses. If you change the API later, the logic's inputs follow.
The canvas: nodes, connection points and connections
- Nodes are the steps. Add them from the Nodes tab, by right-clicking empty space, or by dropping a connection on empty space (the list then shows only nodes that fit).
- Connection points are a node's inputs and outputs. White arrow points decide the next step. Coloured round points carry values, and the colour shows the type.
- Connections join an output to an input. A connection between the wrong types is refused, with the reason and, where it helps, a conversion step to insert.
- An input with no connection uses the value you type for it in Details.
Some nodes you will use often:
The node reference explains every node, with examples.
Logic on systems
A system's Logic tab shows its logic as cards with their inputs and outputs, grouped into Runs when another system calls this API, Runs when something happens in the system and functions. It also lists provider APIs that have no logic yet. On the system map, a system shows how many pieces of logic it has.
Each API another system offers, and that this system declares it uses, becomes a Call Contract node in this system's logic. Each operation of a database, queue or external system becomes a node too. So what a logic can call is exactly what the map says the system depends on.
Test it right away
You don't need a flow to try logic.
- Press Test in the toolbar. The Test tab opens in the bottom panel.
- Pick one of the examples, a test case of a flow that reaches this logic (under From flows: it fills in what this logic gets in that case), or Custom input, and type the values.
- Press Run. The canvas lights up the path taken and the value on every connection. Step through it with the arrow keys.
Calls to other systems and databases are answered by their logic or by test data, just as in a flow run.
The rest of the editor
- Side panel: Nodes (its switch picks Steps or Other logic), Details and Variables.
- Bottom panel: Problems (any error that stops it running, and warnings such as a check whose answer nothing uses: it never runs until its answer goes into a Branch or an AND a Branch reads), Test and History.
- Toolbar: Steps and Flowchart switch how you see it. Code opens the generated code next to the canvas (
Ctrl+Shift+C); its Text tab has the logic as text steps. Save (Ctrl+S) saves a new revision; until then, edits live only in your browser tab. - The … menu: History, Where it is used, Copy link, Present (the canvas full screen) and everything used now and then.
- Turn steps into a function: select some steps, right-click and choose Turn into a function. They move into a new function and one Call Function step takes their place.
Each panel is explained in the logic editor reference. For a full build, follow the login example.
Sticky notes
A sticky note is a short note on the canvas, for you or for everyone. Anyone in the organization or project can add one, viewers included. A sticky note is never part of what it sits on: it has no versions, it isn't reviewed, and Draft mode and draft-first publishing don't hold it back.
- Add one. Press the sticky note button with the zoom buttons and choose Add sticky note, or right-click an empty part of the canvas and choose Add sticky note here. Type, then press Save (or
Ctrl+Enter). An empty note goes away. - Who sees it. A new note is Only me: nobody else ever sees it. Choose Organization before saving, or later from the note's menu, and everyone who can open the logic sees it with your name on it.
- Fold it. The fold button turns a note into a small icon; click the icon to open it again. Folding is yours alone: a shared note you fold stays open for everyone else, and stays folded on your other devices.
- Change it. Only the person who wrote a note changes it. Double-click the text (or choose Edit) to edit it, drag it by its top bar to move it, or nudge it with the arrow keys. Its menu also has the colours.
- Delete it. Delete your own from its menu, and Undo brings it back for a few seconds. Someone who may edit the logic can also delete a shared note left by someone else, after a confirm.
- Hide them. Hide sticky notes in the same button hides every note on logic for you, until you choose Show sticky notes.
A sticky note is saved as soon as you write it: it never makes the logic unsaved, and you can add one while the logic is locked. Notes aren't shown in the flowchart view or while comparing with an earlier revision. Deleting the logic takes its notes to the trash with it.
Related
- Logic editor referenceEvery panel and tab of the logic editor, and a guide to every node.
- FlowsBuild a flow from the logic it starts at, see it cross your systems in lanes, and move it from draft to verified.
- Test data and expected resultsTest data stands in for databases, APIs and inputs that don’t exist yet; expected results describe the result you expect.
- Code generationSee the code for a logic as you build it, take it away as files, and check it returns what the test cases returned.
- Reusable logic and packagesBuild functions that belong to no system and call them anywhere, add logic packages, and publish your own flows and logic.
