diff --git a/README.md b/README.md index 8065093..78f3fa0 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ A Python monorepo managed as a [uv workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/). All members share one virtualenv and one `uv.lock`. +![Demo: services talking over HTTP and Redis, CI testing only affected members, and scaffolding a new service](docs/demo.gif) + +Real commands and output, replayed by [`docs/demo/player.html`](docs/demo/player.html). Also available as an [MP4](docs/demo.mp4). Regenerate with `node docs/demo/record.mjs`. + See **[ARCHITECTURE.md](ARCHITECTURE.md)** for diagrams of the layout, dependency graph, runtime flow, CI and deployment. diff --git a/docs/demo.gif b/docs/demo.gif new file mode 100644 index 0000000..d9ff3c5 Binary files /dev/null and b/docs/demo.gif differ diff --git a/docs/demo.mp4 b/docs/demo.mp4 new file mode 100644 index 0000000..d2d4fb1 Binary files /dev/null and b/docs/demo.mp4 differ diff --git a/docs/demo/player.html b/docs/demo/player.html new file mode 100644 index 0000000..75982ee --- /dev/null +++ b/docs/demo/player.html @@ -0,0 +1,302 @@ + + + + +python-monorepo demo + + + + + +
+
+ ~/python-monorepo +
+
catalog-api
+
HTTP
◀──
+
orders-api
+
event
──▶
+
Redis
+
event
──▶
+
notifier-worker
+
+
+
+
+
+
+
+ + + + diff --git a/docs/demo/record.mjs b/docs/demo/record.mjs new file mode 100644 index 0000000..f95ab56 --- /dev/null +++ b/docs/demo/record.mjs @@ -0,0 +1,44 @@ +// Render docs/demo/player.html to docs/demo.mp4 and docs/demo.gif. +// +// node docs/demo/record.mjs # needs playwright (Chromium) and ffmpeg +// +// Frames are rendered deterministically via window.seek(t), so the result does +// not depend on how fast the machine is. +import { execFileSync } from "node:child_process"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { createRequire } from "node:module"; + +const require = createRequire(import.meta.url); +const { chromium } = require("playwright"); + +const here = dirname(fileURLToPath(import.meta.url)); +const docs = dirname(here); +const FPS = 15; +const frames = mkdtempSync(join(tmpdir(), "demo-frames-")); + +const browser = await chromium.launch(); +const page = await browser.newPage({ viewport: { width: 960, height: 600 }, deviceScaleFactor: 2 }); +await page.goto(pathToFileURL(join(here, "player.html")).href + "?record"); +await page.evaluate(() => document.fonts.ready); +const duration = await page.evaluate(() => window.DURATION); +const total = Math.ceil(duration * FPS); +for (let i = 0; i < total; i++) { + await page.evaluate((t) => window.seek(t), i / FPS); + await page.screenshot({ path: join(frames, `f${String(i).padStart(5, "0")}.png`) }); +} +await browser.close(); +console.log(`rendered ${total} frames (${duration.toFixed(1)}s)`); + +const input = ["-y", "-loglevel", "error", "-framerate", String(FPS), "-i", join(frames, "f%05d.png")]; +execFileSync("ffmpeg", [...input, "-vf", "scale=1280:-2:flags=lanczos", "-c:v", "libx264", + "-pix_fmt", "yuv420p", "-crf", "23", "-preset", "slow", "-movflags", "+faststart", + join(docs, "demo.mp4")], { stdio: "inherit" }); +execFileSync("ffmpeg", [...input, "-vf", + "fps=10,scale=960:-1:flags=lanczos,split[a][b];[a]palettegen=max_colors=64:stats_mode=diff[p];" + + "[b][p]paletteuse=dither=none:diff_mode=rectangle", + join(docs, "demo.gif")], { stdio: "inherit" }); +rmSync(frames, { recursive: true, force: true }); +console.log("wrote docs/demo.mp4 and docs/demo.gif");