Skip to main content

Documentation 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.

MTG Cheaper Deck uses python-dotenv to load configuration from a .env file placed in the project root. When any module is imported, load_dotenv() runs automatically and populates os.environ with the values in that file. There is only one required variable — DATABASE_URL — and it already has a sensible default, so a minimal setup requires nothing more than creating the file shown below.

Create the .env file

Place a .env file at the project root before running any command. The minimal configuration that gets everything working out of the box is:
DATABASE_URL=sqlite:///./data/cards.db

Environment Variables

DATABASE_URL
string
required
SQLAlchemy connection URL for the card database. Controls which database engine is used to store and query Scryfall card data. Defaults to sqlite:///./data/cards.db when the variable is not set.

SQLite (default)

SQLite requires zero additional installation — it ships with Python’s standard library. When DATABASE_URL points to a SQLite file, init_db() (called inside db.py and at the start of sync_scryfall.py) automatically creates the data/ directory if it does not exist, so there is no manual folder setup needed. The database file is excluded from version control via .gitignore, so it will never be accidentally committed.

PostgreSQL

To switch to PostgreSQL, change DATABASE_URL to a PostgreSQL connection string and install the driver:
pip install psycopg[binary]
Then update your .env:
DATABASE_URL=postgresql+psycopg://user:password@localhost:5432/mtg_cards
The db.py table definition and upsert logic are fully portable — no changes are needed there. The get_engine() function detects the dialect at runtime and sets the appropriate connection arguments automatically.
The legalities filter in scoring.py uses json_extract, which is SQLite syntax. If you switch to PostgreSQL, the _POOL_SQL query in scoring.py must be updated to use the PostgreSQL jsonb ->> operator instead.

Data directory

The following files are created under data/ during normal operation. All of them are excluded from git:
FileDescription
cards.dbSQLite database containing all synced Scryfall card data. Excluded from git.
oracle-cards.jsonl.gzCompressed bulk file downloaded from Scryfall. Re-downloaded on each sync_scryfall.py run. Excluded from git.
compare.htmlTemporary card comparison page generated during analysis. Excluded from git.
The .env file itself is also listed in .gitignore and will never be committed. Keep any sensitive credentials (such as a PostgreSQL password) out of version control by relying on this exclusion.

Build docs developers (and LLMs) love