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

@@ -28,3 +28,4 @@
- [Persist Metadata](./devlog/2025-12-16-230000_persist_metadata.md): Completed. Implemented IndexedDB persistence for Scryfall metadata to ensure offline availability and reduce API calls.
- [Bulk Parse Feedback](./devlog/2025-12-16-231500_bulk_parse_feedback.md): Completed. Updated `CubeManager` to handle metadata generation properly and provide feedback on missing cards.
- [Full Metadata Passthrough](./devlog/2025-12-16-234500_full_metadata_passthrough.md): Completed. `DraftCard` now includes a `definition` property containing the complete, raw Scryfall object for future-proofing and advanced algorithm usage.
- [Server-Side Caching](./devlog/2025-12-16-235900_server_side_caching.md): Completed. Implemented logic to cache images and metadata on the server upon bulk parsing, and updated client to use local assets.

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.