Skip to main content

Core Package Overview

@riftseer/core is the shared library that everything else in the monorepo depends on. It owns the provider interface all data access goes through, and the autocomplete search engine. Card types and the parser live in @riftseer/types and are re-exported here for convenience.

Nothing in core is runtime-specific — it runs in Bun, Node, and Cloudflare Workers alike (except the server-only entry point, which is Bun/Node).


What's in core​

ModuleFilePurpose
Typessrc/types.tsRe-exports Card, CardRequest, ResolvedCard, and all sub-interfaces from @riftseer/types
Provider interfacesrc/provider.tsCardDataProvider — the only contract the API cares about
Parsersrc/parser.tsRe-exports parseCardRequests() from @riftseer/types
Discord emojisrc/icons.tsEMOJI_FILES and renderTextForDiscord(), over the @riftseer/types/render token kernel
Searchsrc/search.tsautocompleteSearch() — deterministic, position-aware name ranking
Normalizesrc/normalize.tsRe-exports normalizeCardName() from @riftseer/types
Supabase providersrc/providers/supabase.tsSupabaseCardProvider — the only CardDataProvider implementation
Loggersrc/logger.tsLightweight structured logger
Server entrysrc/server.tsRe-exports Supabase and Redis clients (server-side only)

Provider pattern​

The API does not import any database client directly. All data access goes through the CardDataProvider interface. The concrete implementation (SupabaseCardProvider) is selected at startup by the CARD_PROVIDER env var via the factory in src/providers/index.ts.

This means route code never changes when the data source changes — only the provider implementation does.

The ElysiaJS API server calls provider.warmup() on startup, then passes the provider into route modules as a dependency. See Provider Interface for the full contract.


Exports​

The public surface is src/index.ts. Import from @riftseer/core:

import type { Card, CardRequest, ResolvedCard } from "@riftseer/core";
import { parseCardRequests } from "@riftseer/core";
import { autocompleteSearch } from "@riftseer/core";

Server-side clients (Supabase, Redis) are exported from @riftseer/core/server — do not import these in Workers or browser builds.

If you only need types or the parser and want to avoid core's heavier dependencies, import from @riftseer/types directly.


Testing​

Tests live in src/__tests__/. Run with:

bun test packages/core

The provider tests use mock() from bun:test to stub the CardDataProvider interface. No live database connection is needed.