Creating Story-Telling Interactive Diagrams With Draw - Io - Better Programming
Creating Story-Telling Interactive Diagrams With Draw - Io - Better Programming
io | Better Programming
Open in app
10
Search
Rinagreen · Follow
Published in Better Programming
12 min read · Dec 13, 2021
Stories and pictures are simple yet powerful tools that help the human brain absorb
new knowledge more comprehensively and remember it longer. In the context of
technical writing, wouldn’t it be great to leverage both instruments to create
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 1/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Among all scenarios (stories) that the service implements, we will cover three
essential ones, namely:
3. searching for profiles by certain criteria (using the mentioned search &
analytics engine).
Despite the prefix ‘-micro’, the service contains several modules, interaction of
which enables its performance. Those components are:
For this service, we will create an interactive schema that explains its architecture
(the relationships between its components) in the context of its business purpose
(the scenarios it implements). To do so, we will use draw.io with its layering feature.
So, if it sounds like something you would like to participate in, let’s start.
The background layer is the core one and should depict those elements that will be
parts of other layers. The background layer is displayed all the time regardless of
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 2/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
The background layer on the schema for Profile Service will represent the service’s
internal organization. It will contain only the components (modules) of Profile
Service with no relationships between them:
Although the service interacts with other software — the website where Users create
their profiles, a search & analytics engine, a database, etc. — we deliberately don’t
display them on the background layer. They will appear later on the corresponding
scenario layers because they are parts of the logic, not the internal organization of
Profile Service.
A control panel for the schema should also be placed on the background layer. The
control panel consists of buttons to display and hide the scenarios. Colored arrows
in buttons will help to differentiate the stories on the schema. Additionally, you can
add an area where descriptions of the scenarios will appear:
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 3/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Important notes
Components of Profile Service are now in grey. In such a way, we emphasize
that they are inactive for now. Later on, when they appear in a particular
scenario, we will change their colors appropriately.
The Description area will contain algorithms for the scenarios so that when
readers switch on one of them, they immediately can read the corresponding
story. However, there is a limitation — only one scenario can be displayed in the
area. We will come back to this restriction in the section Adding Interactivity.
How it works
After a User submits a profile on the website:
2. Receptionist — the consumer of the queue on the Profile Storage’s side — “listens’’
to the message queue. When it has enough capacity, it takes the message with
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 4/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
3. Receptionist then validates the profile according to a particular set of rules and
saves the profile to the database.
4. Receptionist also sends a message with the profile ID to another message queue
that stores IDs of profiles to be indexed.
On the diagram, we will depict this logic on a separate layer named ‘S1. Saving a
profile to the database’. So, before adding any new elements, we
1. add a new layer with the corresponding name in the Layers panel;
2. lock the background layer (by clicking on the lock sign and making it dark-grey)
so that new elements won’t appear where they don’t belong;
Now, we are ready to picture the flow described in the “How it works” section:
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 5/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Important notes
Elements that are not parts of Profile Storage but involved in the logic are dark
grey.
In the Description area, we put the algorithm for the scenario so that readers
can match the arrows on the picture and their meanings.
The button Saving a profile on the control panel is blue on this layer, indicating
that this scenario is currently selected for display. We can’t change the color of
an element that is a part of another layer (Background). We need to copy the
element from the layer it originally belongs to, paste it on the current layer,
change its color (style), and move it on top of the original button:
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 6/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Another technical scenario hides behind the words ‘the website sends’. In this
scenario, at least two site components — the client’s side (front-end) and API
(back-end) — take part. But we combine these elements into one entity —
‘website’ — because they don’t directly relate to the business logic or the
architecture of Profile Service.
At this stage, it’s too early to add interactivity to the diagram. First, we need to create
all layers. Then we can work on switching between them.
If you are new to the concept, indexing of data is a way of storing the data in a special
place (index) to be quickly found and retrieved on demand. You can think of an
index as a database with sophisticated searching mechanisms. ElasticSearch is a
search & analytics engine commonly used to create extensive data indices.
How Indexing of profiles works
1. Indexer — the Profile Service’s module responsible for indexing of profiles —
takes the message with the profile ID from the indexing queue.
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 7/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
2. Indexer then sends a request to API to get profile data by the profile ID.
5. Indexer transforms the profile data into a format suitable for indexing (for
example, JSON) and saves the formatted profile to a corresponding index in a
search & analytics engine (SAE).
On the diagram, we will depict this logic on a separate layer named ‘S2. Indexing
profiles’. So, before adding any new elements, we
1. add a new layer with the corresponding name in the Layers panel;
2. lock both the background and ‘S1. Saving a profile to the database’ layers (by
clicking on the lock sign and making them dark-grey);
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 8/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Let’s put on the diagram the flow described in the “How Indexing of profiles works”
section:
1. The website sends a request to API to get profiles by the specified criteria.
2. API gets suitable profiles from the Profile index in the SAE.
3. For the retrieved profiles, API gets additional data from the database.
This step can be omitted if the Profile index stores all the needed parameters for
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 9/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
each profile. But if, for example, information about skills that Users manually
add to their profiles is not stored in the index, it will be retrieved from the
database on this step.
4. API returns the resulting set of profiles with all needed information to the
website (to the User).
Important notes
1. The optional step is depicted as a dashed arrow.
Adding Interactivity
At this point, we created all the layers for the schema, and readers can already
switch between them using the Layer panel. So, do we actually need to add any
interactivity?
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 10/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Having interactive buttons to display and hide certain scenarios seems more user-
friendly. Besides, everything becomes better when it is clickable.
The background layer is the first one that readers will see. Therefore, buttons in the
control panel of the background layer should respond to clicks and show the
corresponding scenarios. Let’s add interactivity to the Saving a profile button.
1. In the Layers panel, click on the S1. Saving a profile to the database layer;
2. In the bottom menu of the Layers panel, click on the pen icon to open the layer
for editing;
lock and hide all other layers (S1, S2, and S3);
5. Right-click on the Saving a profile button and select Edit Link… in the popup
menu:
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 11/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
{layer_ID} is the S1. Saving a profile to the database layer’s ID copied in step 3.
This code will show the scenario when readers click on the Saving a profile button
on the Background layer.
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 12/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
We use the same approach for the rest of the scenarios. After adding toggle actions
to all three scenario buttons, we have the following result:
Important notes
1. As we said before, the Description area can hold only one scenario at a time. So,
only an algorithm of the top layer among the selected ones will be displayed.
Now, readers can switch ON particular layers, but they can’t switch layers OFF. To
enable readers to hide scenarios, we will add hiding actions on the corresponding
buttons. Unlike showing actions added on the Background layer, hiding actions
should be added on the scenario layers.
Let’s look at the Saving a profile button. To hide the corresponding scenario, we
1. Switch to the S1. Saving a profile to the database layer of the diagram:
lock and hide all layers except Background and S1. Saving a profile to the
database;
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 13/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
show and unlock the S1. Saving a profile to the database layer;
2. Right-click on the Saving a profile button and select Edit Link… in the popup
menu.
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 14/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
This code will hide the scenario when readers click on the Saving a profile button
on the S1. Saving a profile to the database layer.
We use the same approach for the rest of the scenarios. After adding hide actions to
all three scenario buttons, we have the following result:
The only static button now is the Show/hide all scenarios one.
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 15/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
2. Copy the Show/hide all scenarios button and paste the copy near the original
one. Change the color and font of the copied button so that it looks like it is
clicked.
3. Right-click on the copied button, select Edit Data… in the popup menu, and
copy the ID of the button:
4. Go to the original button and add the following toggle action to it:
data:action/json,{“actions”:[{“toggle”:
{“cells”: [“{layer1_ID}”, “{layer2_ID}”, “layer3_ID”,
“copiedButton_ID”]}}]}
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 16/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
5. Add the same action to the copied button (the toggle action shows and hides
elements based on their current state — if they are displayed, it will hide them, and
vice versa).
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 17/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Final suggestions
Instead of a conclusion, I would like to add some more suggestions that may be
helpful when you create your own diagrams.
2. Put numbers on arrows — Numbers on arrows help readers to follow the story
you want to tell. They won’t be confused to find the starting point of a scenario
and the final one.
Useful resources
Interactive diagrams with custom links and actions
The XML code for the ProfileService file is available in this gist.
Follow
Written by Rinagreen
175 Followers · Writer for Better Programming
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 18/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
352 4
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 19/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
1.92K 17
This was a blog post that I already planned to write during the spring when I saw that the hype
around DuckDB started taking new heights…
1.6K 11
52 1
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 21/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
Wenqi Glantz
671 2
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 22/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
487 7
Lists
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 23/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
22
ByteWave
Introduction
71
98 1
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 25/26
4/22/24, 1:50 PM Creating Story-telling interactive Diagrams with draw.io | Better Programming
10.3K 111
https://betterprogramming.pub/creating-story-telling-interactive-diagrams-with-draw-io-f7e57ae32621 26/26