-
Notifications
You must be signed in to change notification settings - Fork 40
/
web_basics.d2
executable file
·399 lines (374 loc) · 10.7 KB
/
web_basics.d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
#!/usr/bin/env d2
#
# vim:ts=2:sts=2:sw=2:et:filetype=d2
#
# Author: Hari Sekhon
# Date: 2023-05-13 22:57:12 +0100 (Sat, 13 May 2023)
#
# https://github.com/HariSekhon/Diagrams-as-Code
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
# ============================================================================ #
# W e b B a s i c s
# ============================================================================ #
direction: down
# this is just a regular object
title: {
label: Web Basics
near: top-center
shape: text
style.font-size: 40
style.underline: true
}
classes: {
dns: {
label: DNS
# icon: https://icons.terrastruct.com/azure%2FNetworking%20Service%20Color%2FDNS%20Zones.svg
icon: https://diagrams.mingrammer.com/img/resources/azure/network/dns-zones.png
shape: image
}
nginx: {
label: Nginx\nweb server
# icon: https://icons.terrastruct.com/dev%2Fnginx.svg
icon: https://diagrams.mingrammer.com/img/resources/onprem/network/nginx.png
shape: image
}
aws: {
label: AWS
icon: https://icons.terrastruct.com/dev%2Famazonwebservices.svg
# icon: https://icons.terrastruct.com/aws%2F_Group%20Icons%2FAWS-Cloud-alt_light-bg.svg
shape: image
}
gcp: {
label: GCP
icon: https://cdn-icons-png.flaticon.com/512/873/873117.png
# icon: https://lirp.cdn-website.com/aa0ef369/dms3rep/multi/opt/google-cloud-icon-400w.png
shape: image
}
azure: {
label: Azure
icon: https://cdn-icons-png.flaticon.com/512/873/873107.png
icon: https://www.smartdesc.co.uk/wp-content/uploads/2022/10/Azure-Square-3.png
shape: image
}
commandline: {
label: Command Line
icon: https://icons.terrastruct.com/aws%2FDeveloper%20Tools%2FAWS-Command-Line-Interface.svg
shape: image
}
apache: {
label: Apache\nweb server
icon: https://www.svgrepo.com/show/353400/apache.svg
# icon: https://icons.terrastruct.com/dev%2Fapache.svg
# icon: https://diagrams.mingrammer.com/img/resources/onprem/network/apache.png
shape: image
}
linux: {
label: Linux
icon: https://icons.terrastruct.com/dev%2Flinux.svg
# icon: https://diagrams.mingrammer.com/img/resources/generic/os/linux-general.png
shape: image
}
mac: {
label: macOS / iOS
icon: https://icons.terrastruct.com/dev%2Fapple.svg
# icon: https://diagrams.mingrammer.com/img/resources/generic/os/ios.png
shape: image
}
android: {
label: Android
icon: https://icons.terrastruct.com/dev%2Fandroid.svg
shape: image
}
debian: {
label: Debian
icon: https://diagrams.mingrammer.com/img/resources/generic/os/debian.png
shape: image
}
redhat: {
label: Redhat
icon: https://icons.terrastruct.com/dev%2Fredhat.svg
# icon: https://diagrams.mingrammer.com/img/resources/generic/os/red-hat.png
shape: image
}
suse: {
label: Suse
icon: https://diagrams.mingrammer.com/img/resources/generic/os/suse.png
shape: image
}
ubuntu: {
label: Ubuntu
icon: https://diagrams.mingrammer.com/img/resources/generic/os/ubuntu.png
shape: image
}
windows: {
label: Windows
icon: https://icons.terrastruct.com/dev%2Fwindows.svg
# icon: https://diagrams.mingrammer.com/img/resources/generic/os/windows.png
shape: image
}
browser: {
label: Web Browser
icon: https://icons.terrastruct.com/tech%2Fbrowser-2.svg
shape: image
}
chrome: {
label: Chrome
icon: https://icons.terrastruct.com/dev%2Fchrome.svg
shape: image
}
firefox: {
label: Firefox
icon: https://icons.terrastruct.com/dev%2Ffirefox.svg
shape: image
}
safari: {
label: Safari
icon: https://icons.terrastruct.com/dev%2Fsafari.svg
shape: image
}
laptop: {
label: Laptop
icon: https://icons.terrastruct.com/tech%2Flaptop.svg
shape: image
}
desktop: {
label: Desktop
icon: https://icons.terrastruct.com/tech%2Fdesktop.svg
shape: image
}
tablet: {
label: Tablet
icon: https://icons.terrastruct.com/tech%2F079-tablet-1.svg
shape: image
}
phone: {
label: Smart Phone
icon: https://icons.terrastruct.com/tech%2F052-smartphone-3.svg
shape: image
}
server: {
label: Server
icon: https://icons.terrastruct.com/tech%2F022-server.svg
# icon: https://icons.terrastruct.com/essentials%2F112-server.svg
shape: image
}
firewall: {
label: Firewall
icon: https://icons.terrastruct.com/infra%2F003-firewall.svg
# icon: https://diagrams.mingrammer.com/img/resources/generic/network/firewall.png
shape: image
}
router: {
label: Router
icon: https://diagrams.mingrammer.com/img/resources/generic/network/router.png
shape: image
}
network: {
label: Local Network
icon: https://diagrams.mingrammer.com/img/resources/generic/network/subnet.png
shape: image
}
datacenter: {
label: Datacenter
icon: https://diagrams.mingrammer.com/img/resources/generic/place/datacenter.png
shape: image
}
internet: {
label: Internet
icon: https://icons.terrastruct.com/infra%2F022-hosting.svg
shape: image
}
invisible: {
style.opacity: 0
}
traffic: {
label: traffic
style.animated: true
style.stroke-dash: 5
}
http_request: {
label: HTTP GET /
style.animated: true
style.stroke-dash: 5
}
http_response: {
label: <html>...
style.animated: true
style.stroke-dash: 5
}
dns_request: {
label: DNS query\nwhere is www.domain.com\n(record type "A" query)
style.animated: true
style.stroke-dash: 5
}
dns_response: {
label: DNS reply\nwww.domain.com is at IP address 1.2.3.4
style.animated: true
style.stroke-dash: 5
}
}
platform: Cloud Platform or Datacenter {
aws.class: aws
gcp.class: gcp
azure.class: azure
# datacenter.class: datacenter
# datacenter -> server
server.class: server
aws -> webserver
gcp -> webserver
azure -> webserver
server -> webserver
webserver: Web Servers {
apache.class: apache
nginx.class: nginx
apache -> website
nginx -> website
website: {
label: www.domain.com\n1.2.3.4
class: internet
}
}
dns.class: dns
}
# platform -> internet: { class: traffic }
# platform <- internet: { class: traffic }
#
# internet.class: internet
# internet <- network.router: { class: traffic }
# internet -> network.router: { class: traffic }
# #internet <- network.router: { class: dns_request }
# #internet -> network.router: { class: dns_response }
# #internet <- network.router: { class: http_request }
# #internet -> network.router: { class: http_response }
#
# network: Local Network {
# router.class: router
# lan.class: network
# lan.label: Local Area Network (LAN)
# lan -> router: {
# label: forward to 1.2.3.4
# class: traffic
# }
# lan <- router: {
# label: return traffic from 1.2.3.4
# class: traffic
# }
# }
computer: Computer {
# software -> _.platform.dns: {class: dns_request}
# software <- _.platform.dns: {class: dns_response}
software.os -> _.platform.dns: {class: dns_request}
software.os <- _.platform.dns: {class: dns_response}
# os -> _.network.lan: { class: traffic }
# os <- _.network.lan: { class: traffic }
software: Software {
browsers: Web Browsers {
browser.class: browser
chrome.class: chrome
firefox.class: firefox
safari.class: safari
}
browsers -> _._.platform.webserver.website: {class: http_request}
browsers <- _._.platform.webserver.website: {class: http_response}
# browsers -> _._.network.lan: { class: http_request }
# browsers <- _._.network.lan: { class: http_response }
cli: Command Line {
cli.class: commandline
# host -> _._._.platform.dns: { class: dns_request }
# host <- _._._.platform.dns: { class: dns_response }
curl: |sh
curl wwww.domain.com
<html>...
|
curl -> _._._.platform.webserver.website: {class: http_request}
curl <- _._._.platform.webserver.website: {class: http_response}
# curl -> _._._.network.lan: { class: http_request }
# curl <- _._._.network.lan: { class: http_response }
# curl -> host: {class: invisible}
# host -> cli: {class: invisible}
host: |sh
host www.domain.com
www.domain.com has address 1.2.3.4
|
# host -> nslookup: {class: invisible}
# nslookup: |sh
# nslookup www.domain.com
#
# Server: 10.255.252.1
# Address: 10.255.252.1#53
#
# Non-authoritative answer:
# Name: www.domain.com
# Address: 172.217.169.4
# |
# dig: |sh
# dig www.domain.com
#
# ; <<>> DiG 9.10.6 <<>> www.domain.com
# ;; global options: +cmd
# ;; Got answer:
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59483
# ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
#
# ;; OPT PSEUDOSECTION:
# ; EDNS: version: 0, flags: do; udp: 512
# ;; QUESTION SECTION:
# ;www.domain.com. IN A
#
# ;; ANSWER SECTION:
# www.domain.com. 211 IN A 172.217.169.4
#
# ;; Query time: 7 msec
# ;; SERVER: 10.255.252.1#53(10.255.252.1)
# ;; WHEN: Sun May 14 16:50:39 BST 2023
# ;; MSG SIZE rcvd: 73
# |
}
# cli -> os #: {class: invisible}
# browsers -> os #: {class: invisible}
# cli -> blank #: {class: invisible}
# browsers -> blank #: {class: invisible}
# blank -> os
os: Operating Systems {
windows.class: windows
mac.class: mac
android.class: android
linux: Linux {
linux.class: linux
# linux -- distros
distros: Distros {
ubuntu.class: ubuntu
debian.class: debian
redhat.class: redhat
suse.class: suse
# ubuntu -- debian -- redhat -- suse: {class: invisible}
}
}
# windows -- mac -- linux
# windows -> blank: {class: invisible}
# mac -> blank: {class: invisible}
# linux -> blank: {class: invisible}
# blank.class: invisible
}
}
software.os -> phone: {class: invisible}
software.os -> tablet: {class: invisible}
software.os -> laptop: {class: invisible}
software.os -> desktop: {class: invisible}
phone.class: phone
tablet.class: tablet
laptop.class: laptop
desktop.class: desktop
# laptop -> blank: {class: invisible}
# desktop -> blank: {class: invisible}
#
# blank: {class: invisible}
# desktop -> blank: {class: invisible}
# laptop -> blank: {class: invisible}
}