-
Notifications
You must be signed in to change notification settings - Fork 2
Architecture & Rendering Engine
github-actions[bot] edited this page Sep 11, 2026
·
3 revisions
This technical document details the internal pipeline and design architecture of gh-tree.
When the GitHub Action runs, it executes the following sequence:
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ Action Inputs โ โโ> โ GitHub GraphQL API โ โโ> โ Tree Layout & Math โ
โ (action.yml) โ โ (contributions, PRs) โ โ (src/tree.ts) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ Auto-Commit/Pushโ <โโ โ Rasterize & Encode โ <โโ โ SVG Pixel Art Engine โ
โ (src/main.ts) โ โ (resvg-wasm + gifenc) โ โ (src/svg.ts) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
- Reads inputs from
@actions/corewith default fallbacks. - Fetches contributions, commits, PR counts, and contributor status.
- Queries Open-Meteo for real-time weather data if
cityis configured. - Invokes
generateTreeSvg()for all animation frames (default 20 frames). - Passes SVG frames to
renderGif()and writes the output file (tree.gif). - Updates
README.mdmarkers viaupdateMarkdownFile(). - Commits and pushes changes with
gitusing@actions/coreor skips if clean.
-
GraphQL Calendar Query: Queries user
contributionsCollection(from, to)overdayshistory (default 140 days). -
PR Recency Windowing: Filters pull requests, reviews, and assignments within
prDays(default 14 days) to ensure active, fresh collectibles. - Active Streak Calculation: Computes consecutive active commit days up to today/yesterday.
-
Contributor Verification: Calls the REST
/repos/nivinvysakh/gh-tree/contributorsendpoint to verify if the runner is an official contributor and unlock the Lapis Lazuli Ore ๐ท.
-
Branch Tiering: Buckets the 14 contribution weeks into a 4-tier canopy structure:
- Tier -3 (Peak block: 1 block)
- Tier -2 (Upper canopy: 3 blocks)
- Tier -1 (Mid canopy: 5 blocks)
- Tier 0 (Lower canopy: 5 blocks)
- Leaf Intensity Leveling: Computes commit density levels (Level 0 dormant to Level 4 power sprint).
-
Collision-Free Slot Allocator:
- Ground plane is anchored at
groundY = 370. - Distributes items across
leftSlots: [112, 144, 176]andrightSlots: [258, 296, 336, 374]. - Ensures companion pets, campfires, chests, signposts, and flowers never visually overlap.
- Ground plane is anchored at
The rendering architecture uses pure SVG <rect> elements with shape-rendering="crispEdges" for razor-sharp retro pixel art:
-
src/palettes.ts: Static 16x16 pixel index maps, 10 biome foliage & bark color tokens, ground terrain profiles (BIOME_TERRAINS), mineral palettes, and font glyphs. -
src/environment.ts: Celestial bodies (Minecraft Sun, Moon with craters, twinkling stars, clouds), weather precipitation (rain, snowflakes, sakura petals), and atmospheric particles (Nether spores, fireflies, fireworks). -
src/props.ts: Ground terrain layers with jagged hanging grass fringes, trunk logs, 14 canopy leaves with commit-level shading, milestone chests, stat signposts, creature companions (wolf, fox, cat, parrot), and seasonal decorations. -
src/svg.ts: Top-level frame compositor assembling layers into standard responsive<svg>frames.
- Rasterizes SVG strings into raw RGBA pixel buffers in memory using
@resvg/resvg-wasm(Rust-based SVG renderer compiled to WebAssembly). - Quantizes pixel palettes and writes looping animated GIF89a streams using
gifenc. - Memory efficient with zero dependency on heavy headless browsers or system binaries like
imagemagickorffmpeg.
- Integrates with Open-Meteo REST API.
- Geocodes city names to coordinates (latitude / longitude).
- Evaluates weather codes (WMO code), solar zenith angle (day vs. night), precipitation, and snowfall to compute atmospheric state.
- Searches for comment tags:
<!-- commit-tree-start --> ... <!-- commit-tree-end -->
- Replaces the content inside with the cache-busted animated GIF tag:
<!-- commit-tree-start -->  <!-- commit-tree-end -->
gh-tree is created and maintained by @nivinvysakh and amazing open-source contributors! ๐
Contribute code or documentation to unlock the exclusive Lapis Lazuli Ore ๐ท!