yazi — ~/projects

Projects

Home page of the TCG Store demo on desktop: dark purple storefront with a search bar, category menu and a featured expansion banner.
32 Prisma modelsAdvanced demo · paused

TCG Store

A trading-card store, built end to end

A complete Magic: The Gathering store that I designed, built and tested alone: a public storefront, a deck builder, a customer account, and an admin back office that largely runs itself. It runs as an online demo and the source code is private.

Role
Solo, full-stack
Period
2025 – 2026
  • Next.js
  • TypeScript
  • PostgreSQL
  • Supabase
  • Prisma
  • better-auth
  • Cloudinary
  • Vitest
  • Playwright

↑ ↓ choose · Enter opens

yazi — TCG Store

Chapter I // Next.js · TypeScript · PostgreSQL · Supabase · Prisma · better-auth · Cloudinary · Vitest · Playwright

TCG Store

A trading-card store, built end to end

Advanced demo · paused
Data model
32 Prisma models
Server actions
33 modules
Tests
387 test files
Integrations
5 external services
Scheduled jobs
3 cron jobs
Languages
EN and ES

What it is

A complete Magic: The Gathering store that I designed, built and tested alone: a public storefront, a deck builder, a customer account, and an admin back office that largely runs itself. It runs as an online demo and the source code is private.

What I built

Eight areas, each described below: the storefront and catalog, checkout and payments, a deck builder with a community, catalog automation and media, inventory management, the customer account, the admin back office, and the quality and security work behind them. Built with Next.js 16, React 19, TypeScript and PostgreSQL (Prisma), and tested with Vitest and Playwright.

What I took from it

A store is not a catalog: the hard part is keeping everything around it correct without someone watching. That taught me to design for failure first.

Architecture and the reasons behind it

Front end and back end live in one Next.js codebase on purpose. This is how the pieces fit, why I drew the lines where I did, and how the work was carried out.

  1. BrowserReact 19 client components only where interaction needs them (deck builder, inventory grid, dashboards). Cart and favorites live in Zustand stores kept in localStorage.
  2. Next.js App RouterServer components render the catalog pages. A request proxy runs first (origin checks, session-cookie gate, per-IP rate limiting). Mutations are server actions (33 action modules); real HTTP endpoints exist only for webhooks, cron jobs and exports.
  3. Feature modulesCode is organised by domain, not by file type: admin, auth, catalog, checkout, deck-builder, home and inventory each own their actions, components and services, on top of a shared layer.
  4. Prisma + PostgreSQL32 models on Supabase Postgres, with a separate direct URL configured for migrations. One typed schema feeds every layer above it.
  5. External servicesScryfall (cards, sets, prices), MTGJSON (sealed products), Wompi (payments and webhook), Cloudinary (media), Resend (email). Each sits behind a service module so jobs and admin actions share one implementation.
  6. Scheduled jobsThree Vercel cron routes: daily catalog sync, daily invoice reconciliation, weekly image healing. Each is authenticated with a secret and reports its result to a log table the admin can read.

Why front and back in one codebase

I built it alone. Server components and server actions share Prisma's generated types end to end, so changing a column breaks the compiler where the UI uses it instead of breaking a customer. One deployable unit also removes a whole class of drift: no separate API contract, no CORS, no two deploys to keep in sync. When a real endpoint is needed (webhooks, crons, CSV export), a route handler does it inside the same project.

Why concurrency lives in the database

On a serverless host many instances run at once, so an in-memory lock protects nothing. Stock rows carry a version number and every write is a conditional update, so the database decides who wins. Bulk edit, CSV import and checkout all go through the same rule, and an integration test exercises the race.

Why jobs are split into isolated steps

A card store depends on third-party data that fails in small ways: one set has no price, one image is gone. If one failure aborted the run, the rest of the catalog would go stale. Each step is wrapped so a failure is recorded and the run continues, and the admin sees the result on the lifecycle screen instead of finding out from a customer.

Why manual overrides always win

Automation is only trusted if it cannot undo a human decision. Price sync checks a per-item price mode before writing, and the admin media panel exists for exactly the cases the automatic art resolver gets wrong.

How the work was done

  1. Write the requirements down first, quoting the exact wording of each one, then break them into numbered tasks, each linked to the requirement it satisfies.
  2. Work on a branch per phase with small commits, tests next to the behavior they cover, and one gate per commit: type check, the unit suite and lint with zero errors.
  3. Test against realistic data: a local copy of the catalog (read-only, no users or orders) for an exhaustive pass over the admin panel.
  4. Deploy in small merged pull requests and check the live demo right after each one.
  5. Keep the notes: a deployment runbook, a document of golden rules (back up before risky changes, document the rollback) and the debt tracker, so the project can be picked up again after a pause.

Full feature inventory

1. Storefront and catalogA public store where every card shows its real price and live stock.
  • Singles and sealed products Separate catalogs for single cards and sealed products such as booster boxes, browsed by game and by expansion.
  • Card pages Card image, rules text, expansion, available languages and a price table by edition, condition and finish, with stock state.
  • Expansion pages Every set has its own page with featured cards, banners and its sealed products.
  • Preorders Upcoming sets appear as preorders, with the homepage hero showing the next release first.
  • Prices in pesos Prices are shown in Colombian pesos, converted from the stored USD rate, with price history kept per item.
  • Cart that follows you The cart is saved to the account, so it is the same on any device once you sign in.
  • Two languages Spanish and English across the whole site, each language loaded only when it is used.
2. Checkout and paymentsBuy with local payment methods and get every step confirmed by email.
  • Wompi payments Checkout through the Colombian gateway Wompi, with a webhook that confirms the payment back to the store.
  • Stock checked on the server Availability is validated on the server before a payment is processed, so a sold-out card cannot be bought.
  • Order lifecycle Seven order states from pending to refunded, an order log per order, and invoices with PDF download.
  • Transactional emails Welcome, password reset, order confirmation, shipping notification, preorder confirmation and back-in-stock alerts, plus a notice to the admin on new preorders.
