05 Finding What Already Exists

Finding What Already Exists

Reuse is where Klok pays back: the second integration that needs employments, customers or invoices should use what the first one built, not build its own copy. So before anything is designed, the architect checks what the landscape already has, and the business confirms that what is reused really means what the need means. This page is for both.

Where To Look

The question Where to look
Is there a solution for this business flow already? The solution documents in the organisation's integration-solutions repository, listed in klok.dev under Build → Solutions. A route id's prefix names its solution: KLK010E2_… belongs to KLK010.
Is this system integrated already? klok.dev, Build → Systems, and Build → Integration projects, where a project's row shows the routes of its last build
Is there a datamodel for this information? klok.dev, Build → Datamodels; the model's documentation on docs.klok.dev says what it means, and its Topics tab shows who publishes and reads it
Who already publishes or reads this information, and what would a change affect? klok.dev, Build → Context graph; Ask Kloker ("which integrations read employments?"); an impact analysis on Kloker → Tasks
What does an existing service do, with which topics and settings? The service's documentation on docs.klok.dev
What is running right now, and on which topics? klok.dev, Run → Broker, which shows every topic of a namespace with its publishers, subscriptions and grants

Architects and developers have the same answers on the command line:

Command Answers
klok agent ask "Which legs consume InvoiceV1?" the same landscape questions as Ask Kloker in klok.dev
klok agent impact InvoiceV1 --change major what a change of a datamodel affects
klok docs read <doc-id> a project's whole documentation as one file
klok solutions check --root <registry checkout> where the solution documents and the route classes in the code disagree
klok fleet status --broker every deployed service, and every producer and consumer on the broker

What The Analysis Produces

The analysis answers the same questions whether a person, Kloker or both do it, and its answers go into the solution document (sections 4 and 6):

  • Reusable components: solutions, services, datamodels and topics the need can use, and for each whether it is used as it is or needs a change.
  • New components: what has to be built, and why nothing existing fits.
  • Information model levels: the class of every datamodel involved, and who reads it.
  • Legs and patterns: the legs the solution needs and the pattern of each, as a first proposal for the design.
  • Topic names: the topics the legs will use, with their purposes.
  • Open questions: what has to be answered before the design holds.

Build, Extend Or Reuse

Every service the solution needs is classified, because each kind is a different amount of work and has a different owner:

Kind When What it means
Reused as is A topic already carries the right datamodel in the right flow, and its owner and meaning match the need Nothing changes in the existing service. The new solution adds a reader of its own: an egress with its own subscription, and a consume grant when the topic belongs to another domain or organisation. It is still named in the solution document, so that everyone can see what it depends on.
Reused, slight change Something exists but needs a change to serve the need: a new optional field, a purpose for a new flow, a new setting The change is made in the owning project, in its own merge request, reviewed by its owners.
New routes in an existing project The system is integrated already New legs in the project that already speaks to the system, so that everything for one system stays together.
New project The system is not integrated yet A new repository, named after the system and the kind of leg.
Client change An application calls the solution The change in that application is listed, so that it is planned too.

Two decisions sit next to the table:

  • Extend a solution or start a new one? When the need is part of the same business flow, with the same owner, it extends the existing solution: new legs under the same solution id. When it is a new business goal, it is a new solution.
  • Use a datamodel or make a new one? When a datamodel fits, use it. When it almost fits, find out whether the change it needs is compatible (a new optional field) or breaking (a new major version). A second datamodel for the same business object makes every later integration choose between them.

The Platform's Own Services Come First

Some needs are met by services the platform already runs, and those are reused before anything is built:

Need Platform service
Long-running work with progress, steps and a result that people can follow Tasks and the task API
Storing and searching business objects The Operative Data Layer
AI: text, images, analysis The AI services and the Kloker gateway
Large files and images The claim check: the file is stored once and the messages carry a reference
Agreed information models The datamodels in the dependency catalog

Tasks, the Operative Data Layer and the AI services serve tenant klok today; serving other tenants is tracked in frontend-klok-dev#51. Sending and receiving e-mail is designed as a shared service, solution KLK006, and is not built yet (klok/integration-solutions#19).

Signals Worth Knowing

  • A name is not a meaning. Do not reuse a topic or a datamodel because its name looks right. Read what it means, who owns it and who reads it.
  • A reader that throws most messages away on a shared topic is reading a flow that should have its own purpose. The fix is in the producer, as a slight change. See Topic Purpose.
  • A second domain that needs a domain model is a reason to move the model to class B, so that the domains agree on it together.
  • Information in one system's format, read by others, is a coupling to that system. It is reused only inside that system's own flow; others get it translated into a shared model.

When The Map Is Incomplete

The registry of solution documents is the intended map, but it does not yet name every solution that has code: klok solutions check lists the solutions, legs and route ids where the documents and the code disagree, and the work to reconcile them is tracked in klok/integration-solutions#7. A reuse analysis therefore also looks at the code and the integration context, not only at the documents, and a gap it finds is corrected in the solution document or filed as an issue.

The next step is the design itself, reviewed as the solution document: Reviewing A Solution Document.