Skip to content

Commit

Permalink
docs(diagrams): Add architecture diagram (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmichaelchen authored Nov 18, 2023
1 parent ae06ad9 commit 7b9097d
Show file tree
Hide file tree
Showing 7 changed files with 392 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[![Lines Of Code](https://aschey.tech/tokei/github/kevinmichaelchen/temporal-saga-grpc?category=code&style=for-the-badge)](https://github.com/kevinmichaelchen/temporal-saga-grpc)

<p align="center">
<a href="https://raw.githubusercontent.com/kevinmichaelchen/temporal-saga-grpc/main/docs/design.png">
<img width="400" src="./docs/design.png" />
</a>

![./docs/diagrams/architecture.svg](./docs/diagrams/architecture.svg)

</p>

This project demonstrates using
Expand All @@ -32,7 +32,7 @@ The upstream microservices that are called during the workflow all use gRPC.

### Step 1: Spin everything up

We use [pkgx][pkgx] to run Temporal's dev server. We use Docker to run
We use [pkgx][pkgx] to run Temporal's dev server. We use Docker to run
[Jaeger][jaeger] (a telemetry backend).

[pkgx]: https://pkgx.sh/
Expand Down
6 changes: 4 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: '3'
version: "3"

includes:
buf:
taskfile: ./taskfiles/buf.yml
docs:
taskfile: ./taskfiles/docs.yml
go:
taskfile: ./taskfiles/golang.yml
run:
Expand Down Expand Up @@ -36,4 +38,4 @@ tasks:
internal: true
desc: "Format Markdown"
cmds:
- "pkgx bunx prettier --write \"**/*.md\" --prose-wrap always"
- 'pkgx bunx prettier --write "**/*.md" --prose-wrap always'
Binary file removed docs/design.png
Binary file not shown.
73 changes: 73 additions & 0 deletions docs/diagrams/architecture.d2
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
direction: right

vars: {
icons: {
gopher: https://www.svgrepo.com/show/373635/go-gopher.svg
temporal: ./docs/diagrams/temporal.svg
}
}

client: Client

cloud: Cloud {
starter: Starter {
shape: image
icon: ${icons.gopher}
}

worker: Temporal Worker {
shape: image
icon: ${icons.gopher}
}

svc-license: License µService {
shape: image
icon: ${icons.gopher}
}

svc-profile: Profile µService {
shape: image
icon: ${icons.gopher}
}

svc-org: Org µService {
shape: image
icon: ${icons.gopher}
}

worker -> svc-license: Create License {
style: {
stroke: "#ada9a8"
stroke-dash: 3
}
}
worker -> svc-org: Create Org {
style: {
stroke: "#ada9a8"
stroke-dash: 3
}
}
worker -> svc-profile: Create Profile {
style: {
stroke: "#ada9a8"
stroke-dash: 3
}
}
}

temporal: Temporal Cloud {
cluster: Temporal Cluster {
shape: image
icon: ${icons.temporal}
}
}

client -> cloud.starter: Connect/gRPC {
style.animated: true
}
cloud.starter -> temporal.cluster: Start Temporal Workflow {
style.animated: true
}
temporal.cluster -> cloud.worker: Pick up job {
style.animated: true
}
209 changes: 209 additions & 0 deletions docs/diagrams/architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/diagrams/temporal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions taskfiles/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3"

vars:
# https://d2lang.com/tour/themes/
THEME: 105
DARK_THEME: 105

tasks:
compile:
desc: "Compiles D2 diagrams"
vars:
DIAGRAMS:
sh: find . -type f -name "*.d2"
cmds:
- for: { var: DIAGRAMS }
task: compile-one
vars: { ITEM: "{{ .ITEM }}" }

compile-one:
internal: true
label: compile-one-{{.ITEM}}
vars:
DIRNAME:
sh: dirname {{.ITEM}}
BASENAME:
sh: basename {{.ITEM}}
FILENAME:
sh: |
echo {{.BASENAME}} | rev | cut -d. -f2- | rev
cmds:
- pkgx d2 fmt {{.ITEM}}
- |
pkgx d2 \
--sketch \
--theme={{.THEME}} \
--dark-theme={{.DARK_THEME}} \
-l elk \
--pad 25 \
{{.ITEM}}
- echo ITEM={{.ITEM}}, DIRNAME={{.DIRNAME}}, BASENAME={{.BASENAME}}, FILENAME={{.FILENAME}}
sources:
- "{{.ITEM}}"
generates:
- "{{.DIRNAME}}/{{.FILENAME}}.svg"

0 comments on commit 7b9097d

Please sign in to comment.