Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Diagram: Architecture #5452

Draft
wants to merge 44 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
03bbfa0
build: added cytoscape-fcose
NicolasNewman Mar 11, 2024
5a4d497
feat: added architecture diagram parser
NicolasNewman Mar 11, 2024
346ae22
feat: registered architecture diagram
NicolasNewman Mar 11, 2024
cc22e13
feat: added architecture DB & types
NicolasNewman Mar 11, 2024
e01acec
feat(arch): implemented icon registration
NicolasNewman Mar 13, 2024
6c6ce28
feat(arch): implemented basic rendering for diagram
NicolasNewman Mar 13, 2024
84bd20b
feat(arch): improved group rendering
NicolasNewman Mar 17, 2024
5e21487
style(arch): prettier formatting
NicolasNewman Mar 19, 2024
a493e2f
feat(arch): dynamic node sizing
NicolasNewman Mar 25, 2024
0ab7a3d
feat(arch): added 4 default icons, added config field for icons
NicolasNewman Mar 27, 2024
10682ef
feat(arch): added demo
NicolasNewman Mar 27, 2024
b911bd3
feat(arch): improved error handling
NicolasNewman Mar 31, 2024
46a37a6
feat(arch): added fallback icon
NicolasNewman Mar 31, 2024
361e25b
fix(arch): fixed compound nodes overlapping
NicolasNewman Mar 31, 2024
f47bbee
feat(arch): added more demos
NicolasNewman Mar 31, 2024
36f52be
feat(arch): improved positioning system to better handle edge cases
NicolasNewman Apr 3, 2024
92d819e
feat(arch): disconnected graph handling for positioning
NicolasNewman Apr 3, 2024
2709c2d
style(arch): prettier formatting & code cleanup
NicolasNewman Apr 4, 2024
6d5791a
feat(arch): arrows now rendered on diagram
NicolasNewman Apr 4, 2024
aef991b
feat(arch): XY edges now have a 90deg bend
NicolasNewman Apr 7, 2024
22c0090
refactor(arch): reorganized code and added more documentation
NicolasNewman Apr 7, 2024
251e808
build(arch): expose SVG library types
NicolasNewman Apr 7, 2024
baa6c9e
test(arch): added edge arrow demo
NicolasNewman Apr 7, 2024
dcb1b48
merge(arch): : Merge branch 'develop' of https://github.com/mermaid-j…
NicolasNewman Apr 7, 2024
0a14f2c
fix(arch): changed how cytoscape namespace extension is handled to pr…
NicolasNewman Apr 7, 2024
6bd1da2
refactor(arch): refactored code to be consistent with other diagrams
NicolasNewman Apr 7, 2024
073175e
style(arch): resolved es-lint errors
NicolasNewman Apr 11, 2024
497712a
feat(arch): exposed createIcon function
NicolasNewman Apr 11, 2024
cb302a0
feat(arch): converted parser from jison to langium
NicolasNewman Apr 15, 2024
a5d3164
feat(arch): edge labels implemented
NicolasNewman Apr 17, 2024
1d27fac
feat(arch): added cloud svg icon
NicolasNewman Apr 17, 2024
84f1d82
feat(arch): implemented group icons
NicolasNewman Apr 18, 2024
2dfadca
style(arch): disabled no-console for archDB, removed jison
NicolasNewman Apr 18, 2024
ac7891c
feat(arch): improved handling of styles
NicolasNewman Apr 19, 2024
b28f9f8
docs(arch): started writing diagram documentation
NicolasNewman Apr 22, 2024
634b00b
feat(arch): changed how groups are stored in the db
NicolasNewman Apr 22, 2024
b21fc9f
feat(arch): added theme variables for dark and default
NicolasNewman Apr 22, 2024
cabb7b6
fix(arch): Y axis labels rotated to opposite side
NicolasNewman Apr 29, 2024
734bde3
feat(arch): implemented node labels
NicolasNewman May 6, 2024
48e6901
style(arch): linting
NicolasNewman May 6, 2024
5b6c95c
feat(arch): extended parser to control how edges pass through groups
NicolasNewman May 9, 2024
0049127
chore(arch): synced with develop
NicolasNewman May 9, 2024
b09dc5d
feat(arch): implemented junction nodes
NicolasNewman May 10, 2024
769d566
feat(arch): added aws icons
NicolasNewman May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .build/jsonSchema.ts
Expand Up @@ -25,6 +25,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
'sankey',
'block',
'packet',
'architecture',
] as const;

