Add your own algorithm.
Every poster in the catalog is a self-contained plugin: a title, a tagline, a pseudocode snippet, and a function that draws an SVG diagram. The plugins live in the public algo-art-frames-public repo, so adding one takes a single pull request there.
The contract
Every algorithm module exposes one module-level PLUGIN, an instance of AlgorithmPlugin (src/algo_art_frames/algorithms/base.py):
@dataclass(frozen=True)
class AlgorithmPlugin:
slug: str # kebab-case, e.g. "binary-search"
title: str # e.g. "Binary Search"
tagline: str # one line, e.g. "Halve the search space every step."
category: AlgorithmCategory # pick one, don't invent a new string
pseudocode: list[str]
draw: Callable[[RenderContext], str]
accent: str # signature hex color, e.g. "#FF8A3D"
author: str | None = None # optional, shown bottom-right when enabled
date: str | None = None # optional, e.g. "2026-08-26"category must be one of AlgorithmCategory (also in base.py), so the catalog's categories can't fragment into near-duplicates ("ml" vs "machine-learning") as more algorithms get added. Need one that doesn't fit? Add a new member to the enum in the same PR rather than falling back to a raw string.
class AlgorithmCategory(str, Enum):
SEARCH = "search"
SORTING = "sorting"
GRAPH = "graph"
GAME_THEORY = "game-theory"
CRYPTOGRAPHY = "cryptography"
COMPRESSION = "compression"
STREAMING = "streaming"
RANDOMNESS = "randomness"
OPTIMIZATION = "optimization"
MACHINE_LEARNING = "machine-learning"
SIGNAL_PROCESSING = "signal-processing"
LINEAR_ALGEBRA = "linear-algebra"
GRAPHICS = "graphics"
STRINGS = "strings"draw(ctx) gets a render context (theme + canvas size) and returns raw SVG markup. The shared new_canvas() helper lays out the title/tagline/pseudocode and hands back a content box to draw into:
# Defined once, used both on the poster and in PLUGIN
TITLE = "Binary Search"
TAGLINE = "Halve the search space every step."
def draw(ctx: RenderContext) -> str:
dwg, box = new_canvas(
ctx,
title=TITLE,
tagline=TAGLINE,
pseudocode=PSEUDOCODE,
)
# ... draw into `box` using dwg.rect / dwg.text / dwg.line ...
return dwg.tostring()Steps
Clone and set up
Clone algo-art-frames-public and install it with the dev tools. It needs nothing but Python 3.12, and it's all you need to explore the existing posters too.
git clone https://github.com/arukavina/algo-art-frames-public
cd algo-art-frames-public
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
pip install -e ".[dev]"Copy the template
Copy the template to a new snake_case file named after your slug, e.g. dijkstra.py for the slug dijkstra.
cp src/algo_art_frames/algorithms/_template.py src/algo_art_frames/algorithms/dijkstra.pyDraw your diagram
Set TITLE and TAGLINE once, fill in PSEUDOCODE and draw(ctx). new_canvas() lays out the title, tagline and pseudocode; draw into the box it returns with ctx.theme colors so it works in both dark and light.
Register it
Import your module in src/algo_art_frames/algorithms/__init__.py and add it to the _MODULES tuple, then add your slug to EXPECTED_SLUGS in tests/test_algorithms.py.
Preview every variation
Render your poster in both themes with every display option: frame, pseudocode, tagline and author, on and off. Open the SVGs in any browser.
python -m algo_art_frames.preview dijkstra --variationsCheck and open a PR
Run the checks, then fork the repo (only maintainers can push to it), push your branch to your fork and open a pull request. CI runs the checks again and renders previews of every poster. Once a maintainer approves and merges it, your poster goes live here within a day.
pytest
ruff check .
gh repo fork --remote # your fork becomes origin
git checkout -b my-poster
git add -A && git commit -m "feat: add dijkstra poster"
git push -u origin my-poster
gh pr createWhat CI checks
Merged posters go live automatically, so every PR runs the same contract tests you ran locally. A plugin:
- Imports only algo_art_frames and a short list of standard-library modules
- No eval, exec, open, __import__ or similar built-ins
- Renders in under 2 seconds and under 1 MB of SVG, in both themes
- Draws the same title and tagline it lists in PLUGIN
- Changes visibly when each display option is switched
- Never renames or removes an existing slug
Full reference
The complete write-up, the template file and the tests live in the public algorithm repo.