Skip to main content
Version: 0.4.0

Work on a large model

Keep a model of hundreds of systems readable: split it into files that follow its structure, and let Kanoniq keep the layout. The guide grows one small model, a shop, a step at a time, and every step is a whole model that builds with no error or lint, here in more than one file: type each file into model/, at the path it names, in a repository kq init made, and check it with kq validate or in VS Code as you type. Every statement used here is described in full in Splitting a model.

Split it into files​

A model can be split across as many files and folders as you like, and no keyword marks it. Which file a declaration sits in means nothing: a connection in one file may name a component declared in another. Declare the shop's domains and systems in shop.kq:

ecosystem shop "Shop" { domain selling "Selling" { function place-order "Place an order" } domain finance "Finance" { function pay "Take payments" } platform storefront "Storefront" { component web-shop "Web Shop" : user-facing-app { spa web-shop-ui "Web Shop" } component order-service "Order Service" : backend component payments "Payments" : saas } }

Then write how they call each other, and which function each realizes, in calls.kq. It reopens the ecosystem and the platform, each with its keyword, its Code and a block:

ecosystem shop { platform storefront { web-shop -> order-service/orders-api over http auth user-token order-service -> payments/payments-api over http auth key web-shop realizes selling/place-order order-service realizes selling/place-order payments realizes finance/pay } }

The declaration and every reopening are one element, with one Id, and the name goes on the declaration only. Reopening something declared nowhere is an error, so a mistyped Code never creates an element. See Reopening an element.

Write a file inside its element​

A file whose first line is scoped is read inside the element its folder names, so it needs no wrapping: the folder shop/storefront/ is the platform storefront in the ecosystem shop. The element must be declared in another file, here shop.kq, which stays as it was. Move the calls into shop/storefront/calls.kq:

scoped web-shop -> order-service/orders-api over http auth user-token order-service -> payments/payments-api over http auth key web-shop realizes selling/place-order order-service realizes selling/place-order payments realizes finance/pay

Its references resolve from the platform, so web-shop is the storefront's web shop. See Scoped files.

Let kq arrange keep the layout​

kq arrange sorts a model into one layout: a file per ecosystem at the root, a folder per ecosystem holding its domains and a file per platform or monolith, and a folder per platform or monolith holding each domain's software, data, and identities and roles in files of their own. Every file in a folder is scoped. Run kq arrange in the repository, and the shop's two files become five. shop.kq keeps the ecosystem:

ecosystem shop "Shop"

shop/domains.kq holds its domains:

scoped domain selling "Selling" { function place-order "Place an order" } domain finance "Finance" { function pay "Take payments" }

shop/storefront.kq holds the platform:

scoped platform storefront "Storefront"

A component goes with the domain it realizes, and a connection with the component it starts from. shop/storefront/selling.s.kq holds Selling's software:

scoped component web-shop "Web Shop" : user-facing-app { spa web-shop-ui "Web Shop" } component order-service "Order Service" : backend web-shop -> order-service/orders-api over http auth user-token order-service -> payments/payments-api over http auth key web-shop realizes selling/place-order order-service realizes selling/place-order

shop/storefront/finance.s.kq holds Finance's:

scoped component payments "Payments" : saas payments realizes finance/pay

The first run marks the model arranged, with "arranged": true in kanoniq.repository.json, and from then on anything out of place is an error until you run kq arrange again. kq arrange --check writes nothing and exits with 1 if anything would change, so a pipeline can hold the layout. See The conventional layout.

Where next​

© 2026 Extenza Works. All rights reserved.