/**
Expand Down
2 changes: 2 additions & 0 deletions .cspell/code-terms.txt
Expand Up @@ -53,6 +53,7 @@ GENERICTYPE
getBoundarys
grammr
graphtype
halign
iife
interp
introdcued
Expand All @@ -64,6 +65,7 @@ Kaufmann
keyify
LABELPOS
LABELTYPE
layoutstop
lcov
LEFTOF
Lexa
Expand Down
1 change: 1 addition & 0 deletions .cspell/libraries.txt
Expand Up @@ -23,6 +23,7 @@ Docsy
DokuWiki
dompurify
elkjs
fcose
fontawesome
Foswiki
Gitea
Expand Down
310 changes: 310 additions & 0 deletions demos/architecture.html
@@ -0,0 +1,310 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Architecture Mermaid Quick Test Page</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
<style>
div.mermaid {
/* font-family: 'trebuchet ms', verdana, arial; */
font-family: 'Courier New', Courier, monospace !important;
}
</style>
</head>

<body>
<h1>Architecture diagram demo</h1>
<h2>Simple diagram with groups</h2>
<pre class="mermaid">
architecture
group api(cloud)[API]

service db(database)[Database] in api
service disk1(disk)[Storage] in api
service disk2(disk)[Storage] in api
service server(server)[Server] in api
service gateway(internet)[Gateway]

db L--R server
disk1 T--B server
disk2 T--B db
server T--B gateway
</pre>
<hr />

<h2>Groups within groups</h2>
<pre class="mermaid">
architecture
group api[API]
group public[Public API] in api
group private[Private API] in api


service serv1(server)[Server] in public


service serv2(server)[Server] in private
service db(database)[Database] in private

service gateway(internet)[Gateway] in api

serv1 B--T serv2

serv2 L--R db

serv1 L--R gateway
</pre>
<hr />

<h2>Default icon (?) from uknown icon name</h2>
<pre class="mermaid">
architecture
service unknown(iconnamedoesntexist)[Uknown Icon]
</pre>
<hr />

<h2>Split Direction</h2>
<pre class="mermaid">
architecture
service db(database)[Database]
service s3(disk)[Storage]
service serv1(server)[Server 1]
service serv2(server)[Server 2]
service disk(disk)[Disk]

db L--R s3
serv1 L--T s3
serv2 L--B s3
serv1 T--B disk
</pre>
<hr />

<h2>Arrow Tests</h2>
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
service servR(server)[Server 3]
service servT(server)[Server 4]
service servB(server)[Server 5]

servC (L--R) servL
servC (R--L) servR
servC (T--B) servT
servC (B--T) servB

servL (T--L) servT
servL (B--L) servB
servR (T--R) servT
servR (B--R) servB
</pre>
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
service servR(server)[Server 3]
service servT(server)[Server 4]
service servB(server)[Server 5]

servC (L--R) servL
servC (R--L) servR
servC (T--B) servT
servC (B--T) servB

servT (L--T) servL
servB (L--B) servL
servT (R--T) servR
servB (R--B) servR
</pre>
<hr />

<h2>Group Edges</h2>
<pre class="mermaid">
architecture
group left_group(cloud)[Left]
group right_group(cloud)[Right]
group top_group(cloud)[Top]
group bottom_group(cloud)[Bottom]
group center_group(cloud)[Center]

service left_disk(disk)[Disk] in left_group
service right_disk(disk)[Disk] in right_group
service top_disk(disk)[Disk] in top_group
service bottom_disk(disk)[Disk] in bottom_group
service center_disk(disk)[Disk] in center_group

left_disk{group} (R--L) center_disk{group}
right_disk{group} (L--R) center_disk{group}
top_disk{group} (B--T) center_disk{group}
bottom_disk{group} (T--B) center_disk{group}
</pre>
<hr />

<h2>Edge Label Test</h2>
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
service servR(server)[Server 3]
service servT(server)[Server 4]
service servB(server)[Server 5]

servC L-[Label]-R servL
servC R-[Label]-L servR
servC T-[Label]-B servT
servC B-[Label]-T servB

