Sketch: Network Modelling

Clojure software architects often say that we add schemas "at the boundaries"

Sketch allows you to model and test the entire system with those boundaries, before building and deploying any components.

Github Repo

Demo: when you run this test it generates the static HTML file below.

The actors and the step labels are clickable. They will display the state changes made each actor at any step.

The state diagrams are zoomable using your mouse wheel and can be dragged.

Example diagram showing network interactions

This provides an effective thinking / storytelling / discussion tool.

You can clone the repo and run it yourself locally if you want to play with it. If you do, try this:

Why: what problems does this address?

Complex Reasoning: Understanding and predicting the behavior of distributed components is difficult. Integration tests describing systems often become large and complex. This complexity makes it difficult for developers to maintain a complete mental model of the entire test.

Collaborative Design Difficulties: Designing distributed systems requires effective collaboration among team members. Many external factors increase the difficulty of sharing design knowledge.

Schema Naming Drift: Maintaining consistent naming conventions across distributed components is challenging. Over time, schema keyword naming drift can occur, leading to greater cognitive load, misinterpretations and integration issues between services. Some projects have mixtures of keyword styles in domain functions which can lead to confusion.

Opaque Integration Tests: Integration tests are often crafted as sequential narratives that describe system behavior. Typically only developers use them to understand the system. There are many other people who could benefit from that understanding. With that knowledge, they can contribute more to the design process.

How: what do you get?

There are two data flows provided by Sketch that are useful:

Malli Schema Generation

The core of the system design is described by an EDN/Aero file See io.nextdoc.sketch.core/model-registry to understand the shape.

You can start a file watcher on this which will emit a Malli registry to a namespace of your choice

clj-rewrite is used to maintain the generated form in this file with alphabetical order.

The watcher warns when generated registry keywords are no longer in sync with the model.

You can build out your domain directly in the generated registry or reference other domain registries that you merge together.

Interactive static HTML review tool

Each Sketch test generates its own static HTML file which is used to review the sequence of steps.

Click on the image above to experiment with the interactivity.

Source code benefits

Testing: tools you can use

Benefits

Status

Roadmap

How can you help?