Skip to content

Commit b229ca7

Browse files
committed
feat: add D2 theme support and update documentation with architecture diagrams
- Introduced 'astro-d2' package and integrated D2 theme overrides for light and dark modes - Updated documentation to include detailed D2 architecture and task lifecycle diagrams - Modified package.json to include 'astro-d2' dependency - Enhanced Astro configuration with new theme settings and diagrams for better clarity
1 parent 25d2ca7 commit b229ca7

File tree

7 files changed

+127
-2
lines changed

7 files changed

+127
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Setup D2'
2+
description: 'Install D2 diagramming tool with retry logic'
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- name: Install D2
8+
shell: bash
9+
run: |
10+
for i in 1 2 3 4 5; do
11+
echo "Attempt $i to install D2..."
12+
if curl -fsSL https://d2lang.com/install.sh | sh -s --; then
13+
echo "D2 installed successfully"
14+
break
15+
else
16+
if [ $i -eq 5 ]; then
17+
echo "Failed to install D2 after 5 attempts"
18+
exit 1
19+
fi
20+
echo "Install failed, retrying in 5 seconds..."
21+
sleep 5
22+
fi
23+
done

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
- name: Set Nx SHAs for affected commands
4545
uses: nrwl/nx-set-shas@v4
4646

47+
- uses: ./.github/actions/setup-d2
48+
4749
- name: Quality gate (lint + typecheck + test)
4850
run: pnpm nx affected -t lint typecheck test --parallel --configuration=production
4951

@@ -112,7 +114,9 @@ jobs:
112114

113115
- name: Set Nx SHAs for affected commands
114116
uses: nrwl/nx-set-shas@v4
115-
117+
118+
- uses: ./.github/actions/setup-d2
119+
116120
- name: Check if website is affected
117121
id: check-affected
118122
run: |

pkgs/website/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ pnpm-debug.log*
1919

2020
# macOS-specific files
2121
.DS_Store
22+
23+
# generated files
2224
public/edge-worker/
25+
public/d2/

pkgs/website/astro.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import starlightLinksValidator from 'starlight-links-validator';
66
import starlightSidebarTopics from 'starlight-sidebar-topics';
77
import robotsTxt from 'astro-robots-txt';
88
import starlightLlmsTxt from 'starlight-llms-txt';
9+
import d2 from 'astro-d2';
910
import { fileURLToPath } from 'url';
1011
import path from 'path';
1112

@@ -83,6 +84,7 @@ export default defineConfig({
8384
},
8485

8586
integrations: [
87+
d2(),
8688
react({
8789
include: ['**/components/**/*.tsx'],
8890
exclude: ['**/pages/**/*'],

pkgs/website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@types/react-dom": "^19.1.7",
2828
"@vercel/analytics": "^1.5.0",
2929
"astro": "^5.7.14",
30+
"astro-d2": "^0.8.0",
3031
"astro-robots-txt": "^1.0.0",
3132
"react": "^19.1.1",
3233
"react-dom": "^19.1.1",

pkgs/website/src/content/docs/concepts/how-pgflow-works.mdx

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,41 @@ pgflow follows four core design principles:
2727

2828
## 1. Three thin layers
2929

30-
<img src="/diagrams/three-layers.svg" alt="Three layers of pgflow architecture: TypeScript DSL, SQL Core, and Worker" width="90%" />
30+
```d2
31+
direction: down
32+
33+
Build-time: {
34+
dsl: "TypeScript DSL" {
35+
shape: document
36+
}
37+
38+
sql: "SQL migration" {
39+
shape: stored_data
40+
}
41+
42+
dsl -> sql: "npx pgflow compile"
43+
}
44+
45+
Runtime Postgres: {
46+
label: "Run-time (inside Postgres)"
47+
48+
core: "SQL Core" {
49+
shape: diamond
50+
}
51+
}
52+
53+
Runtime Worker: {
54+
label: "Run-time (outside Postgres)"
55+
56+
worker: "Edge Worker" {
57+
shape: cloud
58+
}
59+
}
60+
61+
# Connections
62+
Build-time.sql -> Runtime Postgres.core
63+
Runtime Worker.worker -> Runtime Postgres.core: "poll for work &\nreport results"
64+
```
3165

3266
Layer cheat-sheet:
3367

@@ -84,6 +118,49 @@ Steps execute via **tasks** - units of function execution. For regular steps, th
84118

85119
Behind the scenes, when a step becomes ready, workers handle the execution through a simple 3-call sequence:
86120

121+
```d2
122+
direction: down
123+
124+
Step Lifecycle: {
125+
step: "Step: created → started → completed" {
126+
shape: hexagon
127+
}
128+
}
129+
130+
Task Execution: {
131+
label: "Task Execution (inside Postgres)"
132+
133+
queue: "pgmq Queue" {
134+
shape: cylinder
135+
}
136+
137+
core: "SQL Core" {
138+
shape: diamond
139+
}
140+
141+
tasks: "step_tasks table" {
142+
shape: sql_table
143+
}
144+
}
145+
146+
Worker Process: {
147+
worker: "Edge Worker" {
148+
shape: cloud
149+
}
150+
}
151+
152+
# Connections
153+
Step Lifecycle.step -> Task Execution.tasks: creates
154+
Step Lifecycle.step -> Task Execution.queue: enqueues
155+
156+
Worker Process.worker -> Task Execution.queue: "1. read_with_poll"
157+
Worker Process.worker -> Task Execution.core: "2. start_tasks"
158+
Worker Process.worker -> Task Execution.core: "3. complete_task/fail_task"
159+
160+
Task Execution.core -> Task Execution.tasks: updates
161+
Task Execution.core -> Step Lifecycle.step: advances
162+
```
163+
87164
1. `read_with_poll` → locks queue messages
88165
2. `start_tasks` → marks task started, builds input
89166
3. `complete_task/fail_task` → finishes task, moves step forward

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)