Wiki/Technology

Technology & Credits

Technology Stack

MTG Codex is a full-stack web application with several moving parts. Here's a complete breakdown of what's running under the hood.

Hosting & Infrastructure

The API runs on DigitalOcean App Platform in a Docker container, connected to a managed PostgreSQL cluster on the same platform. The ingest worker — which pulls Scryfall bulk data and updates prices nightly — runs on a separate DigitalOcean Droplet. The frontend is deployed on Vercel, which handles CDN distribution, Edge caching, and automatic deploys from the GitHub main branch. TLS certificates are managed via Let's Encrypt.

Languages & Frameworks

The backend is Python 3.10 running FastAPI with Uvicorn as the ASGI server. The frontend is Next.js 14 (App Router) with TypeScript and React 18. Styling is done with Tailwind CSS.

Databases & Search

PostgreSQL is the primary database, accessed via psycopg 3 with a synchronous connection pool. User accounts, collections, decks, binders, messages, notifications — everything relational lives here.

Elasticsearch 9 powers the card search, pricing index, and faceted filtering. It's what makes searching 110,000+ cards feel instant, and what makes the multi-dimensional filters (color + type + rarity + set + oracle text) work together efficiently.

APIs & Third-Party Services

ServiceWhat It Does
**Google Gemini**AI card recognition (Gemini 2.0 Flash Vision) — runs every time you tap the scanner
**Scryfall**Card data, images, and bulk pricing. The nightly ingest job pulls their full dataset
**SendGrid**Transactional email for verification messages and password resets

Key Libraries

On the Python side: PyJWT and bcrypt for authentication, Pydantic for validation, WebSockets for the real-time phone-to-desktop connection, Pillow for image preprocessing before it goes to Gemini, Tesseract OCR as a fallback identifier, HTTPX for async HTTP, and ijson for streaming the Scryfall bulk JSON without loading the whole thing into memory.

On the JavaScript side: Axios for API calls, Lucide React for icons, Radix UI for accessible headless components, date-fns for date formatting, and qrcode.react for generating the scan session QR codes.

---

Legal & Attributions

Magic: The Gathering

MTG Codex is unofficial Fan Content permitted under the Wizards of the Coast Fan Content Policy. It is not approved or endorsed by Wizards of the Coast.

Magic: The Gathering, card names, card images, mana symbols, set symbols, and all associated trademarks are the property of Wizards of the Coast LLC, a subsidiary of Hasbro, Inc. Card images are sourced from Scryfall and are the copyrighted property of their respective rights holders. They are used here for identification and reference purposes only. MTG Codex does not claim ownership of any Magic: The Gathering card images, artwork, or related content.

Scryfall

Card data and pricing are provided by Scryfall (scryfall.com). Scryfall is not affiliated with or endorsed by Wizards of the Coast. Card images from Scryfall are used in accordance with their stated usage guidelines.

Open Source

MTG Codex is built on the shoulders of a lot of excellent open-source work. Sincere thanks to the maintainers and contributors of FastAPI, Next.js, React, Tailwind CSS, Elasticsearch, PostgreSQL, psycopg, Pydantic, Lucide, and every other library listed above.

Disclaimer

MTG Codex is a personal fan project, provided as-is without warranty. Card prices are sourced from Scryfall and are estimates — they may not reflect actual current market values. MTG Codex is not a marketplace and does not facilitate buying, selling, or trading of cards.