projects / crucible
Crucible
Design a system, then break it. A Go simulation engine compiled to ~200 KB of TinyGo WASM drives a SvelteKit canvas, with no server at all.
- ~200 KB Go engine as TinyGo WASM sim.wasm build
- 23 Component kinds Component catalog
- 1 to 1M Requests per second Traffic slider range
- 13 Starter templates Template library
Overview
Problem
System design is usually argued on a whiteboard, where nothing ever falls over.
Approach
A Go engine runs as TinyGo WASM in a Web Worker under a SvelteKit 2 and Svelte 5 canvas. Drag components on, wire them up and drive traffic from 1 to 1M requests per second.
Result
Architectures actually run: live p50 and p99 latency, throughput, queue depth and error rate per node, chaos on demand, and seeded runs that replay byte for byte.
Share-replay is the first feature, not the last one bolted on.
On determinism
Decisions · why this stack
-
Two clocks, two ceilings
An event-driven sim clock on a min-heap never spins on idle ticks. A fixed ~33 ms render clock gives each step a 12 ms wall budget and an event cap, covering runaway producers and runaway sim time.
-
Deterministic by construction
A PCG32 RNG seeded once, a heap ordered by (time, seq) and an integer nanosecond clock. The same seed and topology give an identical run, so a shared link replays exactly.
-
One small Node interface
Six engine archetypes sit behind OnRequest, OnEvent, SetFaulted and Snapshot. The catalog maps 23 UI kinds onto them, so a CDN or a WAF is a palette entry, not an engine type.
-
TinyGo over standard Go
About 10x smaller WASM (~200 KB) from reflect-free code paths, with a standard Go build kept as the fallback.
-
No server at all
ssr = false, adapter-static and a CDN-only deploy on Vercel. The sim runs in the visitor's browser, so there is no per-user cost and nothing to keep awake.
Stack
- Go
- TinyGo
- WebAssembly
- Web Workers
- SvelteKit 2
- Svelte 5
- TypeScript
- Tailwind
- @xyflow/svelte
- Vercel
Architecture
- SvelteKit canvas @xyflow/svelte, 23 component kinds
- WASM bridge 7 functions, one JSON serialisation
- Web Worker 12 ms wall budget per tick
- Go engine TinyGo WASM, ~200 KB
- Min-heap scheduler Event-driven sim clock, PCG32 seed
Demo
Screens
Numbers
By the numbers
- 12 ms Wall budget per tick Engine source
- ~33 ms Render cadence Engine source
- 6 Engine archetypes Engine source
- 7 WASM bridge functions Engine source
- 512 Latency samples per node Engine source
- 9 Topology lint rules Inspector
- 6 Scripted chaos drills Template library
- ~10x Smaller than a standard Go build sim.wasm build