Skip to content

Instantly share code, notes, and snippets.

@yitsushi
Created February 15, 2022 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yitsushi/ce4c6ef2bb749fc4bb77c5127ac90ca8 to your computer and use it in GitHub Desktop.
Save yitsushi/ce4c6ef2bb749fc4bb77c5127ac90ca8 to your computer and use it in GitHub Desktop.
Simple Communication Diagram with LaTeX
\documentclass{standalone}
\usepackage{tikz}
\usepackage{transparent}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{anyfontsize}
\usetikzlibrary{calc, backgrounds, positioning, matrix}
\newcommand{\layer}[3]{
\node[draw] (top) at (#1, #2) {#3};
\node[draw] (bottom) at (#1, 0) {#3};
\draw (top.south) -| (bottom.north);
}
\newcommand{\arrow}[5]{
\draw[-stealth] (#1, #3) -- (#2, #3) node [#5] {#4};
}
\newcommand{\arrowstream}[6]{
\draw[-stealth, dotted] (#1, #3) -- (#2, #4) node [#6] {#5};
}
\definecolor{foreground}{RGB}{149, 149, 159}
\definecolor{background}{RGB}{41, 42, 45}
\begin{document}
\begin{tikzpicture}[
draw=foreground, text=foreground,
label/.style={pos=0.5,above,font=\tiny, sloped}
]
\newcommand{\height}{5};
\newcommand{\webui}{0};
\newcommand{\gitops}{5};
\newcommand{\mngc}{10};
\newcommand{\leafca}{15};
\layer{\webui} {\height} {Web UI};
\layer{\gitops} {\height} {Backe-end};
\layer{\mngc} {\height} {Agent};
\layer{\leafca} {\height} {Cluster};
\arrow{\webui}{\gitops}{4}{List all Releases}{label};
\arrowstream{\gitops}{\webui}{1}{0.5}{Stream}{label};
\arrow{\gitops}{\mngc}{3.5}{List all Releases} {label};
\draw[dotted] (\mngc, 2.75) -- (7.5, 2.75);
\draw[dotted] (7.5, 2.75) -- (7.5, 1)
node [label, rotate=180] {Stream};
\arrowstream{7.5}{\gitops}{1}{1}{}{};
\arrow{\mngc}{\leafca}{3}
{List all Releases}{label};
\draw[dotted] (\mngc, 2.5) -- (7.5, 2.5);
\arrowstream{\leafca}{\mngc}{2.5}{2.5}
{List of events (Releases)}{label};
\arrowstream{\leafca}{\mngc}{2}{2}
{New events (Release)}{label};
\arrowstream{\leafca}{\mngc}{1.5}{1.5}
{New events (Release)}{label};
\draw[dotted] (\mngc,2) -- (7.5, 2);
\draw[dotted] (\mngc,1.5) -- (7.5, 1.5);
% Add a bit of margin ;)
\node[yshift=1em, xshift=-2em] at (0, \height) {};
\node[yshift=-1em, xshift=2em] at (\leafca, 0) {};
\end{tikzpicture}
\end{document}
@yitsushi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment