Skip to main content
Version: Next

Language basics

Ids, codes, files and what every statement shares.

Basics​

Files are UTF-8 text with LF line endings. A model is every .kq file under its repository's model/ folder, read as one (see The model is the files).

Layout is free. Newlines and indentation only separate words. The formatter writes one statement per line, two-space indents and aligned columns, so let it handle layout (format on save in VS Code, or kq fmt).

Codes are lowercase letters and digits in hyphen-separated groups: order-service, api2. Paths join Codes with /: platform-orders/order-service/order-api. See Names, Codes and paths for how a path is resolved. A Code has no length limit.

- before a path or a statement, in a later plateau's block, removes it (see Change over time). A Code never starts with -.

Version tags are v and digits, v1, and number a policy's versions, the versions of an event, a command, a query or an API, and the version a call names. Spelled like a Code, v1 is still a valid Code anywhere else.

Names are double-quoted and never empty. \" and \\ are the only escapes.

Comments start with // and run to the end of the line. The formatter keeps them where they are: above a statement, at the end of its first line, or above a closing brace. A comment anywhere else stops the formatter with an error naming it, rather than being lost.

Descriptions are /// lines directly above a declaration or a statement. They become the element's description, which the viewer's Information pane and the editor's hover show. Text between backticks on one line, such as `orders-api`, is shown as code in the viewer; an export keeps the backticks as written.

/// The single front door for the storefront apps. Fans out to the /// catalogue, search and basket services; owns no data of its own. component storefront-bff "Storefront BFF" : backend technology ".NET"

What may be written where​

Writing a declaration inside a block puts the element inside that block's element. These are the only nestings allowed:

InsideYou may declare
a fileplateau, ecosystem
plateauecosystem, extend: the model at that point in time, so the block contains nothing (see Change over time)
ecosystemdomain, platform, monolith, broker, environments, db-server, the rest of the infrastructure and its links, job-role, process, and, in a later plateau's block, data-migration (see Data migrations)
ecosystem, domain, platform, monolith, module, componentalso a motivation block, or motivation for another element
domain, platform, monolith, module, component marked bounded-contextalso its relationships with other bounded contexts: conforms-to, customer-of, partnership, shared-kernel, separate-ways (see Relationships between contexts)
motivationstakeholder, driver, assessment, goal, impact, principle, value, purpose, value-stream, and influences, delivers and the realizations of goals, value stream stages and impacts
driver, assessment, goal, principlemore of its own kind
value-streamvalue-stream-stage
domaineither domains, or function-groups and functions — never both; and process
job-roleholds
processpool, lane, task, start, end, xor, and, and then lines
poolexternal
function-groupfunction
platformcomponent, a user interface (spa, mobile-app, desktop-app) that no component serves, broker, db-server and the other platform services, object, and relationship statements
monolithmodule, component, interfaces, storages of any kind, broker, db-server and the other platform services, object, identity, role, event, command, query, and relationship statements
modulecomponent
componentinterfaces, storages of any kind, identity and role, event, command and query
event, command, queryits versions, v1, v2, one per line
brokerchannel
db-serverpool, and a broker in a redis one
storage-accountits queue broker
registryrepository
ai-platformmodel
a storagedata entities, and in a file or blob one, channel

An identity in a component or monolith not marked idp is reported by validation (KQ043), and so is a role in one with no user interface of its own (KQ040).

Two misplacements are reported with where the declaration belongs: a module written in a platform belongs in a monolith, and a storage belongs in the component or monolith that owns it.

Relationships​

RelationshipMeans
ContainmentOne element is inside another. Written by nesting, never as a statement
ConnectionWho calls whom: a component calls an interface, or sends to or receives from a channel. The arrow points the way control flows, from the caller
RealizationAn application element implements a domain, function group or function in its own ecosystem; or the function side contributes to a goal, carries a value stream stage or causes an impact
InfluenceAn assessment or a value bears on a driver, or a driver or an impact on a goal, with an optional strength
Value deliveryA value stream delivers a value
AccessA component of a monolith reads or writes a data entity its monolith holds itself, naming an aggregate by its root. Optional, and legal only inside one monolith. No view draws it as a line
Context relationshipHow one bounded context relates to another: conformist, customer and supplier, partnership, shared kernel or separate ways (see The context map). The context map view draws it
Property linkAn element's ref property names another element, one link per value of a ref list (see Open properties). Kanoniq derives it from the # line; no view draws it

