Skip to main content
Version: 0.4.0

Your first model in VS Code

Make a repository, write a small model in VS Code, see it drawn beside the editor as you type, and fix a mistake the editor reports. About fifteen minutes. The same model from the command line is Your first model from the command line.

1. Install​

Install the Kanoniq extension and the kq command line, as Install describes. You need kq for the next step only; everything after it happens in VS Code.

2. Make a repository​

A model lives in a repository: a folder that kq init sets up. In VS Code's terminal, make one, say my-model/:

kq init my-model

It writes the files of a repository, kanoniq.repository.json and model/my-model.kq among them, and AGENTS.md, the authoring brief an AI assistant reads, should you work with one. Open the my-model/ folder in VS Code with File › Open Folder…. The Explorer marks its model/ folder with an M and its portal/ folder with a P.

3. Write a model​

Open my-model/model/my-model.kq and fill in its Ecosystem, giving it a name of its own:

ecosystem my-model "Shop" { domain selling "Selling" { function place-order "Place an order" } platform storefront "Storefront" { component web-shop "Web Shop" : user-facing-app technology "Next.js" { spa web-shop-ui "Web Shop" } component order-service "Order Service" : backend web-shop -> order-service/orders-api over http auth user-token web-shop realizes selling/place-order order-service realizes selling/place-order } }

From the top:

  • An ecosystem is the outermost boundary, usually a company. Everything sits inside one. kq init declared this one, with the folder's name as its Code.
  • The domain and its function say what the organization does, whatever the systems.
  • The platform holds the components that do it. web-shop is an app people use, with a single-page app as its user interface; order-service is a backend service.
  • web-shop -> order-service/orders-api over http auth user-token says the web shop calls the order service's HTTP API, carrying the signed-in user's token. You don't declare orders-api: naming it is enough, and Kanoniq adds it.
  • realizes says which components carry out which function.

The quoted text is what a reader sees, the element's name. The lowercase word before it is its Code, which other statements use to refer to it. See Names, Codes and paths.

4. See it​

Open my-model/ in VS Code. The file is colored, and a mistake shows in the Problems panel as you type.

Right-click my-model.kq and choose Show Kanoniq Viewer. The diagram opens beside the editor and follows your edits:

The diagram in words

2026-10-05-getting-started · Whole model

Boxes

  • Shop (Ecosystem)
    • Selling (Domain)
      • Place an order (Function)
    • Storefront (Platform)
      • Web Shop (User-facing app)
        • Web Shop (SPA)
      • Order Service (Backend)
        • orders-api (HTTP API)

Lines

  • Web Shop → orders-api: connection, HTTP · user-token
  • Web Shop → Place an order: realization
  • Order Service → Place an order: realization

That is the whole model. Pick Selling in the viewer to see the Domain's layered view instead: what Selling does, and the components that do it. See Views and notation.

5. Fix a mistake​

Change the connection so it names the order service but not its interface:

web-shop -> order-service over http auth user-token

The line is underlined at once, and the Problems panel lists the error, KQ022: a connection lands on an interface or a channel, never on a component. Put /orders-api back, and the error goes.

6. Commit it​

Commit every .kq file, model/my-model.g.kq included: it holds the Ids that keep each element's identity when you rename or move it. Build again after every change; a build of an unchanged model changes nothing.

Next​

© 2026 Extenza Works. All rights reserved.