Skip to content
← Back to work

MTG Card Recommendation Engine

AI-powered Commander deck analysis — paste a decklist or Archidekt URL and get suggestions for cuts, additions, and mana base improvements.

RAGGemini APIScryfallNext.jsUpstash

The Problem

Magic: The Gathering has over 27,000 unique cards. Building a Commander deck means navigating a vast combinatorial space. Existing tools offer keyword-based search (misses emergent synergies) or community-curated lists (static, biased toward popular strategies). I wanted AI that could reason about card interactions and give actionable deck improvement advice.

Approach

Built a decklist analysis pipeline: users paste a decklist or Archidekt URL, cards are resolved against the Scryfall API, then the full deck context is sent to Gemini for structured analysis. The AI returns categorised recommendations (cuts, additions, mana base fixes) with reasoning for each suggestion. NZ pricing data is scraped from MTGSingles for local players.

Architecture

Next.js 16 App Router with API routes for card resolution, recommendation generation, and NZ price lookups. Scryfall bulk data for card resolution. Gemini API for structured deck analysis. Upstash Redis for rate limiting. Deployed as an independent Vercel project and served through the portfolio shell via Multi-Zone rewrites — a micro-frontend architecture pattern.

Results

The demo handles real Commander decklists, resolves cards with artwork from Scryfall, and generates detailed recommendations in under 10 seconds. Rate limited to prevent abuse. Running cost: ~$3-5/month with moderate traffic.

Lessons Learned

Structured output schemas (Zod validation on AI responses) dramatically improve reliability over free-form generation. Scryfall's API is excellent but needs client-side rate limiting to respect their guidelines. Multi-Zone rewrites on Vercel make micro-frontend composition trivially simple compared to Module Federation.

Want to see it in action?

Launch Demo →