A connection, a realization, an access, an influence, a value delivery or a references line may be marked assumed when you have not checked it.

A connection starts at a component, or at a monolith that holds its interfaces itself, or at a user interface, or, delivering a message, at a channel. It lands on an interface or a channel, never on a component but for a delivery out of a channel and an in-process call; a monolith that holds its interfaces itself is reached through them in the same way. Only ui lands on a user interface, and only a robot or a role states it.

Realization runs at any altitude. A platform, a monolith, a module or a component may realize a domain, a function group or a function. A realization written on a platform, a monolith or a module covers every component in it. The target is never an ecosystem, and never a domain that holds sub-domains: realize the sub-domain that applies. Once an ecosystem has domains, every component should realize something, directly or through its platform, monolith or module, so shared infrastructure such as a gateway belongs in an Enabler Domain (see Enabler Domains; KQ104).

A component has a primary domain: the one it belongs to, where it is documented and filed. It is the domain its realizations lead to; a component realizing into several domains, such as a front end serving several, marks one realization primary to say which (see Realization). The primary domain says nothing about what the component realizes, and views still draw it under each domain it realizes into.

A connection may say how its caller authenticates: one scheme per arrow, such as key, client-credentials or on-behalf-of, named by how the credential works rather than by product, and for a token the identity provider that issues it. On a leg into or out of a channel, it is that component's credential at the broker. See Authentication.

A call may name the gateway it goes through, via: one that publishes the API the call lands on, or the nat gateway it leaves by. Leave it out and no gateway is said; a call through a gateway is never written as two calls. See Connections.

A connection may go through an anticorruption layer, acl, where the component at its end translates what it takes from another bounded context. See Through an anticorruption layer.

A connection may say what it carries: the events, commands and queries on it, each with its version where it has versions. An event travels into and out of channels, a command or a query to the component that handles it. Say nothing and nothing is said. See What a connection carries.

A webhook is just an HTTP call. What the receiver does next is process, not landscape.

There are no application services. A function says what a component does and an interface says how it is reached, which is the separation an application service would otherwise provide.

Relationship statements​

Connections, realizations and accesses are written in a platform or monolith block: the one holding the component they start from, or the monolith around the module that holds it. A monolith that connects or realizes as a component does writes the statement in its own block. A connection from a user interface goes in the block of the platform or monolith it belongs to. A delivery from a channel, which starts from no component, is written where the component receiving it is.

Naming a relationship​

A connection or realization may carry its own Code and name, after as:

web-shop -> order-service/orders-api over http as place "Place order"

Open properties​

A # line above a declaration or a relationship statement gives it a property your repository has declared: a cost center, a go-live date, a runbook link. Write the /// description first, then one # line per property, the name and its value, or a list's values separated by commas:

/// The single front door for the storefront apps. #cost-center "CC-42" #rto PT4H #owned-by storefront component storefront-bff "Storefront BFF" : backend technology ".NET" #sla-tier gold #tactics retry, circuit-breaker storefront-bff -> catalogue-service/api over http

Declare each property once, in kanoniq.repository.json, under properties, with its type:

{
"properties": {
"cost-center": { "type": "text", "label": "Cost center" },
"rto": { "type": "duration", "label": "RTO" },
"sla-tier": { "type": "enum", "values": ["gold", "silver", "bronze"], "on": ["Connection"] },
"tactics": { "type": "enum", "list": true, "values": ["retry", "circuit-breaker", "outbox"], "on": ["Connection", "Component"] },
"owned-by": { "type": "ref", "targets": ["Platform"], "on": ["Component"] }
}
}
TypeWriteFor example
textA text in quotes#vendor "Oracle"
numberA number; unit in the declaration is shown after it#seats 250
booleanyes or no#pci-scope yes
dateA date#go-live 2025-03-01
durationPT30M, PT4H, P90D, P18M (months) or P7Y#rto PT4H
urlAn http or https address in quotes#runbook "https://wiki.example.com/bff"
pageA page file's path from the repository's root, in quotes#overview "portal/Home/Selling.page.yml"
enumOne of the declaration's values#sla-tier gold
refThe path of an element, as a reference in the declaration is written#owned-by storefront