3. Deck builder and communityBuild a deck, check it against the rules, and buy the cards from the store.
  • Search and availability Card search with filters for mana value, rarity and availability, switching between all cards and only what is in stock.
  • Analysis tools Mana curve chart, a budget gauge with preset tiers, format-rule checks, Commander bracket guidance with an explanatory FAQ, and a hypergeometric probability calculator.
  • Import and export Import a deck list, export to Moxfield, Arena, MTGO or plain text, and export the deck as an image.
  • Compare decks A comparison tool with charts to put two decks side by side.
  • Community decks Public decks with an explorer and tags, likes, ratings, comments with reactions, and related-deck suggestions.
  • Guided and mobile A builder tour for new users, and a phone layout with collapsible filters and a fixed bar to view the deck.
4. Catalog automation and mediaNew sets come out all the time. The store keeps its catalog, prices and artwork current without anyone doing it by hand.
  • Daily sync, 03:00 UTC Updates the USD to COP rate, finds new sets on Scryfall, imports sealed products from MTGJSON, validates artwork and syncs prices, each as a separate step.
  • Failures stay contained If one step fails, the others still run. The failure is logged and the admin sees the run marked as partial.
  • Date-driven preorders A future set with enough cards becomes a preorder by itself. At release the flag is cleared and items become normal stock. The homepage banner is chosen by rules, not by hand.
  • Weekly image repair, Sundays 06:00 UTC Checks every set and sealed-product image, re-resolves broken set art and clears dead images so the page shows a placeholder. It resumes where it stopped if time runs out.
  • Manual control when needed An admin media panel covers what automation gets wrong: signed Cloudinary uploads and per-set banner and cover editing. Jobs only run with a secret token.
5. Inventory managementStock has to stay correct when several people, and the checkout, touch it at the same time.
  • Stock per variant Condition, language and finish, for singles and sealed products, with faceted filters, search and selection over large lists.
  • No lost updates Each stock row carries a version number and every write checks it, so two people editing at once cannot silently overwrite each other. Bulk edits, CSV import and checkout follow the same rule, and an integration test reproduces the race.
  • Audit trail Every stock change is logged, with separate logs for singles and sealed, and can be exported.
  • CSV tools and alerts CSV import normalizes card names and shows a preview before applying. CSV export and low-stock alerts are built in.
  • Prices a human sets stay set Automatic price sync never overwrites a price the admin set manually.
6. Customer accountOne place for everything a buyer needs after signing up.
  • Sign-in options Email and password or Google, with password reset by email.
  • Orders Paginated history with seven order states and a button to reorder a past order.
  • Favorites and alerts Saved cards that notify you when they are back in stock, plus a notification inbox.
  • Decks and addresses Saved decks and shipping addresses in the same account area.
  • Security Two-factor authentication with authenticator apps, and one click to sign out of other devices.
  • Built for phones too Every tab has its own URL, and phones get a bottom tab bar.
7. Admin back officeRun the store from one place and see problems before a customer does.
  • Dashboard Net profit, orders, stock alerts and completion rate for the month, the year or all time, with a revenue chart and a recent-activity feed.
  • System status Live status of the database, the Wompi payment gateway and the exchange-rate feed.
  • Orders and invoices Orders with state filters, search by ID, payment ID or user, a date range and CSV export. Invoices with PDF download, reconciled daily by a job.
  • Catalog operations Inventory, sealed products, preorders, set lifecycle and the media panel, each with its own screen.
  • Users and guide User management with a detail page per user, and an in-panel guide that explains how to operate the store.
  • Visible failures The set lifecycle screen shows the last automated run, its status and any failure message.
8. Quality, security and performanceI audited my own work, fixed what I found, and kept the site fast.
  • Reviewed end to end An exhaustive pass over the admin panel on a local copy of the catalog, plus a security review of authentication, payments, cron jobs and uploads.
  • Security by design Security headers, per-IP rate limiting on sign-in and admin routes, trusted-origin checks, authenticated webhook and cron routes, two-factor authentication, a minimum password length, a generic response on duplicate sign-ups so accounts cannot be enumerated, and no secrets in the browser.
  • Clean dependencies The audit of production dependencies reports zero known vulnerabilities.
  • Performance A cached, rate-limited Scryfall client, a custom image loader that avoids serverless timeouts, streamed catalog pages and language files loaded on demand.
  • A gate on every change Type check, unit suite and lint with zero errors before a change counts as done.

Demo tour: the admin panel and the customer account

Evidence

  • Go to Map
  • Go to About
  • Go to Projects
  • Go to Experience
  • Go to Stack
  • Go to Arcade
  • Go to Contact
  • Go to Direct view
  • Open chapter I · TCG Store
  • Open chapter II · AmplixMe FS-0009
  • Open chapter III · IKAI Shell
  • Open chapter IV · JavaScript para Subir de Nivel
  • Open chapter V · omarchy-zen
  • Open chapter VI · obsidian-backend-template
  • Open chapter VII · Skorify (community contributions)
  • Open chapter VIII · Fitness_Tracker
  • Open chapter IX · linux-win-setup
  • Open chapter X · weather-app-react
  • Open chapter XI · studio-ghilbli-api
  • Theme: Chipre
  • Theme: Páramo
  • Theme: Tinto
  • Theme: Cafetal
  • Theme: Niebla
  • Theme: Nevado
  • Theme: Cable
  • Theme: Catedral
  • Download CV
  • Copy email
  • Cambiar a Español

↑↓ browse · Enter run · Esc close