Verify all auth code is in code/client/pages/ and code/api/discord/*
List all custom hooks used in auth flow (use-toast, etc.)
Document all Supabase queries used for auth
Get list of all environment variables currently in use
Create a "mirror" directory structure on aethex.foundation (Replit)
During Phase 1
Copy all page files (Login, Signup, Onboarding, Dashboard, etc.)
Copy all context files (AuthContext, DiscordActivityContext, ThemeContext)
Copy all component files (OAuthConnections, PassportSummary, etc.)
Copy all API endpoint files (discord/oauth/, profile/ensure.ts, passport/)
Copy all Supabase migrations
Copy tailwind.config.js and global.css for styling
Adapt all import paths for new directory structure
Update all VITE_API_BASE references
Update Discord OAuth app redirect URIs
Set up environment variables on Replit
Testing Phase 1
Can users log in via Discord on aethex.foundation?
Can users view their profile?
Can users link additional OAuth providers?
Can users access their passport?
Are Supabase queries working correctly?
Are Discord OAuth callbacks returning correct data?
10. SUCCESS CRITERIA FOR PHASE 1
✅ All auth pages render correctly on aethex.foundation ✅ Users can log in via Discord on aethex.foundation ✅ Users can link additional accounts (Google, etc.) ✅ Passports display correctly ✅ All OAuth callbacks complete without errors ✅ Supabase access is working (read/write to user_profiles) ✅ Code is ready for Phase 2 (permission migration)
11. ESTIMATED EFFORT
Task
Estimate
Audit & document auth code
2-3 hours
Copy & adapt page files
4-6 hours
Copy & adapt API endpoints
3-4 hours
Fix imports & dependencies
2-3 hours
Test login flow
2-3 hours
Build SSO endpoints
4-6 hours
Total Phase 1
17-25 hours
12. BLOCKERS & RISKS
Risk 1: API endpoints on Vercel may not work on Replit without refactoring
→ Mitigation: Convert to Express routes on Replit server
Risk 2: Environment variable names differ between Vercel and Replit
→ Mitigation: Use consistent naming convention
Risk 3: Supabase RLS policies may prevent new app from writing to tables
→ Mitigation: Phase 2 handles permission migration
Risk 4: Discord OAuth app may not accept aethex.foundation as redirect URI
→ Mitigation: Update Discord app settings before testing
Next Steps
Review & Approve Scope: Confirm this list is complete
Set up Replit Structure: Create mirrored directories on aethex.foundation
Start Code Copy: Begin with pages, then contexts, then components
Adapt & Test: Fix imports, test each piece as copied
Proceed to Phase 2: Once Phase 1 is solid, move to database permission migration