11 Datamodels

Datamodels

A datamodel is the contract between legs: what an ingress publishes and an egress reads, described once and used by every route on both sides. Each model is a repository of its own in GitLab, with its schema as an XSD; the model's pipeline turns it into Java, Python and TypeScript classes and records each release in the dependency catalog, where the integration projects take it from. Datamodels shows the tenant's models as GitLab has them, where each one travels on the broker, which projects use which release, and what a change to it would break.

  • In the menu: Build → Datamodels (/information-models/data-models)
  • For: architects and developers; developers and admins of a model's domain change it (of the tenant or common for public, common and system models)
  • Reads: the repositories under <tenant>/datamodel/ in GitLab, kept as a copy in klok.dev that is read again when the list opens and the last reading is more than five minutes old; the routes from every build on main; the broker for the Topics tab; a model's releases, its job token allowlist, the dependency catalog and the tenant's Pulsar file for Before it runs

What You See

Column What it says
Model The model's name, which opens its page, and the description from its klok-datamodel-project.json
Domain The model's domain, or System: <system> for a model under system/<system>/
Access Can edit when you may change the model, otherwise Read only
Version The major version; the exact release is the one in the dependency catalog
Fields The fields and complex types of the model's XSD: 17 fields · 27 types
Updated When the repository's default branch last had a commit
Sync Whether the last reading of the repository went through: In sync, Sync failed (the error on hover) or Pending

The line under the page title says when the library last read GitLab. Sync now reads it at once, for a Tenant Admin, a Domain Admin or platform staff; a repository whose newest commit has not moved since the last reading is skipped.

A model's page has Overview, Edit, Topics, Used by and, when you may change the model, Review. Overview has its description and facts: domain, its Contact (the owners of its domain, or the tenant's owners for a common, public or system model), who reads its documentation on docs.klok.dev, kind, version, repository, fields, complex types, the last commit and the last reading. While the model is not yet usable by its consumers, it ends with Before it runs (below).

Walkthrough: See Where A Model Travels And Who Uses It

  1. Search for the model, for example personnel, and open PersonnelSchedulingV1.

  2. Topics lists every topic that carries the model's types, one row per purpose: the generic topic persistent://klok/hr/PersonnelEmploymentBatchV1, and PersonnelEmploymentBatchV1_heroma for the flow from Heroma. Beside each are the routes that publish and consume it, from the builds on main, and the broker's live numbers: backlog, rates, the oldest message and the dead letters.

  3. Used by lists the integration projects whose build on main takes the model, by name or through a bundle of the catalog, with the release each one has against the release the catalog names now. It reads every project's build files from GitLab when it opens, so it takes a few seconds and shows what is on main right now.

  4. A project that is behind links to its own Datamodels tab, where Kloker analyses the upgrade (Integration Projects).

A topic for a new purpose is asked for with Request a purpose topic on the Topics tab; the topic's owner approves it under Broker → Requests (Broker). The generic topic, the model's name without a purpose, needs no approval: New model declares it when it creates the model, a build that needs it gets it at once, and the tenant's Ensure declares it for a model made by hand.

Walkthrough: Change A Model

  1. Open the model and Edit. Your draft starts from main.

  2. Open the XSD under Schema. Model shows it as a table: every complex type with its fields (name, type, required, list, description) and every enum with its values. A change in the table is a change of the XSD text in your draft, as small as the edit; Edit shows the same file as text, and Suggest fields asks Kloker for fields, which you take or leave part by part.

  3. Read the box above the table. It lists what your draft changes against main and marks what is breaking: a field removed or renamed, a field that became required or optional, a changed type or list, an enum value added or removed, a type removed. A release must work both ways with every earlier one, so the model's pipeline refuses a breaking change: it needs a new major version, which is a new datamodel.

  4. On Review, give the merge request a Conventional Commits title, such as feat(datamodel): add reasonCode to PersonnelAbsencePeriodV1, say what and why, and Create merge request.

  5. The model's owner merges it in GitLab. The model's pipeline releases the new version, writes it to the dependency catalog, and the library shows it at its next reading. The projects then move to it from their Datamodels tab.

