============================================================
 LearnWithBitto.com — May 2026 Final v2 Deploy Package
============================================================

WHAT'S IN THIS ZIP
------------------
- app.js                  Express server (Certifier API + waitlist API + routes)
- seo.js                  SEO helper
- package.json / package-lock.json / passenger_app.cjs
- .htaccess               Cache rules, SPA routing (no-cache on index.html)
- public/                 ENTIRE static site
    index.html              Hub (with injected: Products nav, 7-flag language
                            switcher, "Top Learners" leaderboard, "Exclusive
                            Bitto Trading Event" waitlist section)
    products/               7 BitMart product modules (21-27), badges
    blockchain/             8 blockchain modules (all unlocked)
    advanced/               existing advanced track
    leaderboard.html        Gamified "Bitto Arena" page
    certificate.html        Certifier claim page
    articles/, images/, etc.
- supabase-migration-add-certificate.sql    (ALREADY RUN on prod 2026-05-19)
- supabase-migration-add-waitlist.sql       (ALREADY RUN on prod 2026-05-19)
- supabase-migration-add-bitmart-id.sql     (existing)

WHAT IS NOT IN THIS ZIP (intentionally - keeps your server config safe)
----------------------------------------------------------------------
- .env                    Your secrets stay on the server, untouched.
- node_modules/           Already on the server from Feb. No reinstall needed
                          unless package.json changed (it did not vs v1).

============================================================
 INSTALL ON cPANEL  (5 minutes)
============================================================

Given your current /home/loveqbyx/learnwithbitto.com listing:

STEP 1 - BACKUP CURRENT app.js
   In cPanel File Manager, rename:
     app.js  ->  app.js.bak-2026-05-19-v1
   (You already have app.js.predeploy.bak from earlier. Keeping both is fine.)

STEP 2 - UPLOAD THIS ZIP
   Upload learnwithbitto-May2026-final-v2.zip to /home/loveqbyx/learnwithbitto.com/
   Right-click -> Extract -> "Overwrite all files: YES".
   Overwrites: app.js, seo.js, .htaccess, package.json, package-lock.json,
   passenger_app.cjs, public/, DEPLOY-README.txt, the 3 migration SQL files.
   Does NOT touch: .env, node_modules/, tmp/, stderr.log, your .bak files.

STEP 3 - (ONE TIME) ADD CERTIFIER ENV VARS
   Open .env in cPanel code editor and add (if not already present):
     CERTIFIER_API_KEY=cfp_YrVB1iKOexM2Zaw6yJBNrGQPvxlpxqEIcDm6
     CERTIFIER_GROUP_ID=01kryhxb6pejyymmcvmhsjjaw1
   (Optional defaults are fine: CERTIFIER_API_BASE, CERTIFIER_VERSION,
    CERT_POINTS_THRESHOLD=1800.)

STEP 4 - RESTART THE NODE APP
   Either:
   A) cPanel -> "Setup Node.js App" -> learnwithbitto.com -> "Restart".
   B) In File Manager, create/touch the file:  tmp/restart.txt
      (Passenger watches this file - touching it triggers a restart.)

STEP 5 - VERIFY (use a private/incognito window to bypass cache)
   https://learnwithbitto.com/            -> Hub loads with "Top Learners"
                                              populated, "Exclusive Bitto
                                              Trading Event" section, 7-flag
                                              language switcher, Products link.
   https://learnwithbitto.com/products/   -> 7 module cards + signup nudge.
   https://learnwithbitto.com/blockchain/ -> 8 modules + signup nudge.
   https://learnwithbitto.com/leaderboard -> Gamified arena page.
   https://learnwithbitto.com/certificate -> Claim page (login-gated).

STEP 6 - CLEAN UP (optional)
   Safe to delete once verified:
     - learnwithbitto-v6-herofix.zip      (Apr 9 backup, superseded)
     - learnwithbitto-deploy-final.zip    (earlier today, superseded by v2)
     - app.js.predeploy.bak                (keep for extra safety if you want)
     - index.html at site ROOT (the 437 KB one)
        -> public/index.html is what gets served; the root one is unused.
   KEEP: .env, .htaccess, node_modules/, public/, app.js, package*.json,
         passenger_app.cjs, seo.js, tmp/.

============================================================
 TROUBLESHOOTING
============================================================

- 502 / "Application failed to start" after restart:
    Check stderr.log. Most common cause: a typo in .env. The app DEGRADES
    GRACEFULLY without CERTIFIER_* vars (cert endpoints return 503
    "not configured") - it will NOT crash from a missing cert key.

- Hub looks the same (no new sections):
    Hard-refresh (Cmd+Shift+R / Ctrl+F5). New index.html is no-cache via
    .htaccess, but your browser may still hold the old one.

- "Top Learners" empty:
    /api/leaderboard reads from Supabase get_leaderboard RPC. The page
    falls back to a stock roster if the RPC returns nothing - so it always
    shows something. Check browser console if totally blank.

- Certificate page says "not configured":
    STEP 3 incomplete or you didn't restart after editing .env.

============================================================
 WHAT CHANGED VS v1 (earlier today's learnwithbitto-deploy-final.zip)
============================================================
- Added guest "Sign up free" nudge banner on both /products/ and
  /blockchain/ (dismissible, 7 languages).
- Confirmed all modules unlocked (product 7/7, blockchain no gating).
- Rebuilt both Vite tracks with fresh asset hashes.
- Re-tested every route + API endpoint, console clean.

Project memory: MEMORY.md -> project-architecture, product-track-build,
i18n-multilingual, certificate-integration.
