TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/invvd/mtg-cheaper-deck/llms.txt
Use this file to discover all available pages before exploring further.
card_images module generates a self-contained HTML page that displays an original card next to its cheaper suggested replacements, then opens it in the system’s default browser. No images are downloaded or stored locally — each <img> tag points directly to a Scryfall endpoint that redirects to the actual card scan. The page is written to ./data/compare.html by default and is regenerated on every invocation.
Constants
IMAGE_URL_TMPL is the URL pattern used to fetch card images. Scryfall redirects requests to this endpoint to the actual image hosted on their CDN. The version=normal parameter requests the standard-resolution scan (approximately 488 × 680 pixels), which is the right size for side-by-side display. No API key is required.
COMPARE_HTML_PATH is the default path where open_comparison() writes the generated HTML file. The data/ directory is created automatically if it does not exist.
card_image_url
Returns the Scryfall image URL for a card dict.A card dict containing at minimum a
scryfall_id key. Typically a row from the local cards table or a dict from the suggestions list.str | None — the fully-formed Scryfall image URL if scryfall_id is present and non-empty, or None if the field is missing or falsy. Callers rendering HTML should handle the None case with a placeholder element.
build_comparison_html
Generates a standalone HTML page showing the original card and each suggestion in a horizontal row with price and savings captions.The local database row dict for the card being replaced. Must have
name, scryfall_id, and price_usd fields. Used to render the left-hand card block and to calculate the savings percentage for each suggestion caption.A list of suggestion dicts as returned by
suggest_alternatives(). Each dict must have a "card" key (the candidate row dict with name, scryfall_id, and price_usd) and a "score" key (the numeric similarity score).str — a complete, self-contained HTML document as a string. The page uses an inline <style> block (dark background, flex layout) and no external dependencies, so it renders correctly even without internet access — though the card images themselves require a live connection to Scryfall’s CDN.
Each suggestion caption shows the candidate’s name, USD price, percentage savings over the original, and the similarity score. An arrow (→) separates the original block from the suggestion blocks.
open_comparison
Writes the comparison HTML to disk and opens it in the system’s default web browser.The local database row dict for the card being replaced. Forwarded to
build_comparison_html().List of suggestion dicts from
suggest_alternatives(). Forwarded to build_comparison_html().File path where the HTML should be written. The parent directory is created automatically with
mkdir(parents=True, exist_ok=True). The file is overwritten on each call.None. After writing the file, calls webbrowser.open() with the resolved file:// URI. This opens the default browser on macOS, Windows, and most Linux desktops. In headless environments the call silently does nothing.
This function is triggered interactively when the user presses i in the terminal pipeline to inspect a specific card replacement.