Walkthrough: Create A Model

  1. Choose New model. Choose the Class (A public, B common, C domain, X system), the domain or system it belongs to, its Name in PascalCase without a version, its Major version (1 for a new model) and a one-line Description.

  2. What klok.dev creates shows the names the platform's rule gives it, the same as klok datamodel names: the repository <tenant>/datamodel/<public | common | domain/<d> | system/<s>>/<model-kebab>-v<n>, the root element <Model>_v<n> of the type <Model>V<n>, and the namespace. A repository that exists already is refused, and so is a system that is not on Systems.

  3. Create the datamodel creates the repository from project-template-datamodel, with an example XSD under the model's name, and its documentation project. Its one commit runs no pipeline, so the template's example is never released. klok.dev also puts the tenant's root group on the project's CI job token allowlist, so that its consumers' pipelines may read its packages, and declares its generic topic, persistent://<tenant>/<namespace>/<Model>V<n>, in the tenant's Pulsar file and on the broker. The model's page opens on Edit.

  4. Write the XSD in your draft, with the checks beside it, and Create merge request on Review. The merge to main releases version 1, and the release writes its version into the dependency catalog.

  5. Until the model is usable by its consumers, its Overview ends with Before it runs, each step read from where it is true when the page opens: | Step | Done when | | --- | --- | | Its packages, readable by the tenant's pipelines | The tenant's root group is on the project's CI job token allowlist; without it a consumer's build gets 403 from the package registry | | Its first release | The project has a release; until then the step follows the pipeline on main | | Its line in the dependency catalog | The catalog on main names the release's version | | Its generic topic | The tenant's Pulsar file declares it |

A step on its way says what it waits for, and one left to a person says what to do. The list goes away once every step is done or out of klok.dev's sight.

What Happens In Git

In klok.dev In Git Merged by By hand
Create the datamodel A new repository from project-template-datamodel, its first commit chore: initialize <name> from project-template-datamodel [skip ci] straight on main, which is then protected; the tenant's root group on its CI job token allowlist; its documentation project; and the merge request feat(pulsar): create the generic topic of <Model>V<n> to the tenant's Pulsar file klok.dev merges the Pulsar file's merge request and applies it; nobody merges the first commit Create the project from the template in GitLab, put the schema in schema-definition-xsd/, fill klok-datamodel-project.json, push; add the tenant's root group under Settings → CI/CD → Job token permissions; the next Ensure declares the generic topic
Edit, then Review → Create merge request Your draft as commits on a branch klok-dev/<model>-<id>, and a merge request with your title The model's owner, in GitLab The same change on a branch of your own
The merge, in GitLab The model's pipeline checks compatibility, publishes the classes and commits the release to the dependency catalog: chore(catalog): update <name> to the version published by <repository>@<sha> — —
Request a purpose topic A request in klok.dev; once approved, a merge request to the owning tenant's Pulsar file, which klok.dev merges and applies The topic's owner approves in klok.dev The topic's line in the Pulsar file, in a merge request
Sync now Nothing: klok.dev reads GitLab again — —

Opening a model never writes anything about it. See What klok.dev Does In Git for every page.

Who Does What

Automation Kloker You
The library reads GitLab; the box under Model applies the pipeline's compatibility rule as you type; the model's pipeline validates the XSD, refuses a breaking change, publishes Java, Python and TypeScript classes and records the release in the catalog; New model puts the tenant's group on the allowlist and declares the generic topic, merged without approval; Before it runs reads each step when the page opens Suggest fields proposes fields you take or leave; Analyse upgrade on a project's Datamodels tab compares two releases for that project; Kloker beside the page answers questions about the model and writes the merge request's title when you ask Describe the contract, decide when a change needs a new major version, review and merge

See You, The Automation And Kloker.

How It Connects

A solution's document names the datamodels its legs use (Solutions); a system's own models live in its group (Systems); the projects take each release from the catalog (Integration Projects); the Broker carries them on topics; the Operative data layer stores objects by their model; and the Context graph shows what a change to a model would reach.

Read More