Poke Notes is a Next.js App Router app for tracking Pokemon TCG battle logs, deck lists, tournaments, and related stats.
- Node.js 20.9 or newer (required by the installed Next.js version)
- npm
- A Supabase project with Auth enabled
- A Google OAuth provider configured for Supabase Auth
- Install dependencies:
npm ci- Create a local env file:
cp .env.example .env-
Fill in the values in
.env. -
Bootstrap the database:
- For a new Supabase project, apply
schema.sql. It is the complete schema snapshot; do not replay the historical incremental SQL over it. - For an existing environment, inspect migration history and the target schema before applying anything.
supabase/migrationsis the release authority.sqlis historical reference material, not a fresh-install sequence or a destination for new migrations. - Local Git hooks validate database changes without deploying them. Production migrations run only through the
Deploy production databaseworkflow, which the merging session dispatches after merge tomain; seedocs/migration-release.md.
- Configure Supabase Auth redirect URLs for each environment:
http://localhost:3000/auth/callbackhttps://<your-production-domain>/auth/callback
- Start the app:
npm run devFor repeatable state-changing browser journeys, use the isolated local Supabase stack. It contains synthetic fixtures and cannot target a linked hosted project:
npm run e2e:local:setup
npm run dev:e2e
# In another terminal:
npm run auth:e2e:saveReset with npm run e2e:local:reset before a full run, then save auth again because reset replaces the local user. To test on a phone, open the Wi-Fi address that dev:e2e prints and paste the code from npm run auth:e2e:copy-code. Claude has its own local account, which Sign in as Claude selects and npm run auth:e2e:save:claude saves. See docs/agents/local-e2e.md for fixture IDs, safety rules, lifecycle commands, and verification.
The existing-account flow below remains available for non-destructive local checks against a configured development project. Do not use it for the resettable browser suite.
The production app does not provide a test-login route. The development-only local login requires the current pairing code on both localhost and a phone; there is no trusted-host shortcut.
For automated localhost browser checks, configure the existing test account, start the server, and save a host-scoped browser state. The save command reads the pairing code from ignored local env and submits it in the login form; it does not place the code in a URL:
npm run auth:local:setup
npm run dev:test-login
# In another terminal:
npm run auth:local:saveauth:local:setup and dev:test-login are safe to run repeatedly: when local credentials already
exist, setup preserves the existing password so active browser sessions remain valid. If the saved
agent-browser state redirects to /login, run npm run auth:local:save and retry with a fresh
agent-browser session. The in-app Browser and Chrome use separate cookie stores and do not consume
the saved agent-browser state.
Rotate the test-account password only when credentials may be compromised:
npm run auth:local:rotate
npm run auth:local:saveRotation intentionally invalidates existing localhost sessions, including manually authenticated browser sessions.
For authenticated testing on a phone connected to the same trusted Wi-Fi network:
- Configure the existing local test account and start the LAN-accessible dev server:
npm run dev:test-login- In another terminal, copy the local pairing code to the macOS clipboard without printing it:
npm run auth:local:copy-code- On the phone, open the Mac's
.localaddress on port 3000, choose Sign in locally, and paste the pairing code. The setup command records the current private IP and macOS local hostname as exact allowed hosts in the ignored, mode-0600.env.localfile.
Use this only on a trusted private network. The local server uses HTTP, so it is not suitable for
public or shared Wi-Fi. A browser session is tied to the hostname used to create it; do not switch
between the .local name and numeric IP during the same session.
If the dev server starts showing stale chunk errors, clear the Next cache and restart:
npm run dev:resetCopy the keys from .env.example. The running application needs:
NEXT_PUBLIC_APP_URLNEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEY
Seed and catalog utilities also use:
NEW_SUPABASE_URLNEW_SUPABASE_SERVICE_KEY
Optional variables:
POKENOTES_AUTH_CLAIMS_SECRET(dedicated HMAC key for forwarded auth claims; falls back to the Supabase service key)CRON_SECRETLIMITLESS_SYNC_SECRET(production hourly Limitless sync)POKEMON_TCG_API_KEY(optional upstream rate-limit allowance for card-effect sync)POKE_NOTES_DEBUG_AUTHPOKE_NOTES_DEBUG_PERFPOKE_NOTES_AUTH_REDIRECT_ORIGINSPOKE_NOTES_ENABLE_TEST_LOGINPOKE_NOTES_TEST_LOGIN_EMAILPOKE_NOTES_TEST_LOGIN_PASSWORDPOKE_NOTES_LOCAL_LOGIN_CODEPOKE_NOTES_LOCAL_LOGIN_HOSTS
Run npm run for the complete script list. Common commands are:
npm run devstarts the app locallynpm run dev:resetclears.nextand starts the dev server againnpm run cleanremoves local Next.js build outputnpm run lintruns ESLintnpm run format -- path/to/file.tsformats explicitly named authored files with pinned Prettiernpm run format:check -- path/to/file.tschecks those files without writing; exits nonzero on driftnpm run typecheckruns Next type generation and TypeScript checksnpm run testruns the test suitenpm run buildcreates a production buildnpm run design:auditchecks shared design-token and component conventionsnpm run schema:healthverifies the linked schema, grants, exact tenant/link constraints, triggers, and security contracts read-onlynpm run types:supabaserefreshes generated TypeScript definitions from the linked schemanpm run audit:deck-compatibilitycompares legacy and relational deck aggregates with SELECT-only paginated reads and aggregate-only output; exit2means cut-over remains blockednpm run startserves the production build locallynpm run auth:local:setupconfigures the existing local test account and allowed LAN hostsnpm run auth:local:copy-codecopies the local pairing code without printing itnpm run auth:local:savesubmits that code in the localhost login form and refreshes the host-scoped agent-browser statenpm run e2e:local:setupstarts and resets isolated local Supabase, then loads synthetic browser fixturesnpm run dev:e2estarts the app against the isolated local databasenpm run auth:e2e:saverefreshes the localhost-only browser state for the synthetic accountnpm run perf:probeprobes configured local page/API routes without making localhost the production benchmarknpm run perf:prod:authopens an attended Google login and saves host-filtered production auth statenpm run perf:prodreplays the authenticated production route journeynpm run sync:pokemon-catalogruns the Pokemon catalog sync manually
Formatting accepts explicit repository-relative JS/JSX/MJS/CJS, TS/TSX, CSS, Markdown/MDX,
JSON and YAML file paths. Quote paths containing spaces or parentheses. Directories, globs,
outside/symlink paths, generated types/supabase.ts, SQL, lockfiles, ignored files and build
artifacts are rejected. The whole batch is validated and parsed before writing. Name only
files changed for the task; baseline formatting is a separate reviewed change. The command
never defaults to formatting the repository, and is not an automatic commit hook.
CONTEXT.md: product language and data invariants.PRODUCT.md: users, product intent, brand, and accessibility direction.docs/design-system.md: current UI tokens and shared-component contracts.docs/performance-targets.md: dated production measurements and performance targets.known-edge-cases.md: current cross-feature behavior and compatibility contracts.docs/application-health-review.md: the dated repository/production audit and remaining work.docs/adr: accepted architectural decisions.
Older local working copies may still contain ignored HANDOVER.md, REBUILD_PLAN.md, or ARCHETYPE_CATALOG_STARTER.md files. They are superseded migration-era artifacts, are not repository documentation, and are candidates for local deletion once no external reference depends on their filenames.
Deployments are intended for Vercel.
- Create a Vercel project from this repository.
- Add the same runtime env vars used locally.
- Set
NEXT_PUBLIC_APP_URLto the deployed origin. - If another non-Vercel origin must complete authentication, add its full origin to the
comma-separated
POKE_NOTES_AUTH_REDIRECT_ORIGINSallowlist. Vercel's server-provided current deployment and branch URLs are approved automatically, but every callback URL must also be allowed by Supabase Auth. - In Supabase Auth, add each approved deployed
/auth/callbackURL to the allow list. - Apply
schema.sqlfor a fresh database. For an existing database, deploy only unapplied native migrations through the controlled production workflow. - Set
CRON_SECRETin Vercel so the scheduled catalog sync route can authenticate requests. /auth/test-logindeliberately returns404outside development. Production browser checks use an attended Google login captured bynpm run perf:prod:auth; local automated and phone checks use the development-only flow above.
Migration alignment, schema health, and application behavior are release evidence, not cached repository facts. Capture them from the intended production target for each database deployment.
vercel.json schedules /api/cron/sync-pokemon-catalog to run daily at 05:00 UTC. The job refreshes pokemon_catalog from the upstream sources, then invalidates the cached Pokemon options and identification catalog so UI menus and lookup paths see the new rows without a manual reseed.
The upcoming-events dashboard reads the saved limitless_event_feed snapshot and shows its UTC sync time. It never fetches Limitless during a dashboard request. Supabase Cron requests the protected refresh endpoint at :05 each hour when the snapshot is at least 55 minutes old. GitHub Actions checks at :35 and refreshes only when the snapshot is at least 75 minutes old. Vercel also runs a daily sync during the 06:00 UTC hour. A database lease prevents concurrent refreshes; manual GitHub workflow dispatch bypasses the age check but still uses the lease. The Production environment secret LIMITLESS_SYNC_SECRET must match the Vercel Production variable; the controlled database deployment workflow copies it into Supabase Vault after migrations. The Cron job is inert until that Vault secret exists. An app deployment that precedes the migration temporarily uses the original unleased refresh path and reports compatibilityMode: true; confirm that production syncs stop reporting this after the database workflow. Check the saved timestamp and Cron/GitHub run history after release, since a successful scheduler invocation alone does not prove a new snapshot was saved.
Before shipping a change, the recommended checks are:
npm run lint
npm run typecheck
npm run test
npm run build