on lists the types a property may be written on; without it, any element type may carry it, and any connection, realization, influence or value delivery too, except a ref, which only an element carries. A data entity, a policy, a plateau and a data migration carry none. label is how the viewer names it.

"list": true lets a property take several values, written on one line with a comma between each: #tactics retry, circuit-breaker. Only enum, ref, text, url and page can be lists; a boolean, number, date or duration never is, since two of those on one element mean two different things, each a property of its own. The values keep the order you write them in, and the order means nothing. Give each value once; a ref list names each element once, and each value is a relationship of its own. A property without list takes one value. An unquoted value holds no comma, so #x a,b is two values.

brand is Kanoniq's own property: which brand or brands an application, a website, a kiosk or a customer population belongs to. List your brands in its entry, which takes only values, label and description; its type and where it goes are Kanoniq's. Write it on a platform, a monolith, a component, a user interface or an identity, several brands separated by commas; a backend no customer sees carries none. It is not inherited: an interface in a platform marked #brand acme has no brand unless it says so.

"brand": { "values": ["acme", "budget-co"], "label": "Brand" }
#brand acme, budget-co spa shop "Shop"

A repository made by kq init starts with three properties declared, each under a comment: brand, with an empty values list for you to fill, and two linking their sources. pcf holds an element's ID in APQC's Process Classification Framework, the five-digit number that stays the same when APQC renumbers its hierarchy. bian holds the name BIAN's Service Landscape gives what the element matches: a service domain on a Function, a business domain or business area above it. Both are text and go on a Domain, a Function Group or a Function. The PCF's hierarchy number is not a property: it goes in the parentheses after the name, as your organization's code. Kanoniq gives neither a meaning of its own, so delete them, rename them, make one an enum or a list as you like:

#pcf "10215" #bian "Customer Offer" function make-offer "Make offer" ("3.2.1")

assumed and confidence are reserved names: declaring either is an error, since an #assumed line says what both would; brand is Kanoniq's own, declared only as above. A property goes on an element's declaration, as its description does, never on a reopening. In a later plateau, the declaration restating the element states its properties, all of them, a list whole. A property declared nowhere, or a value not of its type, is reported (KQ058, KQ059, each value of a list on its own); one property given twice, several values on a property that is not a list, a value given twice in a list and a comma with no value after it are errors (KB013, KB074, KB012). The viewer lists an element's properties in its Information pane, a list on one row; no diagram draws them.

In VS Code, typing # on a new line above a declaration or a statement offers the properties your repository declares for it, each with its label, type and description, and assumed; a name already written above it is not offered again. After a name and a space, and after each comma of a list, it offers an enum's values not yet given, yes and no, or for a ref the elements it may name. Hover over # and the name to see its declaration, or that it is declared nowhere.

Extend​

extend adds children to an element declared anywhere in the model, from any file:

extend shop/commerce/processing { grpc-api status-api "Status API" }

The path is the full path from the root, without a leading /. Inside, everything reads exactly as if it were written in the target's own block: references resolve from the target, and it holds only what the target's block may hold. A path that names nothing is an error, starting extend <path>:. An extend may add to an element another extend declares. kq build writes what it adds the same way.

Splitting a model​

A model can be split across as many files and folders as you like. No keyword marks it.

Reopening an element​

Declare an element once, with its name and attributes, and reopen it in any other file with its keyword, its Code and a block. The declaration and every reopening are one element, with one Id:

