feat: Enhance card metadata handling, implement persistent Scryfall caching, and update pack generation logic for new booster structure.
Some checks failed
Build and Deploy / build (push) Failing after 55s

This commit is contained in:
2025-12-16 22:51:21 +01:00
parent e0d2424cba
commit ea24b5a206
7 changed files with 81 additions and 11 deletions

View File

@@ -0,0 +1,25 @@
# Plan: Server-Side Caching of Bulk Data
## Objective
Implement server-side caching of both card images and metadata upon bulk parsing, ensuring the application relies on local assets rather than external Scryfall URLs.
## Implementation Steps
1. **Refactor Server Architecture (`CardService.ts`)**
* Update storage paths to `public/cards/images` (previously `public/cards`) and `public/cards/metadata`.
* Implement `cacheMetadata` to save JSON files alongside images.
2. **Update API Endpoint (`index.ts`)**
* Modify `POST /api/cards/cache` to handle metadata saving in addition to image downloading.
* Update static file serving to map `/cards` to `public/cards`, making images accessible at `/cards/images/{id}.jpg`.
3. **Update Client Logic (`CubeManager.tsx`, `PackGeneratorService.ts`, `LobbyManager.tsx`)**
* **Generation**: Pass a flag (`useLocalImages`) to the generator service.
* **Url Construction**: Generator now produces URLs like `${origin}/cards/images/{id}.jpg` when the flag is set.
* **Triggers**: `CubeManager` immediately sends parsed data to the server for caching before generating packs.
* **Consistency**: `LobbyManager` updated to look for images in the new `/cards/images` path for multiplayer sessions.
## Impact
* **Performance**: Initial "Parse Bulk" takes slightly longer (due to server cache call), but subsequent interactions are instant and local.
* **Reliability**: Application works offline or without Scryfall after initial parse.
* **Precision**: Metadata is now persisted as individual JSONs on the backend, ready for future complex backend algorithms.