02 Information Models And Data Models

Information Models And Data Models

Klok information models describe business information with the precision needed to exchange and use it across systems. They are operational information models for integration: field names, data types, required fields, allowed values and business meanings are explicit. Shared models describe the business rather than copying one system's internal structure; system models describe the representations used at the edges.

The models themselves are distinct from their model levels (A/public, B/common, C/domain, X/system) and the design rules for information models. Those rules govern broker use, naming, schema evolution and model structure. Simple-type fields at the root (the first level) are what Klok ODL services list and filter on; choose root fields deliberately to support searching and indexing (see Using Datamodels In The ODL).

Information models are how Klok prevents integration landscapes from collapsing into ungoverned schema spaghetti. A data model is not just a file. It is a contract that determines what the broker carries, what routes can transform, what documentation can explain, and what downstream consumers can rely on.

What A Data Model Represents

A data model describes a payload type and version. In Klok, the major version should be part of the model or class name, such as InvoiceV1 or CustomerGlobalV2. This keeps incompatible models distinct in Java code and topic names.

A model should define:

  • Business meaning.
  • Fields and constraints.
  • Ownership and scope.
  • Model level (A/public, B/common, C/domain or X/system).
  • Version and compatibility rules.
  • Example payloads.
  • Links to systems, solutions, topics, and route legs.

Data Model Scopes

Scope Class Git Path Use When
Public A <tenant>/datamodel/public/<model> Other tenants or outside parties need a stable public contract
Common B <tenant>/datamodel/common/<model> Multiple domains inside the tenant use the same contract
Domain C <tenant>/datamodel/domain/<domain>/<model> A specific domain owns and evolves the contract
System X <tenant>/datamodel/system/<system>/<model>, or plain Java in the integration The model mirrors the format of one external system

All four may be sent over the broker. System models tie their readers to one system, so data that other systems or domains will read is transformed into a shared model at the edge. See Information Model Levels.

Publishing Models

A new model gets a Git repository of its own from the datamodel template, with its XSD, metadata and klok-docs/. Its pipeline publishes generated Java, Python and TypeScript classes and documentation on docs.klok.dev. A class X model may instead be plain Java classes in an integration. Creating A Datamodel walks through the choices.

Breaking changes should not overwrite an existing major model. The UI should suggest a new major version, such as moving from CustomerV1 to CustomerV2.

Model Design Checklist

  • [ ] The model name includes the major version.
  • [ ] The owner tenant and domain are clear.
  • [ ] The model level is explicit.
  • [ ] If the model is Class X, its readers are meant to depend on that one system.
  • [ ] Example payloads are realistic.
  • [ ] The compatibility story is documented.
  • [ ] Related topics and route legs can be derived.
  • [ ] Documentation and context snapshots can be generated.