// shop.kq ecosystem shop "Shop" { platform orders "Orders" { component order-service "Order Service" : backend { sql orders-db "Orders DB" { order } } } } // orders-data.kq ecosystem shop { platform orders { component order-service { sql orders-db { root order authoritative origin identifier "Order number" } } } }
  • The name, the attributes (a component's, monolith's or module's kind, idp, technology, the abbreviation of an ecosystem, a domain, a function group, a function or a driver, enabler, a domain's subdomain type, bounded-context, big-ball-of-mud, an API's or a channel's open-host and published-language, canonical, an assessment's or a value stream's kind) and the /// description go on the declaration, and only there. Writing them on two occurrences is an error, even where they agree.
  • Reopening something declared nowhere is an error, so a mistyped Code never creates an element.
  • Only an element that holds others can be reopened: ecosystem, domain, function group, platform, monolith, module, component, broker and storage. A function, an interface, a channel, a domain object, an identity or a role is declared once.
  • A data entity can be written in several places in its storage, each fact once: root, a marker, from, a key or property, a policy, part of, references.
  • Relationships from every file add up. The same one written twice is an error (KQ026).
  • Files are read in the order of their paths, so an element reopened in several files lists its children in that order.

Scoped files​

A file whose first line is scoped is read inside the element its folder names, so it needs no wrapping:

// shop/orders/selling.d.kq scoped component order-service { sql orders-db { root order authoritative origin identifier "Order number" } }
  • scoped is the first line, alone. Nothing comes before it, not even a comment.
  • The folder, from model/ (in the folder holding kanoniq.repository.json), names the element: an ecosystem's Code, then a platform's or a monolith's in it, then anything under that. shop/orders/ is the platform orders in the ecosystem shop.
  • A scoped file holds what that element's block may hold, and no ecosystem or ids. It holds an extend only for policies, as kq arrange writes an Ecosystem's.
  • A file without scoped reads as any other file does, in any folder.
  • The scope must be declared in another file, and a scoped file directly in model/ is an error, since that folder names no element. Every folder holding a scoped file, and each folder above it, must name an element; one that doesn't is an error for the scoped files under it. Other folders are free, until the model is arranged.

Renaming or moving an element in the editor renames or moves the folder that names it, and the file beside it named after it. In a git repository, VS Code stages each tracked file it moves as a rename, as git mv would. The plateaus folder, where kq arrange puts the plateau files, names no element.

The conventional layout​

kq arrange sorts a model into one layout: a file per ecosystem at the root, a folder per ecosystem holding domains.kq, motivation.kq for the motivation of the ecosystem and its domains, and a file per platform or monolith, and a folder per platform or monolith holding its own and its components' motivation in motivation.kq, each domain's software in <domain>.s.kq and its data in <domain>.d.kq and its identities and roles in <domain>.i.kq. An ecosystem's job roles go in <ecosystem>.i.kq in its folder, its processes, its domains' included, in processes.kq, and its scenarios in scenarios.kq. What belongs to no single domain goes in files named after the platform or monolith. Once a model is arranged, anything out of place is reported until you run kq arrange again. See kq arrange.

Formatting​

The formatter writes one layout, the same on every machine, so a change to a model is a small diff. Format on save in VS Code, or kq fmt, applies it:

  • Two-space indents, one statement per line, no trailing spaces, and a final newline.
  • Within a block: move lines first, then declarations, connections, realizations and relationships between contexts, each group in the order you wrote it, then the - lines.
  • Plateaus: the one with no block first, then the top level, then every other plateau with its block, in order. A block holds only what changes there.
  • A data migration comes after every other declaration of its Ecosystem's block, its covers lines before its link lines.
  • A run of statements of the same shape is aligned in columns: the names, the -> targets, the over and the realizes line up. A blank line ends a run, so group statements with blank lines to choose what aligns. A declaration that opens a block stands alone, and a statement with a technology clause doesn't align with one without. A realization's primary mark is its own column, left blank on the unmarked realizations of a run that has one, so a marked realization still lines up with its neighbors.
  • Blank lines between statements are kept, at most one in a row.
  • An #assumed line goes after the /// description and before the # property lines.
  • Every reference is rewritten to the shortest path that still resolves from where it is written.
  • A code in parentheses loses its quotes where it needs none, so ("ENV-1.1") becomes (ENV-1.1), and keeps them where it does, ("3.2.1").
  • Policies, policy sets and exemptions open the block they are in; see Formatting.
  • A policy with one version is written on one line, without v1 when it applies from the start; several versions are a block of tagged lines.
  • Comments stay where they are: above a declaration, a statement, a policy version, or a grant, runs-as, used-by, environment, credential or further from line, at the end of its first line, or above a closing brace. A comment anywhere else has nowhere to go, so formatting stops and names it rather than dropping it.

