Foundations
1. About this guide
This guide sets the standards for designing Sutras: how to structure a project, name things, build functions and transformations, expose APIs and web services, connect systems, design microservices, handle errors and release safely. The SutraFlow User Guide says what each activity and screen does; this guide says how to put them together so that the result is correct, secure, fast and easy for the next person to look after.
| Reader | Use this guide to |
|---|---|
| Designers | Shape a Sutra before building it; settle names, contracts and error paths early. |
| Reviewers and leads | Review a Sutra or project against the rules and the checklist (Design review checklist). |
| Architects | Decide service boundaries, integration patterns and how systems talk to each other. |
| Administrators | Know what designers were asked to do, so production settings fit (the Administration Guide covers the servers). |
How the rules are written
| Word | Meaning |
|---|---|
| Must | Required. A Sutra that breaks it does not pass review, unless the reason is written in the Sutra's description. |
| Should | Expected. Break it only for a reason you can explain. |
| May | Allowed; use your judgement. |
Examples use an order business (orders, customers, stock, invoices) because it is easy to picture; the rules are the same for any domain. Activity names link to the activity reference in the user guide.
New to SutraFlow: read How a Sutra runs and Designing Sutras: patterns and good practice in the user guide first, then Design principles here.
2. Design principles
Twelve principles sit under every rule in this guide. When a rule does not cover a case, decide by these.
| # | Principle | In practice |
|---|---|---|
| 1 | One purpose per Sutra | A Sutra does one business thing (Accept an order, Send the invoice). Ten to thirty steps; more means it should be split into called Sutras. |
| 2 | Contracts first | Agree the input and output (a JSON Schema, XSD or WSDL) before building. Every entry point and every called Sutra has one. |
| 3 | Validate at the door | Bad input is refused where it enters, with a clear answer, never deep inside the Sutra. |
| 4 | Safe to repeat | Steps that change things can run twice without harm: retries, redeliveries and recovery after an engine stops all repeat work. |
| 5 | Fail visibly | Every failure ends somewhere a person or a system sees it: an error reply, an alert, a dead-letter queue, a logged run. Nothing is swallowed. |
| 6 | Configuration outside the design | Addresses, names, limits and secrets that differ per environment live in properties, connections and the vault, never in steps. |
| 7 | Reuse, do not copy | Shared logic is a called Sutra; shared connections and schemas are project resources. |
| 8 | Carry references, not content | Large data stays in files, tables and storage; the run carries paths and ids. |
| 9 | Push work down | The database sorts and joins, the data platform crunches; the Sutra orchestrates and checks. |
| 10 | Least rights, both ways | Every entry point has a policy; every connection signs in with its own account with only the rights it needs. |
| 11 | Observable by design | Steps named and described, business keys logged, step data kept as the Sutra's sensitivity allows. |
| 12 | Rules decide, people approve, AI assists | Business rules are ordinary steps; decisions with risk go to a person; AI classifies, extracts and drafts. |
3. Projects, folders and naming
Names are read far more often than they are written: in mappings ({nodes.Find the customer.rows}), logs, run history, alerts, the generated documentation and the Admin Console. A good name says what the thing is or does, in the words of the business.
Projects and folders
- Must: one project per business domain or bounded context (Orders, Billing, Customer care), not per person or per technology. A project is the unit of release, properties and connections.
- Should: folders inside a project by business capability:
Orders/Intake,Orders/Fulfilment,Orders/Reports. Shared called Sutras inShared(orLib); test helpers inTest. - Should: resources (connections, policies, knowledge bases, memory tables) in Resources folders named after the system they reach:
Resources/ERP,Resources/Payments. - Must not: copy a Sutra to change it a little. Make the difference a property or an input of a called Sutra.
Naming conventions
| Thing | Convention | Good | Avoid |
|---|---|---|---|
| Project | Business domain, title case | Orders, Customer care | Project1, Ravi test |
| Sutra | Verb and object; what it does for the business | Accept order, Send invoice email, Sync stock from ERP | Flow 3, REST handler, New Sutra 2 |
| Called Sutra | What it returns or does, as a function name in words | Calculate tax, Find customer by email | Helper, Sub 1 |
| Step | What it does here, in a few words; unique in the Sutra | Find the customer, Reserve stock, Reply 201 | SQL query 2, Map data, HTTP |
| Connection | System and purpose (and access, when it matters) | ERP orders (read), Payments API, Warehouse queue | DB1, Connection, Test conn |
| Security policy | Who it lets in | Partner apps, Internal API key, Company SSO | Policy 1 |
| Schema | Business document and direction or version | Order request, Order v2, Invoice | schema1, test.json |
| Project property | UPPER_SNAKE_CASE, system first | ERP_BASE_URL, ORDERS_QUEUE, INVOICE_FOLDER | url, x |
| Secret | UPPER_SNAKE_CASE, what it unlocks | PAYMENTS_API_KEY, ERP_DB_PASSWORD | secret1 |
| Channel | Business event, past tense, lower case with dots | order.accepted, stock.low | channel1 |
| Queue or topic | Domain, event, environment where the broker is shared | orders.accepted, prod.orders.accepted | q1 |
| REST path | Plural nouns, lower case, hyphens; a version in front when public | /v1/orders/:id, /v1/customer-notes | /getOrder, /Orders_Get |
| Local variable | camelCase; Record IDs for groups of values | {vars.1.batchNo}, {vars.customerId} | {vars.temp} |
| Counter | What it counts | orders-today, invoice-number | c1 |
Descriptions
- Must: every Sutra has a description: what it does, what starts it, what it changes, who owns it.
- Should: every step has a description (General tab) that says why it is there, not what its type is: Customers may only see their own orders: filter by the token subject.
- Descriptions flow into the generated documentation (Documenting Sutras), so a well-described project documents itself.
Building blocks
4. Anatomy of a Sutra
Most Sutras follow the same shape. Using it everywhere means anyone can open a Sutra and find their way.
| Stage | What happens | Typical activities |
|---|---|---|
| 1. Receive | The trigger starts the run with the request, message, file or event. | REST service, SOAP service, Queue / topic trigger, File trigger, Timer, Channel trigger |
| 2. Validate | Refuse what is wrong, with a clear reason. | Body schema on the trigger, Validate fields, If / else |
| 3. Enrich | Look up what the work needs. | SQL query, Send HTTP request, Get Memory Record, Call Sutra |
| 4. Transform | Shape the data for the target. | Map data, Map JSON Data, Map XML Data, Transform (JSONata) |
| 5. Act | Change something: write, send, publish. | SQL update, SQL transaction, Publish message, Write file, Send HTTP request |
| 6. Reply | Answer the caller, as early as possible. | Send HTTP response, SOAP reply, Return, Confirm message |
| 7. Record | A business milestone in the log. | Log |
| Error path | What happens when a step fails. | Error outputs, Error handler, Throw error, End |
Rules
- Must: a Sutra with a caller waiting (REST, SOAP, MCP, a called Sutra with Wait) reaches its reply on every path, including errors. A path without a reply makes the caller wait until Reply wait runs out (504).
- Should: lay the canvas out left to right in the order above, the happy path on one line and error paths below it.
- Should: connect the error output of every step that talks to another system, or rely on an Error handler that handles every failure the same way (see Error handling).
- Should: end branches that are finished with End where it makes the intent clear (stop this branch, or end the run with a status).
- May: mark a step still to be designed with No operation; it must be gone before release.
Lanes: what a step can see
A step can use the trigger, properties, Local variables and the outputs of the steps before it on a connected path; nothing from another lane (What a step can see). The designer, the design check and the engine apply the same rule.
- Must: a step that needs the results of two lanes comes after the step where they meet, usually a Merge. A reference to a step on another lane is a design problem and fails the step at run time.
- Should: read request data as
{{trigger…}}in later steps rather than carrying it from step to step; it is the same on every path. - Should: run Tidy after large changes and check the line colours where lanes meet: every line into a Merge should come from a lane you meant to join.
- Should: give a line a colour by hand only where it helps a reader (a lane you name in the description); meaning must never depend on colour alone.
Durable or in memory
| Durable (default) | In memory | |
|---|---|---|
| Saved | Every step; a run survives a restart and continues on another engine | Only the finished run |
| Speed | Good | Several times faster for short Sutras |
| Waits, approvals, long work | Yes | No: steps cannot wait |
| Use for | Anything that changes data, waits, or must not be lost | Short request and reply lookups that can be repeated by the caller |
Should: choose in memory (Sutra tuning, Execution) only for read-only or repeatable request and reply Sutras of a few steps. When in doubt, durable.
5. Functions and transformations in detail
Most of a Sutra's logic is data work: picking fields, reshaping documents, calculating, formatting. SutraFlow gives several ways to do it. Choosing the right one keeps Sutras readable and fast.
Choose the tool
| Need | Use | Why |
|---|---|---|
| Build a document field by field, with repeating lines | Map data, Map JSON Data (typed JSON), Map XML Data (XML with namespaces and attributes) | Visual, checked against schemas, documented automatically |
| A value in a setting (a file name, a message) | An = formula or {{ }} reference in the field | No extra step |
| Group, pivot or query a whole JSON document | Transform (JSONata) | One expression does what many mapping rules would |
| Filter, sort or total a list | Filter list, Sort list, Aggregate, or a For-Each with Where and Sort by in a mapping | Clear intent, no code |
| Logic that formulas cannot express (loops with state, special algorithms) | JavaScript code | Full language, sandboxed, with a time limit |
| Libraries of a language (data science, a vendor SDK) | Python script, PowerShell script | Runs on the server; needs scripts allowed by an administrator |
| Parse or render a format | Parse JSON, Render JSON, Parse XML, Render XML, Parse CSV, Render CSV, HTML template | Checked against the schema, errors on bad input |
- Should: prefer mappings and formulas to code. A reviewer can read a mapping; code needs reading line by line, and it hides fields from the data trees.
- Should: one mapping step instead of a chain of small transform steps; every step costs a save and a round trip.
- Must: code steps have no side effects beyond their output (no files, no network) unless that is their documented purpose.
Writing formulas
Formulas start with = in a plain field and are implied in mapping targets. References are in braces: {input.orderId}, {nodes.Find the customer.rows}, {vars.1.batchNo}, {gv.INVOICE_FOLDER}. The full list is the Function reference; Sample: Functions (New Sutra, Samples) runs every one of them on an order.
- Should: reference earlier steps by name (
{nodes.Find the customer}) rather than{input}when the value comes from further back: it survives inserting a step in between. - Should: keep a formula to one line a reader can follow; split a long one over two mapping fields or use Transform (JSONata).
- Must: handle missing values on purpose. A field that may be absent gets a default (
if(empty({input.note}), '', {input.note})) rather than leakingnullinto a target system.
Function groups: patterns and pitfalls
| Group | Typical use | Watch for |
|---|---|---|
| Text | Clean names, build codes, pad numbers: concat, upper-case, substring, replace, pad | trim removes spaces at the ends only; normalize-space also collapses inner runs (asha KUMAR becomes asha KUMAR). The Output tab shows spaces as they are. |
| Conversion | Text to number or boolean and back | Convert at the door; a number held as text sorts as text ("10" before "9"). |
| Dates and times | Format, add days, compare, parse partner formats | Keep and send times in UTC with an offset (ISO 8601); convert to local time only for people. State the time zone of every partner field. |
| Numbers | Totals, tax, rounding | Round money once, at the end, to the currency's places; never add rounded parts. Keep amounts and currency together. |
| Logic | if, comparisons, empty, exists | An empty text, a missing field and null are different; test the one you mean. |
| Lists and sequences | Count, sum, join, distinct, position | For per-item work in a mapping use For-Each (with Where, Sort by, Group by), not formulas over indexes. |
| Encoding | Base64, URL encoding, hashes | A hash is not encryption; secrets come from the vault, never built in formulas. |
| Variables and utility | Run id, UUIDs, current time, properties | Use the run id as a correlation id and as an idempotency key for calls that accept one. |
Mapping repeating data
- For-Each over a list with Where (skip lines), Sort by and Group by (one target line per group with
{group.key},{group.count},{group.items});position()numbers lines. Sample: For-Each mapping shows each. - Should: map against a schema on both sides, so the mapper checks every target field and the designer warns about a missing source.
- Should: look up codes (country names, tax rates, product groups) in a memory table or a small reference table, not in long nested
ifformulas.
6. Reusable logic: called Sutras, variables and counters
A called Sutra is SutraFlow's function: it takes an input, does one job and hands back a result with Return. Call Sutra calls it, with Wait on to continue with the result.
Designing a called Sutra like a function
- Must: an input schema and a result schema, with Validate input and Validate result on for shared Sutras: the contract is checked on every call, and the data trees of callers show its fields.
- Must: the input schema lives on the called Sutra's Manual start, with strict validation on, and callers follow it with Input contract from the called Sutra instead of copying it. A change shows in every caller until someone accepts it (Inputs of called Sutras).
- Should: an XSD on the Manual start when the callers hold XML: the called Sutra receives the Parse XML shape plus the original text, so it maps the same way as JSON and can still pass the XML on.
- Must: every path ends in Return (or fails). A path that just ends leaves a waiting caller without a result.
- Should: a pure function where possible: the same input gives the same result, no changes outside. Sutras that do change things say so in their name (Reserve stock) and are safe to repeat.
- Should: callers use the deployed version (the default while not testing is deployed (draft while testing)), so a half-finished draft never runs in production.
- Should: keep it small and generic: Calculate tax takes an amount and a country, not a whole order.
- May: call without waiting to start independent work (a notification, an audit copy). Its failure does not reach the caller, so it needs its own error handling.
One run per item
For work on many items with several steps each, call a sub-Sutra per item from a For each: each item gets its own run, retries and history, and items run in parallel on free workers. A failed item can be found and run again on its own.
Local variables, counters and properties
| Kept in | Lives for | Use for | Activity |
|---|---|---|---|
| Local variables | One run | Values several later steps need (a batch number, a running decision). Record IDs group them: {vars.1.batchNo}, {vars.2.total}. | Set Local Variable, Get Local Variables |
| Counter | The project, across runs and restarts | Sequence numbers, daily totals; safe when many runs change it at once | Counter |
| Memory table | The project, cached on every engine | Reference data read often, changed rarely | Get Memory Record, Set Memory, Query Memory Records |
| Project and Engine properties | Configuration per environment | Addresses, folders, limits | {gv.X}, {ev.X}, Get Properties |
- Should: prefer step outputs (
{nodes.Step}) to local variables; set a variable only when the value is computed in one place and read in several. - Must not: use a local variable to pass data between runs; it lives for one run. Use a counter, memory table or database.
7. Data contracts and schemas
A contract is the agreed shape of a document: what a caller sends, what a Sutra returns, what goes on a queue. In SutraFlow it is a shared schema (JSON Schema or XSD) or a WSDL in the project (Schemas and WSDLs).
- Must: every public entry point (REST body, SOAP operation, queue message, channel, called Sutra) has a schema.
- Must: validate untrusted input against it at the door: REST Validate body: reject invalid (a 400 with the problems), SOAP against its WSDL, queue messages with Validate fields before any change. Strict validation on Manual start, Call Sutra and Return checks the rest.
- Should: a canonical document per business object inside a domain (one Order shape), with mappings at the edges to and from each partner's shape. Partners change; the inside stays stable.
- Should: describe fields in the schema (
description), with formats (date-time,email), patterns and enumerations; the gateway's OpenAPI and the generated documentation show them. - Must: run Check schema change impact before saving a change to a shared schema: it lists the Sutras and mappings affected.
Changing a contract
| Change | Breaks callers? | How |
|---|---|---|
| Add an optional field | No | Add it; callers that do not know it ignore it. |
| Add a required field to a request | Yes | Make it optional with a default first; require it in the next version. |
| Rename or remove a field, change a type | Yes | New version of the schema and of the entry point (/v2/orders, Order v2); run both until callers have moved. |
| Add a value to an enumeration in a response | Maybe | Tell callers first; strict clients may refuse unknown values. |
8. Configuration and secrets
The same Sutra runs on development, test and production. What differs is configuration (Variables and the deployment config).
| Value | Where it lives | Referenced as |
|---|---|---|
| Addresses, folders, queue names, limits that differ per environment | Project properties, overridden per environment in the deployment config | {{gv.ERP_BASE_URL}} |
| Values that belong to a server (its region, its role) | Engine properties | {{ev.REGION}} |
| Passwords, keys, tokens, certificates' private keys | The vault, chosen in connections as Secret properties | The secret's name in the connection; never in a step |
| How to reach a system and sign in | A connection resource | Chosen on the step |
- Must: no address, password, key, path or environment name typed into a step.
- Must: secrets only in the vault; each environment has its own values; rotate by changing the secret, not the Sutra.
- Should: a property has a sensible development default and a description; production values are set in the deployment config, not in the designer.
- Should: one connection per system and purpose, shared by all Sutras of the project that need it; its pool and limit then protect the system for all of them.
APIs and web services
9. REST API design
A REST service is a REST service trigger with a path and a method, answered by Send HTTP response. The gateway serves it, checks its policy and lists it in OpenAPI (The API gateway).
Resources and paths
- Must: paths name resources, not actions:
GET /v1/orders/:id, not/getOrder. Plural nouns, lower case, hyphens. - Should: one Sutra per method and path, or a small group of closely related ones; a Sutra that answers
ANYand branches on the method is harder to secure and document. - Should: a version at the front of public paths (
/v1/); internal services between your own Sutras may leave it out. - Actions that are not create, read, update or delete become sub-resources:
POST /v1/orders/:id/cancellation.
Methods
| Method | Use | Safe to repeat | Success answer |
|---|---|---|---|
| GET | Read one or a list | Yes | 200 with the resource |
| POST | Create, or start a job | No: design it to be (below) | 201 with the new resource and its address; 202 for a job |
| PUT | Replace a whole resource | Yes | 200 or 204 |
| PATCH | Change some fields | Should be | 200 or 204 |
| DELETE | Remove | Yes | 204 |
Status codes and errors
| Code | When |
|---|---|
| 400 | The request is wrong: failed validation, a missing field. Say which fields. |
| 401 / 403 | Not signed in / not allowed. The gateway's policy answers these before the Sutra runs; your Sutra answers 403 for business authorisation (a customer asking for another customer's order). |
| 404 | The resource does not exist (or the caller may not know that it does). |
| 409 | A conflict with the current state: a duplicate, a version mismatch, an order already shipped. |
| 422 | Valid shape, but the business rules refuse it. |
| 429 | Too many requests: answered by the gateway's rate limits and plans. |
| 500 | Something failed inside; the caller cannot fix it. Never with internal details. |
| 502 / 503 / 504 | A system behind the Sutra failed, is unavailable, or was too slow. |
Must: every error answer has the same body shape across the project, for example:
{ "error": { "code": "ORDER_NOT_FOUND", "message": "Order A-1001 was not found", "details": [], "runId": "..." } }
- Must not: put stack traces, SQL, host names or secrets in an answer. Log them; answer with a code and the run id so support can find the run.
- Should: an Error handler in each API Sutra that replies 500 with the standard body, so an unexpected failure still answers.
Safe to repeat, asynchronous work and large lists
- Should: POST that creates is made safe to repeat with a business key the caller sends (an order number, or an
Idempotency-Keyheader kept with the result): a second call with the same key returns the first result instead of creating twice. A unique key in the database enforces it. - Must: work that takes longer than a few seconds answers 202 with a job id at once and continues after the reply (Send HTTP response early, or Call Sutra without waiting); a
GET /v1/jobs/:idservice reports progress. Raising Reply wait is the last resort. - Should: lists are paged (
?limit=50&after=A-1001) with a maximum page size, and filtered by query parameters, never returning a whole table. - Should: set Max body size to what the service needs (1024 KB by default); bigger documents are uploaded as files.
Documentation
The gateway builds OpenAPI from deployed REST services, their policies and body schemas (Admin Console, Gateway, APIs; published on the gateway when chosen). Should: a body schema with descriptions and a realistic test request on every service: the OpenAPI document, the designer's test run and sutra test all use them. Sample: JSON microservices shows three services that call each other.
10. SOAP web services
SOAP services are contract-first: the WSDL comes first, the Sutras follow it. SOAP service serves operations of a WSDL on the gateway (and generates a WSDL when you start without one); SOAP reply answers; Invoke SOAP service calls other SOAP services.
- Must: import or write the WSDL (and its XSDs) into the project before building; agree it with the consumers.
- Should: one Sutra per operation for busy services, or one Sutra with a Switch on the operation for a small service; the WSDL stays one document either way.
- Must: business errors answered as SOAP faults with a fault code and a readable string (and a detail element when the WSDL defines one), not as a normal response with an error flag.
- Should: build replies with Map XML Data against the WSDL's types, so the reply is checked before it leaves.
- Must: a security policy: WS-Security UsernameToken with a time window and replay protection, X.509 signatures and encryption, SAML assertions, or mutual TLS (Exposing APIs: security and TLS).
- Should: give consumers a mock first: a SOAP service with canned replies from the WSDL, so they build while you do. Sample: Mock SOAP service and its caller shows one.
- Calling a SOAP service: Invoke SOAP service with the partner's WSDL, a connection with its security profile, its fault output connected, and a timeout that fits the partner.
11. API security and the gateway
Every request to a deployed Sutra passes, in order: the firewall, the service's security policy (HTTPS, IP rules, authentication, rate limit, CORS), the scopes the service requires, and for gateway apps their plan. A refused request never starts the Sutra.
- Must: every entry point on the gateway (REST, SOAP, WebSocket, MCP, agent channels) has a security policy. The designer and Deploy warn about one without.
- Must: Require HTTPS stays on for anything reached over a network you do not control.
- Should: choose authentication by caller: API keys for a few systems of your own, gateway apps (an app per caller with scopes, a plan and keys or OAuth client-credentials tokens) for partners, JWT from the company's identity provider for its users, mutual TLS for closed B2B links. The user guide's Designing Sutras has the full table.
- Should: scopes per service and operation (
orders:read,orders:refund); a caller gets only the scopes it needs. - Must: authorisation inside the Sutra for data that belongs to someone: the caller's identity is
{trigger.auth.subject}(and{trigger.auth.claims}for JWT); a customer reads only rows where the customer id is theirs. - Should: a rate limit on every public policy, and plans per gateway app, so one caller cannot starve the others.
- Should: CORS origins only for services browsers call, listing the real sites, never
*with credentials.
Behind a reverse proxy or load balancer
When Apache, nginx, IIS or a cloud load balancer is in front of SutraFlow, list it under Admin Console, Gateway, Firewall, Trusted proxies. From a trusted proxy, SutraFlow reads the caller's real address (X-Forwarded-For) and the HTTPS the proxy ended (X-Forwarded-Proto); from anyone else it ignores both. Without it, every caller has the proxy's address, so IP rules and per-address rate limits treat all callers as one, and Require HTTPS refuses calls forwarded over plain HTTP. Must: list only proxies that replace those headers, never a range callers reach directly. The Administration Guide has the proxy settings (Planning a server).
12. Calling other services
Every call out of a Sutra (REST, SOAP, a database, a queue, an app) is a place where another system can be slow, down or wrong. Design each one for that (Calling services).
| Concern | Rule | Where |
|---|---|---|
| Identity | Must: a connection with its own account and security profile (Basic, bearer, API key, OAuth 2.0 client credentials, WS-Security, client certificate); never credentials in the step. | Connection |
| Time | Must: a timeout that fits the system: short for lookups (a few seconds), longer for known slow work. The default 2 minutes is rarely right for an API call. | Step Settings, Timeout |
| Retries | Should: retries for transient failures (3 retries, 1 s first wait, doubling) on calls that are safe to repeat; none on calls that are not, unless the call carries an idempotency key. | Step Settings, or Sutra tuning for all steps |
| What counts as failure | Should: Fail on 4xx or 5xx (the default) and the error output connected; handle the 404 you expect as data, not as an error. | Send HTTP request Fail on |
| A system that keeps failing | Should: the connection's circuit breaker, so calls stop for a while instead of piling up. | HTTP connection |
| How much at once | Should: a connection limit (Maximum concurrent activities) on systems with a capacity: across all engines, steps wait for a place instead of overloading it (Connection limits). | Connection |
| Answers | Should: a response schema, so the mapping after the call is checked and documented. | Send HTTP request Response schema |
- Should: independent calls in parallel branches joined by a Merge, not one after the other.
- Should: send the caller's subject as data when the other system needs to know who asked; do not pass the caller's credentials on.
13. WebSockets, AI tools and agent endpoints
WebSocket services
- WebSocket service starts a run per message (in order per connection unless the service says otherwise); WebSocket send answers one connection or broadcasts to every connection of a service, across engines.
- Must: a policy (browsers send a token or key in the query) and CORS origins for browser clients; size, depth and schema limits on messages.
- Should: clients reconnect with a pause and treat broadcasts as notices, not a ledger: a client that is reconnecting (after a network drop or an engine stop) misses what was sent meanwhile. Keep the state in a system the client can read again (a REST service) and use the broadcast to say "read again". A just-connected client gets the next broadcast, and an engine that died no longer collects broadcasts to send to the wrong clients later.
AI tools (MCP) and agents
- An AI tool is a Sutra with AI tool and Reply to AI: design it like a REST service with a schema, a policy and a clear description, because the model reads the description to decide when to call it.
- Must: tools that change data check the caller and the input inside the Sutra; the model is not an authorisation layer.
- Should: AI guard before agents on public entry points; limits on steps, tokens and time; Ask a person for anything with risk. The user guide's AI agents and knowledge bases has the details.
Integration processes
14. Integration patterns
The well-known integration patterns and how to build each one with Sutras. Use the pattern's name in the Sutra's description, so reviewers know what to expect.
| Pattern | Problem it solves | Build it with |
|---|---|---|
| Request and reply | A caller needs an answer now | REST service or SOAP service, short path, Send HTTP response |
| Acknowledge, then work | The work is long; the caller must not wait | Reply 202 early, continue; or Call Sutra without waiting |
| Fire and forget | Tell another part without waiting | Send to channel or Publish message |
| Publish and subscribe | Many parts react to one event | A broker topic (Publish message / Queue / topic trigger) or an internal channel with several Channel trigger Sutras |
| Polling consumer | A system that cannot call you | Timer, read changes since the last mark, process, save the mark |
| Event-driven consumer | React when something arrives | File trigger, Remote file trigger, Queue / topic trigger, Email trigger, SharePoint / OneDrive trigger, Google Drive / Docs trigger |
| Message filter | Drop what is not wanted | If / else or a connection condition, then End; Filter list for lists |
| Content-based router | Send to a path by content | Switch (one value, many cases), Router (conditions, first or all matches), connection conditions with otherwise |
| Splitter | Process items of a document one by one | For each (parallel), the step Loop setting (in order), or a sub-Sutra per item |
| Aggregator | Join results back together | Merge for branches; the done output of For each; Aggregate for totals |
| Scatter and gather | Ask several systems, combine | Parallel branches with calls, then Merge, then a mapping |
| Content enricher | Add data the message lacks | A lookup (SQL query, Send HTTP request, Get Memory Record) and a mapping |
| Normaliser and canonical model | Many partner formats, one inside | A mapping per partner into the canonical schema at the edge |
| Claim check | Large documents through a flow | Store the file, pass its path or id; large inputs are stored once automatically |
| Process manager (orchestration) | A business process across systems | A parent Sutra calling sub-Sutras with Call Sutra, waiting where needed |
| Saga with compensation | Several systems, no shared transaction | Each step has an undo step; on failure, run the undo steps of what succeeded, in reverse (Error handling) |
| Guaranteed delivery | A message must not be lost | Durable Sutras, persistent broker messages, acknowledgement after success |
| Idempotent receiver | The same message may arrive twice | Queue / topic trigger Deduplicate with a duplicate key; a unique business key in the database |
| Dead-letter channel | A message that cannot be processed | On failure: reject (dead-letter) after Maximum redeliveries; a Sutra that watches the dead-letter queue |
| Human task | A person must decide | Human approval, Ask a person |
| Wire tap | See traffic without changing it | Log with business keys, or a copy to a channel |
Orchestration or choreography
Orchestration: one parent Sutra calls the others in order and knows the whole process; easy to follow and to change, one place to see where a process stopped. Choreography: each Sutra reacts to events and publishes its own; parts are independent, but the process exists only as the sum of the reactions. Should: orchestrate a business process with a clear owner and order (an order from payment to shipping); use events to tell other domains what happened (order.shipped), so they do not depend on your process.
15. Messaging design
Queues and topics decouple systems: the sender does not wait for the receiver, and a slow or stopped receiver catches up later. SutraFlow speaks to Kafka, RabbitMQ and ActiveMQ (AMQP 1.0) with Publish message, Queue / topic trigger and Confirm message, and has internal channels for Sutras of one project (Messaging).
Channel or broker
| Internal channel | Broker queue or topic | |
|---|---|---|
| Between | Sutras of one project | Any systems, across projects and servers |
| Needs | Nothing | A broker |
| Use for | Splitting your own work into steps that react to each other | Integration with other systems, buffering load, delivery that must survive anything |
Acknowledgement
| Acknowledge | The message is settled | Use when |
|---|---|---|
| auto | On receipt, before the Sutra runs | Losing a message on failure is acceptable (metrics, notices) |
| client (default) | When the run succeeds; on failure by On failure (requeue or dead-letter) | Most work |
| explicit | Where Confirm message says (confirm, requeue or reject) | Only after something specific succeeded, for example after the outgoing broker accepted the result |
- Must: processing is safe to repeat: brokers deliver at least once, and a redelivery after a failure or an engine stop is normal. Keep Deduplicate on with a Duplicate key (a message id or business key), and make database changes idempotent.
- Must: a dead-letter path: On failure: reject (dead-letter) after a few redeliveries (Maximum redeliveries), and someone or something watching the dead-letter queue. Requeueing for ever blocks the queue with one bad message.
- Should: persistent delivery and publish confirmation (Kafka acks: all) for business messages.
- Should: a message id and a correlation id on every message (the run id, or the business key), so a message can be traced across systems.
- Should: Concurrency above 1 only when order does not matter; for order per key, use a Kafka key (orders of one customer go to one partition) and keep concurrency per partition.
- Should: a schema per message type, validated on receipt; malformed messages fail before any change.
Sample: Queue in and out takes messages from a broker, reshapes and publishes them, and confirms only after the outgoing broker accepted them.
16. Files and batch processing
- Must: a file trigger waits until the file is complete (stable for some seconds), and a file is moved to a
processed/orerror/folder after the run, so it is not read twice and failures can be found (Files). - Should: one run per file: a trigger per file, or a list without reading and a sub-Sutra per file.
- Must: big CSV and line files are streamed (Stream in batches), never read whole. Batches go out on the batch output while reading goes on; reading pauses while too much waits (back pressure: the number of waiting batches, and also 8 MB of input in flight), so memory stays the same for 10 MB and 10 GB.
- Should: Step data in history set to none for streaming Sutras; every batch is otherwise kept until the run ends.
- Should: batch sizes of 1,000 to 5,000 rows; each batch is a step and counts towards Steps per run.
- Should: database batches paged by key (
where id > :last order by id limit 1000), one page per run or per sub-Sutra call, with the last key saved, so a stopped batch continues where it was. - Should: SFTP and FTP with the host fingerprint checked and a key rather than a password; archive names with a date.
Learning big documents into a knowledge base: stream them in parts of a few thousand lines into Add to knowledge with a source name per part, into a pgvector knowledge base for large volumes. Measured in 2.1.4: a 48 MB document in 54 parts, about 140 MB of live heap at 32 workers, and back to the starting memory after the run.
17. Databases and data stores
The user guide's Designing Sutras has the full rules for SQL; the essentials:
- Must: parameters, never values pasted into SQL. Run data written into SQL is bound as parameters automatically; properties (
{{gv.SCHEMA}}) are written into the text. Anything that changes the statement itself (a sort column) is checked against a fixed list first. - Must: changes that belong together in one SQL transaction or a stored procedure (Call procedure).
- Should: only the columns needed, with a
whereon indexed columns and Maximum rows; one set-based statement instead of a step per row. - Should: upserts or
insert ... on conflict do nothingwith a business key, so repeated runs do not duplicate. - Should: the database's own account per purpose (read-only for reporting Sutras); pool sizes and connection limits within what the database allows for all engines together.
- Should: schema changes as SQL script in a release Sutra, written to run twice safely.
| Store | Use for |
|---|---|
| Relational database (PostgreSQL, MySQL, SQL Server, Oracle) | Business records, transactions, reporting |
| MongoDB | Documents whose shape varies, with the activities of the MongoDB palette |
| Memory tables | Reference data read on every run: codes, rates, mappings; refreshed from a source table |
| Counters | Numbers many runs change: sequences, totals |
| Knowledge bases | Text searched by meaning, for RAG |
18. Error handling, retries and compensation
Decide for every kind of failure where it is handled and what the caller or the operator sees.
| Kind | Example | Retry? | Handle by |
|---|---|---|---|
| Validation | A required field is missing | No | Reply 400 (or a SOAP fault, or dead-letter the message) at the door |
| Business | Not enough stock; credit limit reached | No | A normal branch (an If), a 409 or 422 reply, a message to a person |
| Transient technical | A timeout, 503, a dropped connection | Yes, with backoff | Step retries; after the last one, the error output |
| Permanent technical | 401 from a partner, a missing table, bad configuration | No | Error output or Error handler: alert, reply 500/502, stop |
Where to handle
- Error output of a step: for failures you can do something specific about (a fallback, a cached value, a clear reply).
- Error handler (Error handler): runs when a step fails and its own error output is not connected; other branches stop. Should: one per Sutra for the common response: log with the input, alert, reply 500 to an API caller, dead-letter a message.
- Throw error: fail on purpose with a message when a business check fails deep in a branch and the Error handler should take over.
- End with an error status: end the run as failed after handling, so it shows as failed in Runs and in alerts.
Retries and timeouts
- Should: 3 retries with a 1 s first wait (doubling) on calls to other systems that are safe to repeat; set them once in Sutra tuning (Retries, First retry after) and override on single steps.
- Must not: retry what is not safe to repeat (a payment without an idempotency key) or what cannot succeed (validation, 401, 404).
- Should: a run time limit on Sutras that wait (approvals, long jobs), so forgotten runs end.
Compensation
Several systems rarely share a transaction. When step 3 of 4 fails after steps 1 and 2 changed other systems, undo them: each changing step has an undo (release the stock reservation, refund the payment), and the error path runs the undo steps of what succeeded, in reverse order. Must: undo steps are safe to repeat and are themselves retried; a failed undo alerts a person.
What the outside sees
- Must: callers get a standard error body with a code and the run id; operators get the full detail in the run and the log.
- Should: alert rules (Admin Console) on failed runs, slow runs and waiting approvals, rather than people reading logs.
19. Logging, audit and traceability
- Should: one or two Log lines per run at info for business milestones, with the business keys: Order A-1001 accepted: 3 lines, 2,450 INR. The run id is added for you.
- Should: warn for unexpected but handled; error for what a person must look at; debug only while finding a problem (the user guide's level table).
- Must not: log secrets, passwords, tokens, card numbers or whole personal records. Secret values are masked; other personal data is the designer's care.
- Should: Step data in history (Sutra tuning) all while building, errors only for busy production Sutras, none for Sutras with sensitive data or streaming.
- Should: a correlation id through every hop: the business key in logs and messages, the run id in error answers and as the message correlation id, and
traceparenton HTTP calls (passed on for you) so traces join across systems. - Where logs go: the run's log and each step's Output tab, the project log file (Project, Logging; JSON for collectors), metrics at
/metricsand traces to an OpenTelemetry collector (Trace sampling). - Audit: who changed, deployed or approved what is kept by SutraFlow in the audit log; your Sutra records business decisions (who approved a refund) in your own system.
Microservices
20. Microservice design with Sutras
A microservice is a small service that owns one business capability and its data, and can be changed and released on its own. In SutraFlow a microservice is a set of Sutras behind gateway paths, with their own connections and schemas, usually one project or one folder of a domain project.
Boundaries
- Should: draw boundaries around business capabilities (customers, stock, orders, invoices), not around technical layers (a "database service", a "mapping service").
- Must: a service owns its data. Other services ask it through its API or react to its events; they do not read its tables.
- Should: a project per service when teams release separately; folders of one project when one team owns several small services that are released together.
- Should: size by change: things that change together belong together. A service that cannot change without three others changing is too small (or the boundary is wrong).
Talking to each other
| Style | Use when | With |
|---|---|---|
| Synchronous request (REST, SOAP) | The caller needs the answer to continue (price, stock check) | Send HTTP request to the other service's gateway path, with timeout, retries and a circuit breaker |
| Asynchronous event | Others should know something happened; nobody waits | Publish message of order.accepted; subscribers in their own services |
| Asynchronous command | Ask another service to do work, answer later | A message to its queue, a reply message or callback |
- Should: prefer events between services; a chain of synchronous calls (A calls B calls C) fails when any of them fails and is as slow as their sum.
- Must: a synchronous call between services has a timeout shorter than the caller's own reply time, and a fallback or a clear error when the other service is down.
- Should: services call each other through the gateway with a policy (an internal API key or a gateway app), like any other caller; never by reaching into another project.
- Should: each service publishes its API (OpenAPI from the gateway) and its event schemas; consumers code against those, not against its Sutras.
Anti-patterns
| Anti-pattern | Sign | Instead |
|---|---|---|
| Distributed monolith | Services must be released together | Move the boundary; version APIs; use events |
| Shared database | Two services write the same tables | One owner; the other asks or listens |
| Chatty calls | Dozens of calls to answer one request | A coarser API; a cached copy kept up to date by events |
| Entity services | A "customer CRUD" service with no rules, called by everything | Services around capabilities with their rules inside |
Sample: JSON microservices shows three services: Customers and Stock answer on their own; Orders calls both and returns one reply, or 404, 409 or 502.
21. Resilience, scaling and performance
| Technique | Protects against | In SutraFlow |
|---|---|---|
| Timeouts | Waiting for ever on a stuck system | Step Timeout; Reply wait for gateway callers; run time limit |
| Retries with backoff | Short outages | Step or Sutra Retries, doubling waits |
| Circuit breaker | Hammering a system that is down | HTTP connection circuit breaker |
| Bulkhead | One system or Sutra using everything | Connection limits (Maximum concurrent activities); Runs at once per Sutra |
| Back pressure | A fast producer flooding a slow consumer | Queues between them; streaming batches pause (also by input size); Runs at once queues runs |
| Rate limits and plans | Callers using too much | Gateway policies and plans |
| Durable runs | Engine and server stops | Durable execution: steps continue on another engine |
| Idempotency | Duplicates from retries and redeliveries | Business keys, deduplication, upserts |
Performance
- Should: measure first: Runs shows each step's time, the Admin Console runs and failures per Sutra, Gateway Traffic time per service,
/metricsand traces the rest. - Should: reply early, run independent calls in parallel, use fewer and bigger operations, keep step outputs small (references, not content).
- Should: in memory execution for short repeatable request and reply Sutras.
- Should: Priority for urgent Sutras when work waits in the queue.
- Scaling out: more Steps at once where steps mostly wait on other systems; more engines on PostgreSQL where the CPU is busy. The Administration Guide covers sizing and clusters.
Solution blueprints
22. Packaging: properties, connections and secrets
A release package carries the project's Sutras, connections, schemas and service descriptors. What differs between development, test and production must not be inside them: it goes into properties, connections and the vault, and the deployment config of each environment fills them in. Then one package runs everywhere (Releases, Variables and the deployment config).
| A value like | Put it in | Example |
|---|---|---|
| A folder, a file pattern, a channel or queue name, a limit, a schedule's time zone | A Project property | {{gv.SALES_FOLDER}}, {{gv.ORDERS_QUEUE}}, {{gv.ORDER_EVENTS_CHANNEL}} |
| The address of another service or system, with its timeout, TLS, retry and limit | A connection (HTTP connection: base URL, timeout, circuit breaker, maximum concurrent tasks) | Customers service with base URL {{gv.CUSTOMERS_BASE_URL}}; the step calls /customers/{{input.customerId}} |
| A database, broker, mailbox, SFTP server | A connection of that kind | ERP orders (read), Warehouse queue |
| A password, API key, token, private key | The vault, chosen in the connection as a Secret property | PAYMENTS_API_KEY |
| Who may call a service | A security policy resource | Partner apps |
| A value of the server itself (its region, role) | An Engine property | {{ev.REGION}} |
Making a sample ready to package
Samples are written to run at once on one machine, so several have values typed into steps. Before a sample becomes part of a solution:
- Folders: the file samples write to properties in the project's files folder (
{{gv.SAMPLE_CSV_FOLDER}}is${files}/sample_csv,{{gv.SAMPLE_INBOX_FOLDER}}); give yours names of their own, and let the deployment config of each server set the real path. Prefer${files}(the project's files folder) for files that belong to the project. - Addresses:
http://127.0.0.1:…in the microservice Orders Sutra, the validated HTTP client and the SOAP callers becomes an HTTP connection with a base URL from a property; the step keeps only the path. The connection adds the timeout, circuit breaker and limit in one place. - Policies: the sample services have no security policy (they say so); add one before anything outside the machine can reach them.
- Names: everything a sample stores is named
sample_: channels (sample_orders,sample_order_events), queues (sample_orders.in), tables (sample_sutraflow.sample_sales_orders), counters and folders. A solution drops the prefix: the installer's Remove samples deletes what is namedsample_. Names that differ per environment become properties. - Connections: rename Sample SQLite, Sample SMTP, Local Ollama to what they reach, and point them at the real systems; on a cluster use PostgreSQL rather than an SQLite file.
- Tuning and errors: retries on calls out, an Error handler, Step data in history chosen per Sutra, a run time limit where something waits.
- Remove what is only for learning: expected rejection branches, logs of whole payloads, the No operation placeholders.
One project per release unit
- A project is released as a whole. Keep in one project what changes and ships together (one microservice, one integration); split what ships on its own schedule.
- Shared connections that several projects need (the ERP, the broker) are defined in each project with the same properties; the deployment configs point them at the same system.
- Name packages and tags by project and version (
orders-1.4.0); the release zip carries a deployment config to fill in per environment.
23. Blueprint: a microservices platform
How to grow Sample: JSON microservices (Customers, Stock, Orders) into a platform of services that teams build and release on their own.
Design
| Part | Design |
|---|---|
| Services | A project per service: Customers, Stock, Orders. Each owns its data (its own database or schema) and its paths: /v1/customers, /v1/stock, /v1/orders. |
| Contracts | A JSON Schema per request and reply, validation on at the door (reject invalid), OpenAPI published from the gateway for consumers. |
| Security | A policy on every path. Other services call with a gateway app each (scopes customers:read, stock:read), so a misbehaving caller can be throttled or switched off alone. Outside consumers get their own apps and plans. |
| Synchronous calls | Orders reaches Customers and Stock through HTTP connections (Customers service, Stock service) whose base URL is a property: a short timeout (2 to 5 s), 2 retries for reads, a circuit breaker, and a limit of concurrent calls. Customers and Stock are called in parallel branches with a Merge, not one after the other. |
| Events | Orders publishes order.accepted and order.cancelled to a broker topic; Stock reserves and Billing invoices on their own subscriptions. Nobody waits for them. |
| Data copies | A service that needs another's data often keeps a copy updated by events (a memory table of product names), instead of calling on every request. |
| Errors | The standard error body with a code and the run id; 404 from a dependency becomes the caller's 404 or 422, a timeout or 5xx becomes 502 or 503 (as the sample's Orders does). |
| Tracing | The caller's order number and a correlation id in every log line and event; traceparent passes between services on HTTP calls (Error handling through logs). |
Performance
- Read-only, short services (Customers and Stock lookups) run in memory: several times faster, and the caller simply retries if an engine stops.
- Orders, which changes data and publishes events, stays durable.
- Runs at once per Sutra and connection limits keep one busy service from taking every worker; Priority for the services the business cannot wait for.
Deployment strategy
- Each service is its own Git repository or folder, its own pipeline and its own package (
customers-2.3.0);sutra testruns its test data in the pipeline. - The same package goes to test, then production, with each environment's deployment config (base URLs, broker, database).
- Engines: a cluster on PostgreSQL behind a load balancer (health check
/ready); every engine serves every service, so a service scales by adding engines, not by placing it. - A change that breaks consumers is a new path version (
/v2/orders) deployed beside the old; the old is retired when the gateway's traffic shows no more callers. - Roll back a service alone: Releases, Roll back to its previous package; runs in progress finish on their version.
24. Blueprint: an API for mobile apps
A mobile app is a caller you do not control, on slow networks, with old versions in use for years. Design its API for that.
| Concern | Design |
|---|---|
| Sign-in | Users sign in with the company identity provider; the app sends its JWT, and the policy checks issuer, audience and scopes (JWT with JWKS). Never put an API key that identifies all users in the app: it can be read out of it. |
| Authorisation | Every Sutra filters by the token subject ({trigger.auth.subject}): a customer sees only their own orders. |
| One call per screen | A backend-for-frontend Sutra per screen (GET /v1/app/home) that gathers what the screen needs in parallel branches and returns only those fields: fewer round trips on a slow network. |
| Small answers | Map only the fields shown; page lists (?limit=20&after=…); images as links, not data. |
| Retries from the phone | A phone resends when the network drops: POSTs carry an id made on the phone (an idempotency key) so a resend does not order twice. |
| Versions | Old app versions stay in use: add fields, never rename; a breaking change is /v2/ beside /v1/, retired when the request log shows no old versions. |
| Limits | A rate limit per user on the policy; plans for partner apps. |
| Long work | Answer 202 at once with a job id; tell the phone when it is done by push. |
| Push | Sample: Firebase order to app: save the order, update its live status in the Realtime Database (the app listens), and send a push notification to the device token. |
| Speed | Read-only screens in memory; reply before slow work; cache reference data in memory tables. |
Behind a reverse proxy or a cloud load balancer, list it under Trusted proxies so rate limits and logs see each phone's address, not the proxy's.
25. Blueprint: integration through a message broker
A broker (Kafka, RabbitMQ or ActiveMQ) between systems lets each work at its own pace and survive the others being down. Sample: Queue in and out and Sample: XML queue in and out are the starting point.
Design
- Events and commands: an event says what happened (
order.accepted, on a topic, many subscribers); a command asks one system to do something (invoice.create, on a queue, one consumer). - One canonical message per business event, with a schema, a message id, a correlation id and a timestamp; partner formats are mapped at the edges.
- Receiving: Queue / topic trigger with Acknowledge: explicit when the work ends by publishing, client otherwise; Deduplicate on with a duplicate key; On failure: reject (dead-letter) after a few redeliveries.
- Consume, transform, publish: map, publish and wait for the broker to accept, then Confirm, as the sample does. A message is never confirmed before its result is safely out.
- Dead letters: a Sutra (or an alert) on each dead-letter queue: log the message with its keys, tell a person, and offer to resubmit once fixed.
- Order: where order per customer matters, the Kafka key is the customer id and concurrency stays per partition.
Packaging
- Broker connections per environment: the host, port, TLS files and user come from properties, the password from the vault; the samples' connections (Sample Kafka (TLS + SASL), Sample RabbitMQ (mutual TLS)) show every setting as a property already.
- Queue and topic names as properties (
{{gv.ORDERS_QUEUE}}), so test and production can share a broker without sharing queues.
Broker REST or native
Sample: Broker REST APIs publishes and fetches through Kafka REST, RabbitMQ HTTP and ActiveMQ Jolokia: use it only where a network allows nothing but HTTPS. Native Queue / topic triggers keep the connection open, acknowledge properly and scale; prefer them.
AI workers on a queue
Sample: Agent fed by a queue takes questions from a queue, keeps a memory session per sender, publishes the answer to the reply destination and confirms. The same shape suits any slow worker: the queue absorbs bursts, and Concurrency sets how many run at once.
26. Blueprint: notifications
Most solutions tell someone something: a customer that the order shipped, a team that a job failed. Put that in one place: a notification hub.
Choose the transport into the hub
| Into the hub | Use when | Sample |
|---|---|---|
| Internal channel (Send to channel / Channel trigger) | The senders are Sutras of the same project; nothing to install; the sender does not wait | Sample: Trace notification hub (Traceability and notifications) |
| Broker topic (Publish message / Queue / topic trigger) | Senders in other projects or systems; notifications must survive restarts and outages; several hubs (email, SMS) subscribe | Sample: Queue in and out |
| Call Sutra (Call Sutra) | The sender must know the notification went out (an alert that must not be lost) | Sample: Telegram team alerts |
| Alert rules (Admin Console) | Operations: failed runs, slow runs, gateway errors, engines, approvals waiting, certificates; delivered by email, a signed webhook or a deployed Sutra | Admin Console, Alerts |
Inside the hub
- One event shape for every sender:
{ event, recipient or customerId, data, correlationId, sourceRun }, with a schema. - Decide whom to tell and how (Switch on the event, a memory table of preferences): email (Send email with an HTML template), push (Push notification (FCM)), chat (Telegram, Discord), a webhook (Send HTTP request).
- Templates live in the hub, so the wording of every message is changed in one place.
- Retries on the sending steps; a failed notification is logged with the correlation id and does not fail the business run that asked for it.
- A counter or a table of what was sent, so "did the customer get the email?" has an answer.
Sample: Trace notification hub shows the shape: it starts for every event on sample_order_events, decides between the customer and sales, logs with both run ids and counts. Replace its log steps with real sending steps and its channel name with a property.
27. Blueprint: chat agents for customers and support staff
Two different things are both called "an AI agent". Decide which one you are building first.
| A public agent | Skills for an outside assistant (MCP) | |
|---|---|---|
| Who talks to people | Your agent: on your website, app or chat page | Claude, ChatGPT, Copilot or Cursor; your Sutras are tools it calls |
| Who owns the conversation and its memory | SutraFlow (Agent channel, AI agent with AI memory) | The outside assistant; a skill answers one call and keeps nothing unless it is designed to |
| What you design | The whole dialogue: instructions, tools, guard, hand-off to people, replies | Small, well-described actions with schemas (AI tool, Reply to AI), each checking its own input and caller |
| Who signs in | Your customers and staff, through your website's login | The assistant's app or user, through a policy on the MCP server |
| Samples | Chat for customers and support, AI agent: order desk | MCP skills, AI tool search documents |
A published agent can also be offered to outside assistants as the tool ask_<agent>; then each assistant user's conversation is bound to the gateway app and caller the assistant signed in with (below).
Who is chatting: the website's login, not the message
A website or app that has its own sign-in (its own user table, or an identity provider such as Microsoft Entra ID, Okta, Auth0, Keycloak, Cognito or Firebase Auth) knows who is signed in. It gives the chat a token (a JWT) that says so: who (sub, a name) and what they may do (a role, groups or scopes). SutraFlow never sees their password.
- The policy checks the token. The agent channel's chat policy is a JWT policy: with an identity provider, its JWKS address, issuer and audience; with a website that signs tokens itself, a shared secret (a Secret property) with issuer and audience. A missing, expired, altered or foreign token is refused before any Sutra runs.
- The Sutra reads the person from the token:
{trigger.caller.subject},{trigger.caller.claims.name},{trigger.caller.claims.role},{trigger.caller.scopes}. Never from the message text: a customer typing "I am support" changes nothing. - The chat widget carries the login: the page sets
window.SutraChat = { token: () => currentAccessToken }before loading/chat/<agent>/widget.js. Before each message the chat asks the page for the token (a function may fetch a fresh one), sends it as a bearer token, and asks again when SutraFlow refuses an expired one. The token goes only to the SutraFlow address the widget came from.
Customers and support staff: two designs
| Design | How | Use when |
|---|---|---|
| Separate entry points | A customer agent (/chat/shop-help) whose policy requires the customer scope or audience, and a staff agent (/chat/support-desk) whose policy requires the staff scope, or the company's own single sign-on. A customer token is refused at the staff desk before anything runs. | Staff and customers need different tools, instructions or data: the safest, and the easiest to review. |
| One agent, branching on the role | One agent; an If / else or Switch on {trigger.caller.claims.role} gives staff more (any customer's orders, refunds) and customers less (their own orders only). Sample: Customer and support chat does this. | The dialogue is mostly the same and only the data differs. |
Must: data that belongs to a customer is filtered by {trigger.caller.subject} inside the Sutra (or the tool Sutra), even when the agent "should" only ask for the customer's own orders: the model is not an authorisation layer.
Conversations: signed tokens that expire
- Every answer carries a conversation token: signed by SutraFlow, bound to the agent and to the caller (policy and issuer, subject, gateway app, or the visitor). The caller sends it back to continue (
sessionIdin the chat API,X-Session-Idfor OpenAI-compatible clients,contextIdin A2A,sessionfor the MCP tool). The chat page and widget do this for you. - A token continues the conversation only for the caller who started it. A missing, altered or someone else's token, or a session id a client made up, starts a new conversation: knowing a token gives nobody else anything.
- It lasts the agent channel's Conversation lasts time (24 hours by default; the sample uses 8). The next message after that starts a new conversation. Choose it like a session timeout: long enough for one matter, short enough that an old device does not reopen it.
- Expired conversations keep their AI memory in the database until an administrator clears them: Admin Console, Agent conversations, Clear expired (or
sutra agents clear-expired). Plan it like any retention task: weekly, or after each campaign. - Visitors without a login (a public chat with no policy) get a signed visitor identity in their browser that expires after 30 days (
SUTRA_VISITOR_DAYS) and is renewed while they keep coming back.
The example: a PHP website with its own sign-in
Sample Chat for customers and support comes with a small PHP website, Sutra Sample Shop (samples/sutra-sample-shop, or Download the website (zip) in New Sutra, Samples): its own login (demo accounts for a customer and a support agent), token.php that signs a 15-minute token with the shared secret, the chat widget with window.SutraChat, and check.php to test the setup. SUTRAFLOW_URL in config.local.php points it at this SutraFlow or one on another server. The agent has eight skills (order status, tracking, returns and refunds, invoices, the delivery address, products and stock, a person, help), chosen by keywords: one Switch branch per skill, each applying the role from the token, so a customer sees only their own orders and the support desk every order. Replace token.php with your identity provider's access token, Shop data with your queries, and the keyword step with AI router when you have a model.
Checklist
- A policy on every chat entry point that people outside your company reach; Require HTTPS on in production.
- Roles and scopes from the identity provider, read from
{trigger.caller}; customer data filtered by subject in the Sutra. - Short-lived website tokens (minutes), refreshed by the page; conversation lifetime set per agent; expired conversations cleared on a schedule.
- AI guard before an AI agent on public chats; Ask a person before anything with risk (refunds, cancellations).
28. Blueprint: knowledge bases from databases, APIs and files
A knowledge base does not have to come from documents. Products in a shop's MySQL tables, articles of a Joomla site, tickets in a helpdesk API, policies in SharePoint: anything that can be read can be learned. Add to knowledge takes any text from any step; the source is only where the text came from.
The feed Sutra
| Step | Database (MySQL, PostgreSQL, SQL Server, Oracle) | API | Files |
|---|---|---|---|
| Start | Timer (every 15 to 60 minutes) | Timer, or the API's webhook as a REST service | File trigger, SharePoint / OneDrive trigger, Google Drive / Docs trigger, or a timer over a folder |
| Read | SQL query: only the rows people may see (where published = 1), with the table from a project property | Send HTTP request, page by page | Read file and Read document text |
| Each item | For each, then Map data: one text per item, with the fields a question would mention (name, category, price, description), and the details to keep | ||
| Learn | Add to knowledge: source products/<id> (a stable key per item, so a change replaces it), details (category, price, link) for filters and answers that link, Same text as before: skip so only changed items make vectors | ||
| Clean up | Remove knowledge keep only these sources with the current keys, under products: deleted or unpublished items leave the knowledge base | ||
Sample: Product knowledge feed (Knowledge feed from a database) does exactly this with a MySQL product table; Sample: Product search API answers questions about the products by meaning. Tested on Laragon's MySQL and on a hosted remote MySQL.
Rules
- Must: learn only what the people who will ask may see. Published products for a public chat; for staff, the internal fields too, in another knowledge base or with a detail (
audience = staff) and a filter in the search. - Should: one source per item with a stable key; never one source for the whole table (a change would make every vector again).
- Should: build the text the way a person would ask about it: "Assam tea, 250 g. Category: Tea. Price: 180 INR. Strong, malty black tea…". Codes and ids alone match nothing.
- Should: details for what an answer needs to show or filter (category, price, link, language, date); the search returns them with each passage.
- Should: the table, the query and the schedule from project properties, so the same feed reads test and production databases.
- Should: big tables paged by key, or only the rows changed since the last feed (
where updated_at > :last, the mark kept in a counter or a table), with a full run with keep only now and then. - Thousands of items and more: a pgvector knowledge base on PostgreSQL; the built-in store suits small catalogues.
A Joomla site
Joomla keeps its articles in #__content (the prefix is the site's, for example jos_): SELECT id, title, introtext, `fulltext`, catid, modified FROM jos_content WHERE state = 1 AND access = 1 gives the published, public articles; strip the HTML in the mapping (or with Read document text), use the article's link as a detail, and articles/<id> as the source. Shop extensions keep products in their own tables (VirtueMart, HikaShop, J2Store): read their product, price and category tables with a join. Give SutraFlow a database user that can only read those tables.
Answering from it
- Search knowledge: the closest passages with their details, no AI model needed: a search API, a "related products" list.
- Ask knowledge: a written answer from the passages, with sources (an AI provider).
- An AI agent with the knowledge base: a chat that can also use tools (stock, orders), as in Blueprint: chat agents.
One knowledge base for many projects
When several projects need the same knowledge (products for the shop and the support desk, policies for HR and every chat), do not copy it: make it once in an owning project and ask an administrator to share it in Knowledge admin. Design with areas from the start, one folder of sources per subject and audience (products, hr, support/internal): grants, feeds and the MCP tool all work by area. A plain feed (a folder, SharePoint, a table) can be a managed source with no Sutra at all; when it needs shaping, export it as a Sutra and change that. One writer per area: a feed Sutra and a managed source never write the same area.
29. Blueprint: dashboards
- One dashboard, one question: "How are sales going?", "Is the warehouse keeping up?". Four to eight charts; a number for the headline, a line for the trend, a bar for the ranking, a table for the details.
- Push the work down: aggregate in SQL (
group by month), never fetch raw rows to count them in a Sutra. - Parallel queries: each chart's query on its own branch from Dashboard page, joined by a Merge before Dashboard reply.
- Refresh to match the data: a minute for operations, an hour for sales by month. The shared cache means viewers cost nothing between refreshes; a dashboard that shows each caller their own data caches per caller.
- Must: a security policy on every dashboard that shows anything not public. The page holds no data; the data request goes through the policy.
- Should: read-only database accounts for dashboard queries, and connection limits on busy databases.
- Filters: three to five slicers on the fields people ask by (region, product group, period). On a database, filter in SQL with bound parameters; on JSON, let the Chart steps filter. Give list filters their choices from a small DISTINCT query.
- KPI cards first: two to four figures at the top, each with its comparison (the period before or a target), then the trend, then the breakdowns.
- AI suggestions: let a model choose chart types and titles, never the data; the Chart step and Charts from AI check every suggestion against the allow-list. Send it only field names and kinds when the data is confidential.
- Embedding:
/dash/<name>/embed.json an intranet or customer portal, with the portal's login passed as for the chat button (Blueprint: chat agents).
30. Designing an AI application from the samples
The AI samples fit together into one application: a website's signed-in people chat with an agent, the agent answers from a knowledge base and acts through tool Sutras, people approve what carries risk, and dashboards show how it is going. This chapter sets that project up from the samples, step by step, and then turns it into your own design. Nothing here needs an AI model until the step that adds one.
The samples it uses
| Part of the application | Sample | What it adds |
|---|---|---|
| The chat, with the website's login | Chat for customers and support and the website Sutra Sample Shop | A published agent (/chat/shop-help), a JWT policy, eight skills by role |
| Knowledge from the shop's data | Knowledge feed from a database | Products from MySQL into a knowledge base every 30 minutes, and a search API |
| Knowledge from documents | AI document assistant over a folder | Files of sample_documents into a knowledge base, asked by REST, MCP and chat |
| An agent with tools, memory and approval | AI agent: order desk with tools and memory | AI guard, tool Sutras, AI memory per conversation, Ask a person before refunds |
| Operations | Sales dashboard on a database, with filters; Dashboard from JSON | /dash/sales-db with slicers and KPI cards; charts suggested by AI, checked by the allow-list |
| Outside assistants | MCP skills | Sutras that Claude, ChatGPT or Copilot call as tools |
Everything they store is named sample_ (the tables sample_products and sample_sales_orders in the database sample_sutraflow, the folder sample_documents, the queue sample_agent.questions), so the whole set is removed in one go when you are done: the installer's Samples mode, or sutraflow samples remove.
Setting up the project
- A project of its own: New project, named for the application (Shop assistant). Keep it apart from the project Samples the installer may have made: this one is where you design.
- Add the samples: New Sutra, Samples, tick the ones in the table and add them. Each becomes new Sutras with new ids in this project, with its Sample ... connections and project properties (
CHAT_SITE_SECRET,PRODUCTS_TABLE,ORDERS_TABLE,DOCS_FOLDER). - Fill in the connections: Sample MySQL with a database server the samples may create tables on (a local Laragon or XAMPP MySQL is fine). Run Sample: Sales orders install and the knowledge feed's install Sutra once from the designer: they make the
sample_tables and their rows. - The chat's secret: make a random secret of 32 characters or more, set it as the value of the Secret property
CHAT_SITE_SECRET(Configuration, Project variables), and deploy Sample: Customer and support chat. - The website: Download the website (zip) beside the sample, unzip it into the web server (Laragon:
C:\laragon\www\sutra-sample-shop), copyconfig.local.example.phptoconfig.local.phpand setCHAT_SECRET(the same secret) andSUTRAFLOW_URL(the gateway as the visitors' browsers reach it:http://127.0.0.1:8080on one machine,https://sutra.example.comfor a SutraFlow on another server).check.phpmust show every tick. - Try it as both roles: sign in as the customer (
asha/asha-demo) and ask Track A-1001, then Orders of C-9 (refused: not hers); sign in as the support desk (ravi/ravi-demo) and ask the same (answered). Open the run in Runs: the caller, the role and the skill of each answer are in the trace. Deploy the dashboards and open/dash/sales-db.
From the samples to your application
- The login: replace
token.phpwith your identity provider's access token (Entra ID, Okta, Auth0, Keycloak, Cognito, Firebase Auth) and the policy's shared secret with its JWKS address, issuer and audience. Roles and scopes come from the token's claims. - The data: replace Shop data with SQL query steps on your tables, filtered by
{trigger.caller.subject}for customers. The model is never the authorisation layer. - Understanding the question: the sample chooses a skill by keywords so it runs without a model. With a model, put AI router (or an AI agent with the skills as tool Sutras) in place of the keyword step, and keep AI guard in front on public chats.
- Answers from knowledge: point the knowledge feed at your product table and the document feed at your documents; give the agent the knowledge base. Learn only what the askers may see (Blueprint: knowledge bases).
- Actions with risk: refunds, cancellations and address changes go through Ask a person, or a tool Sutra that checks its input and its caller, as in the order desk sample.
- Operations: a dashboard on the conversations and the actions (questions per skill, hand-offs to people, refunds approved), with a policy for staff only (Blueprint: dashboards).
- Drop the sample names: rename the tables, folders, queues, connections and Sutras; data left under a
sample_name is removed with the samples. Then package and release it like any other project (Packaging, Versions, releases and environments).
Design checklist for an AI application
- Which agent: a public agent that owns the conversation, or skills for an outside assistant (Blueprint: chat agents).
- Who is asking: from the login token, never the message; data filtered by subject.
- What the model may do: narrow steps, tools as Sutras, limits on steps, tokens and time; people before risk.
- What it knows: knowledge fed on a schedule with stable sources and keep only; nothing the askers may not see.
- How long it remembers: the conversation lifetime per agent, and expired conversations cleared on a schedule.
- How you know it works: runs traced, dashboards for operations, test questions for each role kept beside the project.
31. Error handling through logs, and traceability
When a customer calls about order A-2001, anyone on support should get from the order number to the project, the Sutras it went through, every run and every step, in a minute. That needs a little design in every Sutra and the right settings.
1. Design every Sutra for it
- A correlation id made once, at the door, from the business key (
ord-A-2001) or taken from the caller's header, and passed on in every called Sutra's input, every event and every message (as the message's correlation id). - Log lines with the keys: business key, correlation id, and the run id:
Order A-2001 received for 1800 INR [correlation ord-A-2001, run {{run.id}}]. The run id is also added to every line by the project log; putting it in the message makes it searchable everywhere the line is copied to. - Events carry the sending run (
sourceRun: {run.id}), so a run started by a channel or a queue can be traced back. - Errors logged with the same keys on every error output and in the Error handler:
Credit check failed for order A-2001: … [correlation ord-A-2001, run …]. - Error answers carry the run id, so a caller's support ticket points straight at the run.
2. Set up the project log
| Setting (Configuration, Logging, or the deployment config) | Development | Production |
|---|---|---|
| Enabled, file | On, logs/{project}.log | On; a path the log collector reads |
| Level | info (debug while finding a problem) | info |
| Format | text | JSON lines for a log collector (Elastic, Loki, Splunk, Azure Monitor) |
| Rotation | 10 MB, 5 files | Sized to keep the days support needs |
| Step data in the log | As needed | Off (personal data) |
Every line carries the server (production, test, development), the run kind and version (deployed v3, editor test) and [Project / run id / Step]: 2026-11-02T09:12:03Z INFO {production, deployed v3} [Orders / 3f2a91c0 / Log received] Order A-2001 received …. Configuration, Project log shows it with filters by level, by runs from deployed Sutras or designer tests, and by words.
3. Trace an order, step by step
With Sample: Traceability and notifications added: deploy Sample: Trace notification hub, then test Sample: Trace order intake.
- Project: Admin Console, Traceability lists every project with its runs by outcome; open the project for its Sutras with success rate, last run and last failure.
- Find the run: Find a run with
A-2001(a value in the data a run started with), a run id or its first characters, or who started it. The intake run and the hub run both started with the order number. - The run: its ids (run, Sutra, project, each with Copy), who started it, what it started with, every step with status, try, time, engine, error and its input and output, its reply and its log.
- Across Sutras: the intake run shows the credit check it called (Call Sutra) and the credit check shows the run that called it, each a click away. The hub run, started by the channel, names the intake run in its log line (
from run …), and the correlation id finds both in the project log. - The log: Configuration, Project log, filter by
ord-A-2001: every line of every Sutra for that order, in time order. - Keep the evidence: Download saves the whole run as JSON for a ticket.
4. From an error to its fix
- Alert rules (failed runs, slow runs, gateway errors, listeners in error) notify by email, webhook or a Sutra, with the Sutra and the count; the Overview lists the latest failed runs.
- Open the failed run in Traceability: the failed step, its input, the error, the retries.
- Fix the cause (data, a partner, a connection, or a new version of the Sutra), then Resubmit the run from the Overview or the Sutra's runs.
- Gateway, Traffic and the request log show the same calls from the caller's side: path, app, status, time and the run they started.
- Across systems:
traceparentis passed on HTTP calls and traces go to an OpenTelemetry collector (Trace sampling), so a call from a mobile app through SutraFlow to the ERP is one trace.
Every log line, event and error answer carries the business key, the correlation id and the run id. With those three, any order can be followed from the project to every Sutra and run.
The samples explained
32. The samples: how to use them
SutraFlow ships 60 working samples, built from its code when you add them (New Sutra, Samples, or New project, Samples), so a new installation always gets the samples of its release. Each one shows a pattern in a few steps, with every step described. This part goes through them group by group: what each builds, the design lessons in it, and what to change before using it in a solution (see Packaging for the general list).
- Every sample added becomes new Sutras with new ids in the project; it is the project's own copy, changed freely and left alone by upgrades. Adding it again gives the current release's version beside the old one.
- Samples are for learning and as starting points, never for production as they are: build your Sutra from the pattern, then design, test and release it like any other.
- Samples that need something (a broker, Ollama, an OAuth account) say so; those that serve on the gateway must be deployed to be called.
- Samples run without security policies and with folders and addresses typed in, so they work at once on one machine. That is the first thing to change.
| Sample | What it shows | Palettes |
|---|---|---|
| MongoDB document lifecycle (M0-tested baseline) | Insert, list collections, find, array-filter/update, aggregate and delete a run-scoped document, with a strict starter contract and activity descriptions. Needs A MongoDB connection with separate credentials or encrypted complete URI, and permitted server network access.. | MongoDB |
| Typed JSON and XML mapping | Shared typed JSON target and a manual XML root, required attribute, namespace and repeating elements; both rendered to text. No external connection required. | Data & mapping |
| JSON/XML schema validation and strict file reads | Valid and intentionally invalid contracts, typed mapping, Parse/Render, Validate fields, strict JSON/XML file reads, REST/HTTP and SOAP services. Every activity explains its validation outcome. Needs Writable project VALIDATION_FOLDER for file samples; deploy the REST service before the HTTP client. Services are local demonstrations without authentication.. | Data & mapping, Files, HTTP, Triggers |
| Functions | Every function of the formula language on one order: a Map data step per group (text, conversion, encoding, variables, utility, dates, numbers, logic, sequences, lists), each followed by a Log of its results. | Data & mapping, General |
| For-Each mapping | Invoice lines from order lines: Where, Sort by, position(), and a For-Each grouped by country. | Data & mapping |
| Loop on an activity | One activity run per order, and a counter repeated while below 3, like polling a job. | Data & mapping, General |
| Sub-Sutra (Call Sutra and Return) | A reusable tax Sutra and an invoice Sutra that calls it and logs its result or its failure. | Flow control |
| Try and catch with logs | An error handled on one activity, and the Error handler catching the rest, with logs at each level. | Flow control, General |
| REST API with validation | GET /samples/orders/:id: checks the id, shapes the reply, answers 200 or 400. | Triggers, HTTP |
| CSV import and totals | Writes a CSV file, reads it back as typed rows, keeps the paid rows and totals them per country. | Files, Data & mapping |
| Folder of files | Lists the CSV files in a folder with a wildcard and handles each one with For each. | Files, Flow control |
| Database (SQLite) | Creates a table and rows in one transaction, then queries it with a bound :parameter. A built-in SQLite file, nothing to install. | DB Ops |
| XML in and out | Parses an XML order with attributes, maps its repeating lines, and renders an XML invoice; a called Sutra takes XML checked against an XSD at its Manual start, and its caller maps to that contract. | Data & mapping |
| JSONata, JavaScript and HTML | Groups orders with JSONata, scores them in JavaScript, and builds an HTML report. | Data & mapping, Custom code |
| Router, Switch and Merge | Routes on conditions (all matches), joins the branches with Merge, then switches on the status. | Flow control |
| Connection conditions | Named connections taken when their condition on the output is true, and an otherwise connection. | Flow control |
| Channels between Sutras | One Sutra sends to a channel; a deployed Sutra with a Channel trigger receives each message. | General, Triggers |
| Traceability and notifications | One order through three Sutras with one correlation id: intake calls a credit check, then announces the order on an internal channel; a notification hub receives it and decides whom to tell. Every log line carries the order number and correlation id, so the order can be followed from the project to each Sutra and run. Needs the notification hub deployed for the channel step to reach it. | Flow control, General, Triggers |
| Counter, Wait and Sutra variables | A local variable set and read back in one run, a daily counter the server keeps across runs, and a pause; every step describes what it is for. | General, Flow control |
| Scripts: PowerShell and Run program | A PowerShell disk report that hands JSON to the next step, and a program run with arguments; failures carry the exit code and error output. Needs scripts allowed by an administrator in Admin Console > Server > Runtime. | Scripts |
| Timer: nightly archive | Every night at 02:00, lists the CSV files in a folder (oldest first) and moves each one to an archive folder. | Triggers, Files, Flow control |
| File trigger: CSV drop folder | Starts when a CSV file arrives, sorts its rows, writes a cleaned copy and moves the original to processed/. | Triggers, Files, Data & mapping |
| Parse JSON and CSV text | Parses JSON with a shared schema and renders it through a schema-backed mapping; parses CSV, sorts the rows, and renders CSV with a semicolon. A No operation marks a step still to design. | Data & mapping, Flow control |
| SQL update and stored procedure | Updates a row with a bound parameter and fails clearly when no row matched; a second Sutra calls a stored procedure. Needs the Database sample run first; for the procedure, a PostgreSQL, MySQL, SQL Server or Oracle connection. | DB Ops |
| Call a SOAP service | Calls the GetOrder operation of the "Order SOAP service" starter with a raw envelope and maps the reply; a SOAP fault has its own output. Needs the "SOAP service: orders" starter deployed. | SOAP / Web services |
| Email trigger: orders by email | Starts for each new email in a mailbox, pulls the order number and amount out of the text with AI extract, and logs them. Needs an Email (IMAP) connection and an AI provider. | Triggers, Email, AI |
| Firebase: order to app | Saves the order in Firestore, updates its live status in the Realtime Database, and sends a push notification to the customer's phone. Needs a Firebase connection. | Firebase |
| Google Drive and Sheets | Starts when a Google Doc changes in a folder, exports its text, summarises it, and appends a row to a Google Sheet. Needs a Google OAuth connection, a folder and a spreadsheet; an AI provider. | Triggers, Apps, AI |
| Dropbox, YouTube and any API | Searches YouTube, saves the results to Dropbox as JSON, and calls any API of the connected account with Connected API call. Needs Google and Dropbox OAuth connections. | Apps |
| AI: translate, extract, route and reply | With a local Ollama: lists the models, translates a Spanish message to English, extracts its fields, routes it to a team and drafts a reply. Needs Ollama running on this machine with at least one model. | AI |
| Release pipeline | A Sutra that releases a project: builds a package, checks it, deploys it to a test copy, waits for approval, deploys to production, and logs each step; any problem goes to one handler. Needs release activities allowed in Admin Console > Server > Runtime; for remote engines, their admin tokens in the vault. | Release, Flow control, Email |
| Local AI with Ollama | Classifies, summarises and rates a customer email with a local Ollama model, offline. Needs Ollama running on this machine with at least one model. | AI |
| Email a report | Builds an HTML report and emails it; a failure is logged. Needs an Email (SMTP) connection. | Email, Custom code |
| Queue in and out | Takes orders from Kafka, RabbitMQ or ActiveMQ, reshapes and publishes them, then explicitly confirms only after the outgoing broker accepted them. Needs one configured Kafka, RabbitMQ or ActiveMQ connection. | Service Bus |
| Broker REST APIs | Three HTTP-client examples: publish through Kafka REST, publish and fetch through RabbitMQ HTTP, and publish and fetch through ActiveMQ REST. These complement rather than replace native Queue / topic triggers. Needs the broker REST/management endpoint enabled and an HTTP connection plus Basic-auth vault secret. | HTTP, Service Bus |
| Call a public SOAP service | Loads the WSDL of a free public calculator service and calls its Add and Multiply operations; a fault and a network error each have their own output. Needs internet access. | SOAP / Web services |
| Mock SOAP service and its caller | A mock weather SOAP service with a WSDL and canned replies (and a fault for an unknown city), and a Sutra that calls it with a raw envelope, as you would before the real service exists. Needs the mock service deployed. | Triggers, SOAP / Web services |
| JSON microservices | Three small REST services: Customers and Stock answer JSON on their own, Orders calls both over HTTP and returns one combined JSON reply (or 404 / 409 / 502). Needs the three services deployed. | Triggers, HTTP, Data & mapping |
| SQL install script and procedure as a service | A SQL script creates a MySQL database, two tables, seed rows and a stored procedure; a REST service then calls the procedure and returns its rows as JSON. Needs MySQL (Laragon: 127.0.0.1:3306, user root, no password); the service deployed. | DB Ops, Triggers, HTTP |
| SFTP: upload, list, read, archive | Writes a CSV to an SFTP server, appends to it, lists and reads it back, copies it to an archive folder and deletes the copy; a Remote file trigger picks up new files in inbox/. Needs an SFTP server: set the host, user and password of the "Sample SFTP" connection. | SFTP / FTP, Triggers |
| FTP: upload, list, read, archive | The same steps over FTP or FTPS: write, list with rows, read lines, move to a dated archive name; a Remote file trigger picks up new files and deletes them after the run. Needs an FTP server: set the host, user and password of the "Sample FTP" connection. | SFTP / FTP, Triggers |
| Sales dashboard | A dashboard page on the gateway (/dash/sales): revenue by month, orders by category, total revenue, top products and the latest orders, from SQL queries; refreshed every minute and cached for all viewers; PNG and SVG export on every chart. One chart takes its settings from a suggestion step, as an AI would give them, and shows how a field that is not in the data is refused. No database to install. Needs the dashboard deployed. | Dashboards, DB Ops |
| Sales dashboard on a database, with filters | A dashboard on a real MySQL table of orders (/dash/sales-db): filters for region, categories and dates at the top, KPI cards with the change against the month before and a target, revenue by month split by region, revenue by category (a click on a bar filters the whole page), the share of each region, the best customers and the latest orders. One SQL query takes the filters as bound parameters; the Chart steps group and add up its rows. Needs MySQL (Laragon: 127.0.0.1:3306, user root, no password); the install Sutra run once; the dashboard deployed. | Dashboards, DB Ops |
| Dashboard from JSON (any API) | A dashboard from an API answer (/dash/orders-json): the orders list inside the answer, nested fields such as customer.city, dates grouped by month, series split by channel, KPI cards, filters including a search, and a Charts from AI step that plans more charts by itself (built-in rules without an AI provider; with one, the model chooses and every chart is checked). Replace the JSON step with an HTTP request to your own API. Needs the dashboard deployed. | Dashboards, Data, AI |
| Knowledge feed from a database | Products kept in a MySQL table (as a shop or a Joomla site keeps them) become a knowledge base: a timer reads the published products, each one becomes a passage with its category, price and link as details, unchanged products are skipped and removed ones taken out; a REST API searches the products by meaning. No AI model needed. Needs MySQL (Laragon: 127.0.0.1:3306, user root, no password); the install script run once; the API deployed. | AI, DB Ops, Triggers, REST |
| Chat for customers and support | A chat agent on a website that already has its own sign-in (Sutra Sample Shop, a PHP website): the website issues a signed token for the signed-in person, the chat widget passes it on, and the agent answers with eight skills: order status, tracking, returns and refunds, invoices, the delivery address, products and stock, a person from the support desk, and help. Customers see only their own orders, the support desk any order. The website can use this SutraFlow or one on another server. No AI model needed. Needs the agent deployed; the website's shared secret in the project Secret property CHAT_SITE_SECRET; PHP 8 for the website. | AI, Triggers |
| AI agent: order desk with tools and memory | A published agent (chat page, OpenAI API, MCP tool, A2A) that checks its input with the AI guard, looks orders and stock up with two AI tool Sutras, remembers each conversation, and asks a person before any refund. Needs Ollama with a model (phi4-mini works); the three Sutras deployed to chat at /chat/order-desk. | AI |
| AI agent: knowledge base (RAG) | Fills a knowledge base from web pages and from a SharePoint library (kept up to date by a trigger), and a policy assistant that answers only from it, with sources. Needs Ollama with a model; for SharePoint, a Microsoft OAuth connection. | AI, Apps |
| AI agent: fed by a message queue | Takes questions from Kafka, RabbitMQ or ActiveMQ, keeps each conversation in its own AI-memory session, publishes the answer to the requested destination, then explicitly confirms. Needs one configured Kafka, RabbitMQ or ActiveMQ connection; Ollama with a model. | AI, Service Bus |
| AI agent: supervisor and specialists | A supervisor agent published at /chat/help sends each question to the order desk or the policy assistant with Hand off to agent, and answers with what they say. Needs the order desk and knowledge base samples; Ollama with a model. | AI |
| AI agent: tools from another MCP server | Lists the tools of an outside MCP server (the file system server started with npx), calls one directly, and gives them to an agent that answers questions about files. Needs Node.js npx on the server; Ollama with a model. | AI |
| AI document assistant: RAG over a folder | Every 15 minutes, reads the PDF, Word, PowerPoint and Markdown files of a folder into a knowledge base (changed files again, deleted ones out), and answers from it three ways: a REST API, an MCP tool for AI assistants, and a chat agent. Sample documents included. Needs Ollama with a model for the API and the agent (the MCP tool needs none). | AI, Files, Triggers, REST |
| Azure Data Factory: run, monitor, rerun | Runs a pipeline with parameters and waits for it, reruns from the failed activity, and watches the factory for failed runs, asking a person before a rerun. Needs an Azure service principal with Data Factory Contributor on the factory. | Azure, Flow control, AI |
| Databricks: notebooks, SQL and code blocks | Runs a notebook with parameters and reads its exit value; queries a SQL warehouse with a named parameter and runs a Python cell on a cluster. Needs a Databricks workspace with a cluster and a SQL warehouse; a token or service principal. | Azure |
| Python scripts | Python written in the step and a .py file from the project files, with arguments, parameters and the previous output, printing JSON for the next step. Needs Python 3 on the server; scripts allowed in Admin Console > Server > Runtime. | Scripts |
| YouTube: publish from Google Drive, weekly analytics | New videos in a Drive folder are saved to the server and uploaded to YouTube; every week the channel's analytics go to a Google Sheet. Needs a Google OAuth app with the Drive, YouTube and Sheets scopes. | Apps and social |
| Twitch: going live | When the channel goes live, a welcome in the chat; after the stream, the follower count. Needs a Twitch application (dev.twitch.tv). | Apps and social |
| Discord: order status bot | A bot answers !status <order> in a channel with an embed. Needs a Discord bot token. | Apps and social |
| Telegram: order status bot and alerts | A bot answers /status <order> in any chat; an alert Sutra other Sutras call posts to the team chat. Needs a Telegram bot token from @BotFather. | Apps and social |
| MCP skills: Write CSV file, Post to Facebook page | Two Sutras that AI assistants call as tools, on a sample MCP server. Needs a security policy on the MCP server; a Facebook connection for posting. | Triggers, AI, Files, Apps |
33. Samples: data and mapping
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| Functions | An order through ten Map data steps, one per function group (text, conversion, encoding, variables, utility, dates, numbers, logic, sequences, lists), each followed by a Log; a memory table of currency rates for lookups. | Every formula function at work, on realistic data; the Output tab shows each value with its spaces kept. | A reference, not a solution: copy the formulas you need into your own mappings. |
| Typed JSON and XML mapping | Map JSON Data to a typed target and Render JSON; Map XML Data with a root, a required attribute, a namespace and repeating elements; JSON fields renamed into XML. | Typed targets catch wrong types while mapping; source and target names may differ. | Use shared schemas (JSON Schema, XSD) instead of manual types when partners send contracts. |
| JSON/XML schema validation and strict file reads | Validation pipelines for JSON and XML, expected rejections, strict file reads under {{gv.VALIDATION_FOLDER}}, a validated REST service and its client, a validated SOAP service. | Validate at the door; an expected rejection is a normal branch, not a failure; the same contract from parse to render. | Add policies to the services; the client's URL becomes an HTTP connection; drop the expected-rejection Sutras. |
| For-Each mapping | An invoice from order lines: For-Each with Where and Sort by, position(), and a For-Each grouped by country. | Repeating data is mapped with For-Each, not formulas over indexes. | Map against the invoice schema. |
| Loop on an activity | One mapping run per order (Loop: for each item) and a counter repeated while below 3 with a delay, like polling a job. | The step Loop runs in order and can pause between runs; For each runs items in parallel. | Set Maximum runs and a delay that fit the system polled. |
| XML in and out | Parse an XML order with attributes, map its lines with a For-Each, render an XML invoice. | Attributes as @_id; repeating elements as lists. | Validate both documents with XSDs. |
| JSONata, JavaScript and HTML | Totals per country in one JSONata expression, ranking in JavaScript, an HTML report. | One expression for a whole-document reshape; code only for what formulas cannot do. | Keep code steps free of side effects; move the report template to a project file if it grows. |
| Parse JSON and CSV text | JSON text parsed with a shared schema and rendered through a schema-backed mapping; CSV parsed, sorted and rendered with a semicolon; a No operation placeholder. | Text formats in and out of structured data; placeholders mark unfinished design. | Remove the No operation; set the CSV delimiter and encoding from the partner's contract. |
34. Samples: flow control, reuse and traceability
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| Sub-Sutra (Call Sutra and Return) | A tax Sutra that returns tax and total, and an invoice Sutra that calls it and logs the result or the failure. | A called Sutra is a function: input, Return, errors on the caller's error output. | Give the tax Sutra input and result schemas with validation; callers use the deployed version. |
| Try and catch with logs | One failing step handled on its own error output; another caught by the Error handler, logged, and the run ended. | Specific handling where you can act, one Error handler for the rest. | The handler logs the business key and correlation id and, for an API, replies with the standard error body. |
| Router, Switch and Merge | A router taking every matching route, a Merge waiting for all branches (including those not taken), a Switch on the status. | All matches versus one value with many cases; Merge joins parallel branches. | Name branches by business meaning; put thresholds (the large-order amount) in properties. |
| Connection conditions | Named connections taken when their condition holds, and an otherwise connection. | Simple routing without a router step. | Keep conditions short; several conditions on one output are easier to read as a Router. |
| Counter, Wait and Sutra variables | Local variables as records 1 and 2, a counter per day, a pause, all variables read back with the run id. | Local variables live for one run; counters across runs. | Use counters for sequences and totals; never local variables between runs. |
| Channels between Sutras | A sender publishing to sample_orders and a deployed listener that counts and logs each message. | In-process publish and subscribe; the sender does not wait. | Channel name as a property; a schema on the channel; the listener deployed before senders run. |
| Traceability and notifications | An intake Sutra that makes a correlation id, calls a credit check and announces the result on sample_order_events; a notification hub that decides whom to tell; every log line with the order number, correlation id and run ids. | One correlation id through called Sutras and channels; a notification hub; how to trace an order from project to run (Error handling through logs). | Replace the hub's logs with email, push or chat steps; the channel (or a broker topic for other projects) as a property; the credit limit as a property. |
35. Samples: REST, microservices and SOAP
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| REST API with validation | GET /samples/orders/:id: Validate fields, Map data, 200 or 400. | Validate first, shape the reply, a reply on every path. | A policy; the standard error body; a version in the path; a response schema. |
| JSON microservices | Customers and Stock answer JSON or 404; Orders calls both over HTTP, checks stock and answers 201, 404, 409 or 502. | Services that own their data and call each other; dependency errors mapped to the caller's codes. | HTTP connections with base URLs from properties, timeouts and circuit breakers; parallel calls with a Merge; policies and gateway apps per caller (Blueprint: microservices). |
| SQL install script and procedure as a service | A SQL script creating a MySQL database, tables, seed rows and a procedure; a REST service returning the procedure's rows. | Schema changes as scripts that run twice safely; a procedure behind an API. | The script in a release Sutra; the service with a policy and paging; a read-only database account for the service. |
| Call a SOAP service | GetOrder sent to the deployed SOAP starter with a raw envelope; reply mapped; fault and network error on their own outputs. | Faults are not network errors: handle them apart. | Use the WSDL and pick the operation; the endpoint from an HTTP connection; security profile on the connection. |
| Call a public SOAP service | The WSDL of a public calculator loaded; Add then Multiply. | Operations come from the WSDL; chaining calls. | Timeouts and retries for a service on the internet. |
| Mock SOAP service and its caller | A mock weather service with a WSDL, canned replies and a fault for unknown cities; a caller that changes only its endpoint when the real one is ready. | Mock first, so consumers build in parallel. | The endpoint as a property or connection; the mock deployed only on development and test. |
36. Samples: files, SFTP, databases and MongoDB
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| CSV import and totals | Writes a CSV, reads it back as rows, keeps paid rows, totals per country. | Filter and Aggregate instead of code. | The folder ({{gv.SAMPLE_CSV_FOLDER}}) named for the solution; stream big files instead of reading them whole. |
| Folder of files | Lists CSV files with a wildcard, a For each per file, a count; the empty output when nothing matched. | A run per file; handle the empty case. | Folder as a property; a sub-Sutra per file for real work. |
| Timer: nightly archive | Every night at 02:00 (Asia/Kolkata), lists CSV files oldest first and moves each to an archive. | A polling batch with a schedule and time zone. | Folders and time zone as properties; date in archive names; a run time limit. |
| File trigger: CSV drop folder | Starts when a CSV arrives, sorts, writes a cleaned copy, moves the original to processed/. | Stable files, processed and error folders. | Inbox and output folders as properties; an error folder for files that fail. |
| SFTP and FTP: upload, list, read, archive | Write, append, list with rows, read lines, copy to archive, move to a dated name, delete; a Remote file trigger every 60 s for files that stopped growing. | Remote files with the same discipline as local ones. | Host and user from properties, password or key from the vault, host fingerprint checked; longer time limits for distant servers. |
| Database (SQLite) | A transaction creating a table and rows; a query with a bound :min parameter. | Transactions for changes that belong together; bound parameters. | PostgreSQL or the business database instead of an SQLite file (always on a cluster). |
| SQL update and stored procedure | An update that fails clearly when no row matched; a procedure call with named parameters. | "No row affected" is an error you choose to see. | The procedure on the real database; its account allowed only to execute it. |
| MongoDB document lifecycle | Insert, list collections, find, update (with an array filter), aggregate, bulk write and delete, all scoped to one run id, with the URI in an encrypted Secret property. | Documents scoped and cleaned up; credentials only in Secret properties. | The database and collection as properties; indexes for the queries used. |
37. Samples: queues, email and notifications
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| Queue in and out | JSON orders from sample_orders.in with explicit acknowledgement and a duplicate guard, reshaped, published to sample_orders.out, confirmed only after the broker accepted; the same for exact XML. | Consume, transform, publish, then confirm; deduplication. | Queue names and broker settings as properties; a dead-letter path after a few redeliveries (Blueprint: broker). |
| Broker REST APIs | Publish and fetch through Kafka REST, RabbitMQ HTTP and ActiveMQ Jolokia, with every setting from properties and the password in the vault. | HTTP-only access to brokers. | Only where native connections are impossible. |
| Email a report | An HTML report sent with Send email; a failure logged. | Templates and sending as separate steps. | Recipients as properties or input; the SMTP connection per environment; move into a notification hub. |
| Email trigger: orders by email | A new email with "Order" in its subject; AI extract takes the order number and amount; the email marked read. | Unstructured input made structured at the door. | Validate what AI extracted before acting; a person for low-confidence cases. |
| Firebase: order to app | An order saved in Firestore, its live status in the Realtime Database, a push notification to the device. | Mobile apps updated live and by push. | Device tokens from your user records; failures logged without failing the order (Blueprint: mobile). |
| Telegram and Discord bots and alerts | Bots that answer /status or !status; a Telegram alert Sutra other Sutras call. | A called alert Sutra is a simple notification hub. | Tokens in the vault; chat ids as properties; a hub for all channels (Blueprint: notifications). |
38. Samples: AI, agents and knowledge
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| Knowledge feed from a database | A product table in MySQL (made by an install script) read every 30 minutes; each published product becomes a passage with its category, price and link as details; unchanged products skipped, unpublished ones removed; a REST API searches the products by meaning. No AI model needed. | Any table or API can feed a knowledge base: one source per row, text written the way people ask, details for filters and links. | Your own table in PRODUCTS_TABLE and a read-only database user; only rows the askers may see; pgvector for big catalogues; changed rows only for big tables (Blueprint: knowledge bases). |
| Chat for customers and support | A published agent for the people signed in on a website: the PHP site in samples/sutra-sample-shop signs a token per person (role customer or support), the widget passes it on, the policy checks it, and the agent answers with eight skills (orders, tracking, returns, invoices, address, products, a person, help): customers about their own orders, staff about any order. No AI model needed. | Who is chatting comes from the website login, never from the message; conversation tokens that expire; data filtered by the subject. | The token of your identity provider instead of token.php; a database query instead of the order list; HTTPS and Require HTTPS on; an AI agent with a guard if wanted (Blueprint: chat agents). |
| Local AI with Ollama | Classify, summarise and rate a customer email offline. | Small AI steps, each with one job. | An explicit model on the connection; rules (refunds) in ordinary steps. |
| AI: translate, extract, route and reply | Models listed, a Spanish message translated, fields extracted, routed to a team, a reply drafted. | A chain of narrow AI steps beats one big prompt. | A person approves drafted replies before they go out. |
| AI agent: order desk with tools and memory | A published agent (chat page, OpenAI-compatible API, MCP, A2A) with the AI guard, two tool Sutras, memory per conversation and a person before refunds. | Guard first, tools as Sutras, people for risk. | A policy on every entry point; limits on steps, tokens and time; tool Sutras that check their input. |
| AI agent: knowledge base (RAG) | A knowledge base fed from web pages and a SharePoint library kept in step; a policy assistant answering only from it, with sources. | Answers grounded in your documents, with sources. | pgvector for volume; feeds on a schedule or trigger; the site and folder as properties. |
| AI document assistant over a folder | Every 15 minutes, documents of {{gv.DOCS_FOLDER}} into a knowledge base (unchanged files skipped, deleted ones removed); answers by REST, MCP tool and chat agent. | One feed, three ways to ask; a called Sutra per file. | Big documents streamed in parts; a policy on the API and MCP server. |
| AI agent: fed by a queue; supervisor; outside MCP tools | An agent worker on a broker queue; a supervisor handing questions to specialists; an agent using a file system MCP server's read-only tools. | Queues for slow AI work; hand-offs; least-rights tools. | Allow only the tools needed; sessions per sender. |
| Sales dashboard on a database, with filters | A dashboard on the MySQL table sample_sales_orders (made by Sample: Sales orders install) at /dash/sales-db: KPI cards, the trend, breakdowns, and slicers filtered in SQL with bound parameters. | Aggregate in SQL; parallel queries; filters as bound parameters; refresh with a shared cache. | Your table in ORDERS_TABLE, a read-only database user and a policy on the page (Blueprint: dashboards). |
| Dashboard from JSON (any API) | A dashboard from an API answer at /dash/orders-json: raw rows grouped by the Chart steps, and Charts from AI suggesting chart types and titles from the field names. | Any JSON can be charted; AI chooses the look, never the data, and every suggestion is checked against the allow-list. | Your API in place of the sample rows; only field names to the model when the data is confidential. |
| MCP skills | Two Sutras AI assistants call as tools: write a CSV file, post to a Facebook page. | A skill is a Sutra with a schema and a description. | A policy on the MCP server; confirmation before posting publicly. |
39. Samples: apps, data platforms, scripts and releases
| Sample | What it builds | Design lessons | Before production |
|---|---|---|---|
| Google Drive and Sheets; Dropbox, YouTube and any API | A changed Google Doc summarised into a Sheet; YouTube search saved to Dropbox; any API of an OAuth account. | OAuth connections reach whole app families. | Folder and sheet ids as properties; least scopes on the OAuth app. |
| YouTube and Twitch | Drive videos uploaded to YouTube (streamed); weekly analytics to a Sheet; a Twitch going-live announcement. | Large files streamed through server files; scheduled reports. | {{gv.DOWNLOADS}} on a disk with room; private uploads until reviewed. |
| Azure Data Factory | Run a pipeline and wait, rerun from the failed activity; watch the factory and ask a person before a rerun. | Orchestrate the data platform; people decide reruns. | A service principal with least rights; factory and pipeline names as properties. |
| Databricks | A notebook with parameters and its exit value; a SQL warehouse query with a named parameter; a Python block on a cluster. | Push heavy work to the platform. | Workspace, cluster and warehouse from properties; a service principal rather than a personal token. |
| Python scripts; Scripts | Python inline and from a file under {{gv.SCRIPTS_FOLDER}}; PowerShell, a program and a shell script with their exit codes. | Scripts print JSON for the next step; failures carry the exit code. | Scripts in Git with the project; packages installed on the server; scripts allowed only where needed. |
| Release pipeline | Build, check, deploy to test, approval, deploy to production, every problem to one handler. | Releases as a Sutra with an approval gate. | Production as a remote engine with its admin token in the vault; or the CI pipeline (CI/CD). |
Delivery
40. Testing Sutras
- Must: every trigger has realistic test data (test request, test message, payload): the designer's Test,
sutra testin a pipeline and the documentation use it (Testing and debugging). - Should: test the unhappy paths too: invalid input, a missing record, a partner that answers 500 or is slow. A Sutra whose error paths never ran is not tested.
- Should: mock partners that are not ready or not available in test: a REST or SOAP service of your own with canned replies, pointed to by a property.
- Should: called Sutras tested on their own with their input schema, like unit tests of a function.
- Should: tell design runs from runtime runs when reading figures: tests, debugging and drafts are design runs, left out of the Admin Console figures, alerts and Traceability, and kept for 7 days by default.
- Should: breakpoints and step-by-step debugging for logic, the Output tab (with each step's log lines) for what a step really received and produced.
- Must:
sutra testin the release pipeline, so a broken Sutra stops the release (CI/CD pipelines).
41. Versions, releases and environments
- Must: the project in Git: a branch per change, a review before merging, a tag per release (Git).
- Must: one release package built once, from the tag, promoted unchanged to test and production with each environment's deployment config; production refuses deploys from the designer (Releases).
- Should: version numbers that say what changed: patch for fixes, minor for added fields and services, major for changes that break callers.
- Must: a change that breaks callers gets a new API version beside the old one; the old one is retired when its callers have moved.
- Must: database changes travel with the release, as scripts that run twice safely.
- Should: know the way back before deploying: roll back to the previous release; runs in progress finish on the version they started with.
- Samples are learning material and starting points. A Sutra built from one is designed, tested and released like any other; a sample never goes to production as it is.
42. Design review checklist
Go through this list for every new or changed Sutra before it is merged. Each line points to the chapter with the rule.
| Area | Check | Chapter |
|---|---|---|
| Purpose | One business purpose; ten to thirty steps; split otherwise | Principles |
| Names | Sutra, steps, connections, properties and paths follow the conventions; every Sutra and step described | Naming |
| Shape | Receive, validate, enrich, transform, act, reply, record; a reply on every path when a caller waits | Anatomy |
| Lanes | No step uses a step on another lane; lanes meet at a Merge before their results are used; the design check shows no problems | Anatomy |
| Execution | Durable unless short, read-only and repeatable | Anatomy |
| Transformations | Mappings before code; missing values handled; money rounded once; times in UTC | Functions |
| Reuse | Shared logic in called Sutras with input and result schemas and a Return on every path; callers follow the called Sutra's input contract | Reusable logic |
| Contracts | A schema on every entry point; input validated at the door; schema change impact checked | Contracts |
| Configuration | Nothing environment-specific in steps; secrets only in the vault | Configuration |
| REST | Resource paths, right methods and status codes, the standard error body, paging, 202 for long work | REST |
| SOAP | WSDL first; faults for errors; WS-Security or mutual TLS | SOAP |
| Security | A policy on every entry point; HTTPS; scopes; authorisation by caller inside; rate limits; trusted proxies listed when behind one | API security |
| Calls out | Own connection identity; timeout; retries only when safe; error output; limits on systems with a capacity | Calling services |
| Messaging | Safe to repeat; deduplication; a dead-letter path; persistent delivery; correlation ids | Messaging |
| Files and batch | Stable files; processed and error folders; big files streamed; step data none for streaming | Files and batch |
| Data | Parameters; transactions for changes that belong together; idempotent writes | Databases |
| Errors | Each kind of failure handled; an Error handler; compensation for multi-system changes; alerts | Errors |
| Logging | Business keys at info; no secrets or personal data; step data set to fit | Logging |
| Traceability | A correlation id made at the door and passed through called Sutras, events and messages; business key, correlation id and run id in every log line and error answer | Traceability |
| Packaging | Folders, names and addresses as properties or connections; samples hardened before use | Packaging |
| Services | Owns its data; talks through the gateway or events; no chains of synchronous calls | Microservices |
| Resilience | Timeouts, retries, circuit breaker, bulkheads; measured before tuning | Resilience |
| Tests | Test data on every trigger; unhappy paths tested; sutra test passes | Testing |
| Release | In Git; one package promoted; breaking changes versioned; database changes scripted; way back known | Releases |
Small Sutras with one purpose and clear names, contracts at every door, configuration outside, every failure seen, every change safe to repeat, and one package from Git to production.