# Shadow Theme Migration Notes

## Summary

The Shadow Vite/React theme has been migrated to a Next.js App Router application for the FAIRSIDE RUST US 5X store.

## Framework Migration

- Old entrypoint: `legacy/index.html`, `legacy/main.tsx`, `legacy/App.tsx`, React Router pages under `legacy/vite-pages`.
- New entrypoint: `src/app/layout.tsx`, `src/app/page.tsx`, and App Router routes under `src/app`.
- The old Vite files are moved to `legacy/` for reference, but the active scripts now use Next.js.

## Tip4Serv API

- Old secure proxy: `supabase/functions/tip4serv-proxy/index.ts`.
- New secure proxy: `src/app/api/tip4serv/route.ts`.
- Behavior preserved for:
  - `products`
  - `categories`
  - `product`
  - `store`
  - `checkout-identifiers`
  - `checkout`
  - `servers`
  - `server-players`
- `TIP4SERV_API_KEY` is read only in the server route handler and is never exposed to client components.
- The Supabase Edge Function remains in the repo as a deployable fallback and historical reference.

## Discord OAuth

- Old Edge Function: `supabase/functions/discord-oauth/index.ts`.
- New route handler: `src/app/api/discord/oauth/route.ts`.
- New callback page: `src/app/auth/discord/callback/page.tsx`.
- `DISCORD_CLIENT_SECRET` remains server-only.

## RCON / Server Status

- Old Edge Function: `supabase/functions/rcon-players/index.ts`.
- Current Next route: `src/app/api/rcon/route.ts`.
- This route safely proxies the existing Supabase function when `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` are configured.
- The existing Supabase RCON implementation and migrations were not deleted.

## SEO / Open Graph

- Store metadata now lives in App Router metadata in `src/app/layout.tsx`.
- Product metadata is generated in `src/app/products/[slug]/page.tsx`.
- Existing Supabase OG functions are preserved in `supabase/functions/og-store` and `supabase/functions/og-product`.

## Product Mapping

- Local FAIRSIDE marketing metadata lives in `src/config/fairside-products.ts`.
- Image mapping lives in `src/config/product-assets.ts`.
- Checkout uses real Tip4Serv catalog products only after a local product can be matched by:
  - `tip4servProductId`
  - `tip4servSlug`
  - a best-effort title/slug/duration match against the live catalog
- If matching fails, add-to-cart is disabled for that product and the UI shows a mapping warning.

## Manual Steps

Add real Tip4Serv IDs or slugs in `src/config/fairside-products.ts` for every FAIRSIDE product once the live catalog is final. This avoids any ambiguity in checkout mapping, especially for VIP durations.
