Kanonik – from specification to codeDEEN

Library: lending

Holds, checkouts, returns and catalogue – specification versus a DDD domain model with aggregates and events in Java.

Profile

38Requirements
10Rules
7Roles and systems
13Messages in the specification
7Services in the code
108Classes
8Gaps
100 %Recall against reviewed findings (regression)
33 %Recall against independently collected gaps

Full profile in the reader →

Source documents and findings are in German.

How this example came about

Choice

A project without BPMN but with a careful domain model: ddd-by-examples/library (Java, Spring, modular monolith, DDD with aggregates and domain events). It tests the domain side of the comparison: rules, invariants and events of the specification against aggregates and events in the code.

Preparation

We wrote and structured the specification for this demo from the project's domain description and EventStorming results: lending processes, business rules, domain model, messages. Fixed were the commit of the code and the list of expected gaps (test oracle). The language-model extraction was reviewed and accepted; every further run is repeatable without a language model.

What Kanonik did

Kanonik translated the specification into a knowledge graph and read the code: classes, aggregates, domain events raised and received (@EventListener), REST endpoints. From the code it generated an OpenAPI description (patron profile) and an AsyncAPI description of the Spring events, pointing to every place in the code. A mapping specification → code shows requirements and rules per service, package and class; the comparison yields the gap list, measured against the test oracle.

Guided tour

  1. The specification
    Chapter 4 describes the lending processes – from placing a hold (A-4.1-1) to returning a copy; chapter 6 the business rules, chapter 8 the domain model. →
    Screenshot: The specification
  2. The gaps
    The comparison finds events the specification requires but the code never publishes – such as a copy being returned. →
    Screenshot: The gaps
  3. From finding to source
    Every requirement and rule in the gap list opens the specification at its evidence. →
    Screenshot: From finding to source

View the specification

Gaps

8 gaps between specification, BPMN and code

Architecture (ArchiMate)

Enterprise architecture of the domain in ArchiMate 3.2, derived from specification and interfaces: 296 elements, 930 relationships.

View the diagram by layer →

Download model.xml for Archi (File → Import → Open Exchange XML Model)

Interfaces from the code

The project has no interface description. Kanonik generated it from the source code: OpenAPI for REST, AsyncAPI for events and messages. Every element points to its place in the code (x-kanonik-code).

7 REST operations, 23 event operations, 13 messages →

Graph and search (reader)

Graph and search (reader) →

Sources and rights

Specification written for this demo, based on the project's domain description; code from ddd-by-examples/library (MIT).