// Flutter · Node.js · MongoDB · FastAPI · FAISS · ONNX
tcg-library
Cross-platform Pokémon TCG and Magic the Gathering collection manager with on-device card scanning.
What it is
A Flutter app (Windows / Android / iOS / web) for tracking Pokémon TCG and MTG collections, paired with a Node + MongoDB backend for cloud sync and a FastAPI + FAISS service for on-device card scanning.
Why
Existing collection apps either lock features behind subscriptions, ignore non-English locales, or require an internet round-trip to identify a card from a photo. tcg-library targets the gaps: localised in five languages out of the box, full export of your data on demand, and a scanner whose embedder runs entirely on-device — only a 512-dim numeric fingerprint ever leaves your phone.
Notable bits
- On-device card scanning. The embedder is a MobileNetV3 trained on synthetic + real card scans, exported to TFLite for Android/iOS and ONNX for the cloud index. The mobile camera converts each frame into a 512-dim L2-normalised vector locally; the backend matches it against a FAISS HNSW index built from ~20k Pokémon card art-groups.
- Hot-reload of the FAISS index without downtime. ml-service watches the index file mtime and atomically swaps the loaded version while in-flight
/searchcalls complete against the previous one. - Strict atomic full-replace for sync. Collection / portfolio / wishlist sync runs inside a Mongo transaction so two concurrent devices can't interleave a
deleteMany+insertManyand lose state. - Per-device sessions with prev-hash refresh grace. Each login creates a
Sessionrow keyed on(userId, deviceId)with its own SHA-256 refresh-token hash and TTL. 2FA toggles soft-revoke other sessions but keep the toggling device logged in. - Backups that aren't theatre. Nightly
mongodumpto a host bind mount with 14-day rotation, plus a quarterly restore drill into a scratch DB to prove the dumps are intact.
Stack
| Layer | Tech | |---|---| | Mobile / desktop / web | Flutter + Riverpod, MVVM, 5 locales | | Backend | Node 20, Express, Mongoose, MongoDB 7 | | ML service | Python 3.11, FastAPI, FAISS HNSW, ONNX Runtime | | Hosting | Self-hosted Ubuntu, Docker compose, Cloudflare Tunnel, GH Actions deploy |