How taylorleprechaun/cardcollector works
Purpose and Entry Points
Card Collector is a personal Yu-Gi-Oh collection and purchase-planning system built as an ASP.NET Core Razor Pages application. HTTP startup, dependency wiring, authentication, EF Core setup, and hosted work begin in Program.cs. Feature endpoints are PageModels paired with server-rendered Razor views, e.g. Pages/Collection.cshtml.cs, Pages/Wishlist.cshtml.cs, and Pages/Stats.cshtml.cs.
Presentation and Interaction Layer
Razor Pages own request handling, form actions, redirects, CSV downloads, and page-specific view-model assembly. Shared partials provide reusable result tables and modals. Browser-side JavaScript augments selected workflows rather than serving as a separate frontend.
• Pages/Browse.cshtml.cs
• Pages/Cart.cshtml.cs
• Pages/Shared/_Layout.cshtml
• wwwroot/js/cart.js
Application Orchestration
CardService is the primary domain-facing read/orchestration layer. It joins cached card catalog data with persisted collection state to produce browsing, collection, wishlist, dashboard, audit, new-printing, and purchase-priority views. PageModels should cross this boundary through ICardService, rather than directly composing catalog and collection data.
• Services/CardService.cs
• Services/ICardService.cs
• Services/PurchasePriorityAnalyzer.cs
Catalog Ingestion and External Data Boundary
Card catalog metadata is represented by DTOs and loaded via a repository/cache boundary. Startup or cache refresh obtains yaml-yugi card/set data; image metadata comes from YGO Pro Deck, while images remain CDN-hosted. Cache behavior supports TTLs and stale-data fallback; Speed Duel sets are filtered during load.
• Repository/CardDataRepository.cs
• Repository/CardDataMapper.cs
• Data/FileCacheHelper.cs
• DTO/YamlYugi/YamlCard.cs
Persistence and Transaction Boundary
EF Core maps local SQLite state through AppDbContext. Repositories isolate entity-specific queries and mutations; UnitOfWork provides the commit boundary. Persisted state covers owned entries, preferred printings, cart/pending orders, checkouts, ignored/dismissed cards, and historical value snapshots.
• Data/AppDbContext.cs
• Repository/UnitOfWork.cs
• Repository/CollectionRepository.cs
• Data/Models/CollectionEntry.cs
Collection-to-Purchase Lifecycle
Users select preferred versions, which drive wishlist and buy-list candidates. Wishlist items can be staged as pending order lines, finalized through Cart into Orders, then received into the collection. Ownership, pending orders, and checkout state influence visibility and badges throughout shopping and collection workflows.
• Pages/Wishlist.cshtml.cs
• Pages/BuyList.cshtml.cs
• Pages/Cart.cshtml.cs
• Repository/PendingOrderRepository.cs
Pricing, Snapshots, and Analytics
PricingService fetches live per-card pricing from the YGO Pro Deck pricing endpoint. PricingDataCache avoids repeated retrieval, while the hosted background service runs nightly at midnight US Eastern to price owned/wishlisted cards, write dated value snapshots, and prune history. Dashboard and Stats consume persisted snapshots rather than requiring live pricing per request.
• Services/PricingService.cs
• Services/PricingDataCache.cs
• Services/PriceRefreshBackgroundService.cs
• Repository/ValueSnapshotRepository.cs
Runtime and Deployment
The system targets .NET 10 with EF Core 9, SQLite, Newtonsoft.Json, cookie authentication backed by BCrypt credentials, Bootstrap, and CDN Chart.js. Deployment is automated through GitHub Actions and a PowerShell/service-unit deployment path.
• CardCollector.csproj
• appsettings.json
• .github/workflows/deploy.yml
• scripts/card-collector.service
Main entry points: CardService.cs CardService · PriceRefreshBackgroundService.cs Nightly price refresh · AppDbContext.cs AppDbContext · Collection.cshtml.cs Razor PageModels
Components 20
Web UI
- Razor PageModels · Handles collection, wishlist, stats, browse, cart, and buy-list requests.
Pages/Collection.cshtml.cs - Shared Razor layout
Pages/Shared/_Layout.cshtml - Cart browser script
wwwroot/js/cart.js
Application services
- ICardService · PageModels use this boundary for catalog-plus-state views.
Services/ICardService.cs - CardService · Combines cached catalog data with collection state for application views.
Services/CardService.cs - Purchase priority analyzer
Services/PurchasePriorityAnalyzer.cs
Catalog data
- Card data repository · Loads filtered yaml-yugi catalog and image metadata through cache-backed sources.
Repository/CardDataRepository.cs - Card data mapper
Repository/CardDataMapper.cs - File cache helper · Supports TTLs and stale-data fallback.
Data/FileCacheHelper.cs - YamlCard DTO
DTO/YamlYugi/YamlCard.cs
Local state
- AppDbContext · Maps local SQLite collection, order, preference, and snapshot state.
Data/AppDbContext.cs - Unit of work · Commits repository mutations.
Repository/UnitOfWork.cs - Collection repository
Repository/CollectionRepository.cs - Pending order repository · Stages wishlist candidates through checkout and receipt.
Repository/PendingOrderRepository.cs - Collection entry
Data/Models/CollectionEntry.cs
Pricing and analytics
- Pricing service · Fetches per-card pricing from YGO Pro Deck.
Services/PricingService.cs - Pricing data cache · Avoids repeated live price retrieval.
Services/PricingDataCache.cs - Nightly price refresh · Prices owned and wishlisted cards, writes snapshots, and prunes history.
Services/PriceRefreshBackgroundService.cs - Value snapshot repository · Persists dated collection values for dashboard and stats.
Repository/ValueSnapshotRepository.cs
Other components
- ASP.NET startup · Configures HTTP, authentication, EF Core, DI, and hosted work.
Program.cs
Connections 25
- ASP.NET startup → Razor PageModels: hosts
- ASP.NET startup → AppDbContext: configures
- ASP.NET startup → Nightly price refresh: starts
- Razor PageModels → Shared Razor layout: renders in
- Cart browser script → Razor PageModels: augments cart actions
- Razor PageModels → ICardService: queries via
- ICardService → CardService: implemented by
- CardService → Card data repository: reads catalog
- CardService → Collection repository: joins collection state
- CardService → Pending order repository: uses shopping state
- CardService → Purchase priority analyzer: calculates priorities
- Card data repository → Card data mapper: maps
- Card data mapper → YamlCard DTO: transforms
- Card data repository → File cache helper: caches catalog
- Collection repository → AppDbContext: queries and mutates
- Collection repository → Collection entry: manages
- Pending order repository → AppDbContext: queries and mutates
- Unit of work → AppDbContext: commits through
- Nightly price refresh → Pricing service: requests prices
- Pricing service → Pricing data cache: uses
- Nightly price refresh → Collection repository: selects owned cards
- Nightly price refresh → Pending order repository: selects wishlisted cards
- Nightly price refresh → Value snapshot repository: writes snapshots
- Value snapshot repository → AppDbContext: persists in
- CardService → Value snapshot repository: reads analytics