Skip to content

Commit e4d77c6

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 1d05039 commit e4d77c6

File tree

7 files changed

+162
-2
lines changed

7 files changed

+162
-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: 37 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

@@ -80,6 +81,42 @@ export default defineConfig({
8081
},
8182

8283
integrations: [
84+
d2({
85+
themeId: 0, // neutral theme as base
86+
themeOverrides: {
87+
// pgflow brand colors for light theme
88+
B1: "#007b6e", // accent
89+
B2: "#a3d4cb", // accent-high
90+
B3: "#bce0d9", // accent-low
91+
B4: "#e7f0ee", // gray-1
92+
B5: "#c2cdca", // gray-2
93+
B6: "#92a8a3", // gray-3
94+
95+
AA2: "#003b34", // accent-high (dark)
96+
AA4: "#00574d", // accent (dark)
97+
AA5: "#495d59", // gray-4
98+
99+
AB4: "#2a3d39", // gray-5
100+
AB5: "#182b28", // gray-6
101+
},
102+
darkThemeId: 0,
103+
darkThemeOverrides: {
104+
// pgflow brand colors for dark theme
105+
B1: "#007b6e", // accent
106+
B2: "#a3d4cb", // accent-high
107+
B3: "#002b26", // accent-low
108+
B4: "#2a3d39", // gray-5
109+
B5: "#495d59", // gray-4
110+
B6: "#92a8a3", // gray-3
111+
112+
AA2: "#a3d4cb", // accent-high
113+
AA4: "#007b6e", // accent
114+
AA5: "#c2cdca", // gray-2
115+
116+
AB4: "#e7f0ee", // gray-1
117+
AB5: "#ffffff", // white
118+
},
119+
}),
83120
react({
84121
include: ['**/components/**/*.tsx'],
85122
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

@@ -80,6 +114,49 @@ created → started → completed
80114

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

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