01 Why Klok Is Built This Way

Why Klok Is Built This Way

klok.dev has a page for every part of integration work, and each page looks the way it does because of a few decisions about how integrations are built on Klok. Knowing them makes the rest of this chapter easy to follow: when a page writes to Git instead of saving a form, or a topic has to be approved before a service may read it, one of these decisions is at work.

This chapter walks through klok.dev one menu entry at a time. Each page says what the entry is for, shows it with screenshots, walks through its most common task, and says how it connects to the rest. Start with this page and the two after it, which show how the Build pages and the Run pages fit together.

Six Decisions

Decision In short Where you meet it in klok.dev
One broker in the middle Every system connects once, and the datamodels are the contracts Broker, a datamodel's Topics, a project's Broker setup
Git is the truth Solutions, datamodels, code, topics and access are files on main Edit and Review on every item page, Refresh from GitLab, Repositories
Write narrow, consume wide A tenant writes only in its own namespace; reading elsewhere is approved Broker → Request topic or access, Broker → Requests
The same building blocks everywhere Java Klok routes from one template, named after their solution and leg, logged the same way New integration, a solution's Legs, Logs
Documentation follows the code Every build on main describes itself, and the documentation is built from that Documentation, Context graph, a project's Docs column
AI proposes, a person decides Kloker drafts, plans and analyses; a person approves Ask Kloker, Kloker → Tasks and Background, Changes, Logs → Analyses

One Broker In The Middle

Without a common way, every system is wired directly to every other, each integration is built its own way, and nobody sees what a change reaches. On Klok, every system is connected once: an ingress takes its data to the broker, an egress takes data from the broker to it, and the datamodels are the contracts between them. Formats change at the edge: the ingress maps the system's own format to a shared model, and the egress maps the shared model to the receiver's format at the last moment, so a new receiver can read the same data without changing anything that exists.

The personnel scheduling flow (KLK010): two payroll systems publish employments, Konvoj gets them, and the schedules go back to each payroll system. Every system has legs of its own, and none of them knows the others. See Transform At The Edge and Topics, Subscriptions, And The Broker.

Git Is The Truth

The solution registry, the datamodels, the integration code, and the broker's topics and grants are files on main. klok.dev reads and writes them through the GitLab API, and whatever it does can also be done by hand in GitLab: what klok.dev shows is read again from main. That is why a change to a solution, a datamodel, a system or a project becomes your draft and then a merge request that someone reviews, and why a change request is a GitLab issue.

See Git Is The Truth: Everything Must Be Possible By Hand.

Write Narrow, Consume Wide

A tenant publishes only in its own namespace of the broker, and the topic's name decides the tenant, never the message. Reading a topic of another domain or tenant is a consume grant on that one topic, approved by the topic's owner and recorded in Git in the owner's tenant. In klok.dev you ask for it under Broker → Request topic or access, and the owner approves it under Broker → Requests. See Access: Roles, Groups, And Tenants and The Broker In klok.dev.

The Same Building Blocks Everywhere

Integration logic is Java Klok routes in repositories made from one template. A route's id says which solution and leg it belongs to: KLK010E2_PersonecScheduleFileOfframp is the second egress (E2) of solution KLK010. Every route logs the same events, so a business flow can be followed by its correlation id from start to end. Another choice is possible but tactical, and the solution document says why it was made and when it goes away. See Naming Standards and Choosing The Right Route Pattern.

Documentation Follows The Code

Every build on main publishes a description of itself: its routes, datamodels, configuration keys and the repository's own klok-docs/. It becomes the repository's documentation on docs.klok.dev and the project's part of the context graph in klok.dev, so what you read there is what is built. See Integration Context Graph.

AI Proposes, A Person Decides

Kloker answers questions about the landscape, plans changes, writes code and analyses failures. Everything it does becomes a draft, a merge request, an issue or a question for a person, and it never does anything irreversible on its own. See What Kloker Does and Human Review And Traceability.

How The Menu Follows From It

Part of the menu What it is for Pages
Top Where the day starts, and a question in plain language Home, Ask Kloker
Build Describe and change what lives in Git: from a need to the routes that meet it How The Build Pages Fit Together, then Solutions, Changes, Integration projects, Datamodels, Systems, Context graph, Business Cases
Run See how it runs: the runs, the logs, the files, the broker, the data and what is deployed How The Run Pages Fit Together, then Process runs, Logs, File flows, Broker, Operative data, Repositories, Documentation
Manage Kloker, and who may do what in the tenant Kloker, Tenant

The screenshots in this chapter are taken from klok.dev with an example tenant: the people and data in them are made up, and the names of solutions, routes and datamodels follow tenant klok's real landscape.