A long name realigns its whole run. That is the price of a file that reads as a table, and a run is as short as your blank lines make it.

Written by Kanoniq​

You will see these in <name>.g.kq. Don't type them.

MarkerMeans
derivedCreated by Kanoniq from something you wrote
derived orphanCreated by Kanoniq, and nothing names it any more. kq prune removes it
derived plateau initialThe plateau of a model that declares none
derived data-migrationThe data migration of a change of authority you declared none for, in its plateau's block
ids { … }Every element's Id

Reserved words​

Every keyword, and every kind and protocol, is reserved, but for the kinds the build checks: those of the infrastructure, a broker's, a channel's and a repository's format, so vm, postgresql or edge stays a Code you can use. A Code that spells a reserved word is written with an @, such as @customer; the Model holds customer. The reserved words:

about ACC acl active after ai-platform allow and
anonymous app-platform app-role architecture as assessment at auditor
auth authoritative avro azure b2b-representative backend backup backup-vault
basis because before big-ball-of-mud blob bounded-context branch branch-code
broker building by canonical carries cdc certificate channel
client client-credentials command component confidentiality conforms-to const contract
contract-end core cots country covers credential critical cron
custom customer customer-of daily data data-center data-migration data-use
dated db-server ddos delivers deny deployable derived desktop-app
DEV dns document domain driver ecosystem email employee
enabler encrypted end end-of-extended-support end-of-mainstream-support ends environment environments
EPH etl event every exempt extend external failover
falling federated file for format forwards-to freelancer fri
from function function-group future gateway generic goal grant
graph graphql graphql-api grouping grpc grpc-api headquarters holds
host http http-api identifier identity idp ids impact
in in-process in-transit influences initial installation integration internal
invest ipc ipc-api is issuer job job-role joint
json kerberos key key-value lane last law ldap
ldap-api legal-entity lei link location log mail-api main-stream
maintain managed message migrate mixed mobile-app model module
mon monolith monthly motivation move network none notice
number object of on on-behalf-of only open-host opportunity
or origin orphan over paas parent part partnership
personal personal-data phasing-out pilot plaintext planned plateau platform
policy policy-set pool PRD primary principle process property
proposed protobuf public published-language publishes purpose query reads
realizes receiver-auth reconcile references registry regulated replace replica
replication repository retain retire retired rising robot role
root rotate runs-as saas sat scenario schedule schema
scope scoped search-index secret security-service sender-auth separate-ways served-by
server serves service shared-kernel signal-r signal-r-hub signed-by site
snmp snmp-api spa special special-category sql stage stakeholder
start starts status step storage-account stored-in strength subcontractor
subject subjects successor sun supplier supplier-notice support-stream supporting
table task technology terminate then threat thu timer
to transfer transient TST tue UAT ui under
until used-by user-facing-app user-token uses value value-stream value-stream-stage
vault version via waf weakness web-socket web-socket-api wed
weekly when workload workload-identity writes xml xor zone
zone-redundant zones

A Code may contain one: platform-orders is fine.

Nor can a Code be domains or plateaus, or a name Windows keeps for a device: con, prn, aux, nul, com1 to com9, lpt1 to lpt9. A Code can name a folder, and Windows won't create a folder with one of those names.

Reference​

The element types, relationships and kinds of this area, each with what it means.

Relationships

RelationshipWhat it says
ContainmentA Containment joins an element to its parent. Every element but an Ecosystem has exactly one parent, and the model's hierarchy is these relationships.
Property LinkA Property Link records what a reference-typed open property names: from the element carrying the property to the element its value names. Kanoniq derives it from the property.

Provenance: Where a piece of model content came from: authored by an Author, or derived by Kanoniq. Both are equally part of the model.

ValueMeans
authoredCreated explicitly by an Author.
derivedCreated by Kanoniq as a consequence of authored content.

© 2026 Extenza Works. All rights reserved.