servL T-[Label]-L servT
servL B-[Label]-L servB
servR T-[Label]-R servT
servR B-[Label]-R servB
</pre>
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
service servR(server)[Server 3]
service servT(server)[Server 4]
service servB(server)[Server 5]

servC L-[Label that is Long]-R servL
servC R-[Label that is Long]-L servR
servC T-[Label that is Long]-B servT
servC B-[Label that is Long]-T servB

servL T-[Label that is Long]-L servT
servL B-[Label that is Long]-L servB
servR T-[Label that is Long]-R servT
servR B-[Label that is Long]-R servB
</pre>

<hr />
<h2>Junction Demo</h2>
<pre class="mermaid">
architecture
service left_disk(disk)[Disk]
service top_disk(disk)[Disk]
service bottom_disk(disk)[Disk]
service top_gateway(internet)[Gateway]
service bottom_gateway(internet)[Gateway]
junction juncC
junction juncR

left_disk R--L juncC
top_disk B--T juncC
bottom_disk T--B juncC
juncC R--L juncR
top_gateway B--T juncR
bottom_gateway T--B juncR
</pre>
<hr />

<h2>Junction Demo Groups</h2>
<pre class="mermaid">
architecture
group left
group right
service left_disk(disk)[Disk] in left
service top_disk(disk)[Disk] in left
service bottom_disk(disk)[Disk] in left
service top_gateway(internet)[Gateway] in right
service bottom_gateway(internet)[Gateway] in right
junction juncC in left
junction juncR in right

left_disk R--L juncC
top_disk B--T juncC
bottom_disk T--B juncC


top_gateway (B--T juncR
bottom_gateway (T--B juncR

juncC{group} R--L) juncR{group}
</pre>
<hr />

<h2>AWS Icon Demo</h2>
<pre class="mermaid">
architecture
service s3(s3)[Cloud Store]
service ec2(ec2)[Server]
service wave(wavelength)[Wave]

s3 L--R ec2
s3 T--B wave
</pre>

<script type="module">
import mermaid from './mermaid.esm.mjs';

const ALLOWED_TAGS = [
'a',
'b',
'blockquote',
'br',
'dd',
'div',
'dl',
'dt',
'em',
'foreignObject',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'h7',
'h8',
'hr',
'i',
'li',
'ul',
'ol',
'p',
'pre',
'span',
'strike',
'strong',
'table',
'tbody',
'td',
'tfoot',
'th',
'thead',
'tr',
];
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
theme: 'base',
startOnLoad: true,
logLevel: 0,
flowchart: {
useMaxWidth: false,
htmlLabels: true,
},
gantt: {
useMaxWidth: false,
},
architecture: {
iconSize: 80,
},
useMaxWidth: false,
iconLibraries: ['aws:full']
});
function callback() {
alert('It worked');
}
mermaid.parseError = function (err, hash) {
console.error('In parse error:');
console.error(err);
};
</script>
</body>

</html>
3 changes: 3 additions & 0 deletions demos/index.html
Expand Up @@ -88,6 +88,9 @@ <h2><a href="./packet.html">Packet</a></h2>
<li>
<h2><a href="./block.html">Layered Blocks</a></h2>
</li>
<li>
<h2><a href="./architecture.html">Architecture</a></h2>
</li>
</ul>
</body>
</html>
2 changes: 2 additions & 0 deletions packages/mermaid/package.json
Expand Up @@ -72,6 +72,7 @@
"@mermaid-js/parser": "workspace:^",
"cytoscape": "^3.28.1",
"cytoscape-cose-bilkent": "^4.1.0",
"cytoscape-fcose": "^2.2.0",
"d3": "^7.9.0",
"d3-sankey": "^0.12.3",
"dagre-d3-es": "7.0.10",
Expand All @@ -89,6 +90,7 @@
"devDependencies": {
"@adobe/jsonschema2md": "^8.0.0",
"@types/cytoscape": "^3.19.16",
"@types/cytoscape-fcose": "^2.2.4",
"@types/d3": "^7.4.3",
"@types/d3-sankey": "^0.12.4",
"@types/d3-scale": "^4.0.8",
Expand Down
1 change: 1 addition & 0 deletions packages/mermaid/scripts/create-types-from-json-schema.mts
Expand Up @@ -54,6 +54,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
'gitGraph',
'c4',
'sankey',
'architecture',
];

/**
Expand Down