About this project

Deck Lab is a Python/Flask web application for building, researching and testing competitive Commander (Magic: The Gathering) decks in a single workspace. Users can edit decks, research the competitive metagame, inspect card information, and run goldfish simulations; saved decks, accounts and preferences persist across sessions. The hosted instance requires an owner-provisioned account. Key capabilities described in the README: - Deck editing and research workflow: public research results are served from a persisted snapshot with revision tracking, background refresh and bounded stale serving; filters and browser history update without full page rebuilds. - Deterministic domain logic: Commander legality, color identity, partner combinations and deck size are validated in code; the strategy-pack builder selects cards deterministically, with model output confined to a separate validated boundary for explanations. - Explicit data contracts: PostgreSQL research is exposed through versioned `mtg_v1` views with a read-only consumer, and a separate simulator exchanges versioned JSON validated against a packaged schema. Missing evidence and unavailable simulations are surfaced as visible states rather than invented results. - Security: Argon2 password hashes, CSRF protection, account provisioning, password recovery and authorization checks; production and QA use separate credentials, data and container networks. - Reproducible releases: GitHub Actions gates tests, lint, formatting, types and container smoke checks; deployment verifies image revision, archive hash, platform and layers; encrypted backups and isolated restore checks support recovery. Architecture: a Flask + Waitress web app backed by SQLite for accounts, decks and the research snapshot; a background refresh pulls from PostgreSQL `mtg_v1` views; the app can call a private simulator over versioned JSON and an optional model gateway. Deployment uses Caddy for HTTPS and Docker Compose on DigitalOcean, with database and simulator ports kept private; QA is available at a separate subdomain for owner review before production release. Running locally requires Python 3.11+. Setup uses a virtual environment, `pip install -e '.[dev,postgres,legacy]'`, a database setup script, environment variables for secret key, auth mode and rollout flags, an admin-creation CLI command, and a serve command. The CLI/package retains the historical `sabermetrics` name for compatibility. The default fixture-backed cEDH path works without provider credentials, PostgreSQL or a simulator; production research corpus and private accounts are not distributed with the repository. An offline deterministic builder can be exercised via CLI commands that list and build strategy packs. Verification uses pytest, ruff, black and mypy; the default suite relies on fixtures and mocks, while live PostgreSQL, model and simulator integrations are opt-in and model tests can incur API charges. CI also exercises installed-package behavior, authentication/recovery, feedback with mocked delivery, and HTTP container startup. Type configuration records scoped legacy exclusions rather than claiming full coverage. Scope and limitations: this is a Commander-focused application, not a full rules engine; goldfishing measures modeled play patterns, not multiplayer win probability; tournament coverage reflects available source data and inclusion rate is not proof of card quality; strategy-pack support is bounded by curated material and simulator capabilities; the single-host deployment is a deliberate operational tradeoff, not a claim of high availability. Some original generator modules remain as compatibility code, with the active generator product in a separate repository. The project is an unofficial fan project, not affiliated with Wizards of the Coast, and is MIT licensed.