How sync works in 5 minutes

bausteinsicht sync keeps two files in agreement: the model architecture.jsonc (text) and the diagram architecture.drawio. It is not a copy in one direction and not a merge of two files. It works like this:

  1. It reads the model, the diagram and a third file, .bausteinsicht-sync, the sync state: what both looked like after the last sync.

  2. It compares each side with that state. What changed on the model side goes to the diagram, what changed on the diagram side goes to the model.

  3. If both sides changed the same thing, the model wins and sync prints a warning that names the element.

  4. It writes both files and a new sync state.

The model is the source of truth for the structure of the architecture; the diagram is where you arrange it and where you may edit texts.

The six steps of a sync: read the model

What happens when I change something

I changed …​ Sync does …​ Note

the title (or technology, description) of an element in the model

the shape in the diagram shows the new text

the title of an element in draw.io (the text of its title cell)

the model gets the new title

Empty titles are refused. The same holds for technology and description.

the same title on both sides

the model’s value is kept in both files and sync warns about a conflict

"Model wins". The text you typed in draw.io is overwritten. Sync still writes both files, but ends with exit code 1 so that a script notices.

a new element in the model (and it is in a view)

a new shape appears, with a red dashed border

The border only marks "new"; remove it in draw.io when you have arranged the shape.

a new shape in draw.io (a box with a label)

the model gets a new element with an ID made from the label, the first kind of the specification in alphabetical order (or the kind the shape carries, if the specification has it), and a warning to review it

New arrows from or to such a shape become relationships.

a shape deleted in draw.io

the element is removed from the model, together with its relationships and its entries in views

Sync warns and lists what it removed. A view’s scope or an element named by a constraint is kept, and drawn again.

an element deleted in the model

the shape and its arrows are removed from the diagram

a shape moved or resized in draw.io

nothing in the model

Layout belongs to the diagram. bausteinsicht layout arranges all shapes anew.

a relationship added, relabelled or removed

the arrow follows (model to diagram), and in the other direction a new arrow, a new label or a deleted arrow reaches the model

a view added or removed in the model

a page is added to or removed from the diagram

What is not read back from draw.io

  • Layout: positions, sizes and colours are not copied to the model.

  • Links of elements: they are written to the diagram, but a link changed in draw.io is not read back.

  • Style changes on a shape (colours, fonts): kept in draw.io, ignored by the model; the template decides the style of new shapes.

  • Shapes without a label are not imported as elements.

One model per directory

The model, its diagram and its sync state belong together and are expected next to each other: architecture.jsonc, architecture.drawio, .bausteinsicht-sync. Use one model per directory. Several perspectives on one architecture are views (one page each), not several models. If a directory must hold more models, give each its own diagram and state with --drawio and --sync-state; the sync state remembers its model and refuses to be used with another one.

When something looks wrong

  • A shape has a red dashed border: it is new, see above.

  • An edit you made in draw.io is gone after sync: you changed the same thing in the model, or it is something that is not read back (see the list above).

  • More: Troubleshooting. The details of the algorithm are in the sync specification.