KSN: migrate catalog and user data to Supabase#13
Open
codebend3r wants to merge 12 commits into
Open
Conversation
- Add migration creating catalog tables: `series`, `arc_mappings`, `movies`, `search_aliases`, `genre_filters` - Add owner-scoped `user_progress` and `user_preferences` tables - Public read-only RLS on catalog; `auth.uid() = user_id` on user tables - Add `react-query-persist-client` + async-storage persister for the upcoming offline catalog cache
- Read the 578 mapping JSONs in `ALL_MAPPINGS` order and load `series`, `arc_mappings`, and `movies` via the PostgREST client - Preserve insertion order so identity ids keep the shared-manga-id tie-break (first-listed series wins), matching `findMappingByMediaId` - Seeded 578 series, 2767 arcs, 221 movies, 30 aliases, 27 genre filters
- Add `src/data/catalog.ts`: fetch series + arcs + movies + aliases + genre filters from Supabase in one pass, assemble into `SeriesMapping` - Expose `useCatalog`/`useMapping`/`useGenreFilters` via React Query, cached 1h and kept a week for offline cold starts - Preserve the shared-manga-id tie-break by fetching series in id order and letting the first-listed win - Type the Supabase client with generated `Database` types - Make search aliases a runtime-hydratable singleton
- Wrap the app in `PersistQueryClientProvider` backed by AsyncStorage - Dehydrate only the `catalog` query (AniList/MangaDex stay in-memory), kept for up to a week - Warm the catalog at launch so mappings and search aliases are ready before the first screen renders
- Drop the static `GENRE_FILTERS` array; `splitHiddenForAniList` now takes the filter list as an argument - Home screen and the mobile filter sheet render `useGenreFilters()` - Keep the always-hidden Ecchi/Hentai policy in code - Rework the genre-filters test to exercise the pure bucketing logic against a fixture
- `SeriesCard` and the arc screens read `useMapping`/`useCatalog` - Series/anime/manga detail screens resolve the curated mapping via `useCatalog().findMapping` and only fall back to a synthetic mapping once the catalog has loaded (avoids an auto-estimated flash) - Arc screens show a spinner until the catalog resolves, then the not-found state
- Stamp `updatedAt` on every japanese/hidden-genre toggle and persist it - Enables last-write-wins reconciliation against the Supabase copy
- `mergeProgress`: last-write-wins union of local and server progress, per (routeId, side), plus the rows that need pushing - `diffProgress`: upsert/delete deltas to move the server between states - `mergePreferences`: last-write-wins for the single preferences row - Cover all three with unit tests
- Add a cloud-sync controller: pull + last-write-wins merge on login, debounced push of local changes, delete propagation for cleared entries - Local zustand stores stay the immediate source of truth; sync is best-effort and never blocks the UI (logged-out users are unaffected) - Guard against pull->push echo with an applying-remote flag - Start the controller once from the root layout
- Include aliases in the catalog query result and push them into the alias singleton via an effect keyed on the data - Fixes aliases staying empty on a cache-restored start, where the query function (which previously hydrated them) never runs
- Delete `src/data/mappings/` (578 files) and `top100-manifest.json` - Strip the import wall, `ALL_MAPPINGS`, `findMappingByMediaId`, and the `normalizeMapping` layer from `src/data/index.ts`; keep only the pure helpers (`pairResults`, `buildSyntheticMapping`, episode/chapter lookup) - Empty the bundled search-alias defaults (loaded from the DB now) - Reword detail-screen copy that pointed contributors at the JSON files - Drops ~578 modules and ~0.6 MB from the web bundle
- Document mappings/aliases/genre filters living in Supabase - Rewrite "Contributing a mapping" as a SQL insert into `series` + `arc_mappings` instead of a JSON file + `index.ts` import - Refresh the stack list and project layout
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
✅ Deploy Preview for kasane-guide ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Updates to Preview Branch (migrate-to-supabase) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves kasane's static data off bundled JSON and into Supabase (project
obtgldkascmxbtpnvscn), so mappings update without an app release, the bundle shrinks, and user data syncs across devices.Schema
series,arc_mappings,movies,search_aliases,genre_filters) and two owner-scoped user tables (user_progress,user_preferences), all under RLS. Security advisors report zero issues.Seeding
ALL_MAPPINGSorder, preserving the shared-manga-id tie-break (first-listed wins).Client
src/data/catalog.tsfetches everything in one nested query and exposesuseCatalog/useMapping/useGenreFiltersvia React Query.User sync
src/state/sync.ts: pull + last-write-wins merge on login, debounced push on change, delete propagation. Local zustand stays the immediate source of truth; logged-out users are unaffected. Merge logic has unit tests.Cleanup
src/data/mappings/(578 files),top100-manifest.json, and the import wall /ALL_MAPPINGS/findMappingByMediaId/normalizeMappingfromindex.ts(1,385 → 145 lines).kasane-arc-mappingskill now documents the DB-insert workflow.Verification
bun run system-check(typecheck + prettier + eslint + 39 tests + web build) green on every commit.user_progressare blocked by RLS.Notes