Leeway - A real-time chat application built with Next.js, Supabase, and TypeScript
-
Authentication System:
- Uses Supabase Auth with dual auth.users and user_profiles tables
- Supports both email and username login
- Profile management with username and display name
-
Database Structure:
- Separate auth.users (Supabase-managed) and user_profiles (application data)
- RLS policies implemented for security
- Secure view (user_emails) for username-based login
-
Frontend Architecture:
- Next.js App Router
- Client-side auth context for state management
- Shadcn/UI components
- TypeScript for type safety
-
Completed:
- User authentication (email/username login)
- Profile management
- Basic routing
- Auth context setup
- Database schema design
- RLS policies
-
Next Steps:
- Channel implementation
- Real-time messaging
- Direct messages
- File attachments
- Emoji reactions
-
Auth Flow:
- AuthProvider in lib/auth-context.tsx manages auth state
- Profile data merged with auth data in user state
- Username login requires user_emails view lookup
-
Database Access:
- RLS policies control data access
- user_profiles table extends auth.users functionality
- Joins handled through UUID relationships
-
Security Considerations:
- RLS policies on all tables
- Secure email access through view
- Profile updates restricted to own user
- auth.users table cannot be modified (Supabase managed)
- Profile updates require separate table from auth data
- Username login requires additional lookup step
-
Required Services:
- Supabase project with Auth enabled
- Database with RLS policies
- Required tables and views created
-
Environment Variables:
- NEXT_PUBLIC_SUPABASE_URL
- NEXT_PUBLIC_SUPABASE_ANON_KEY
-
Profile Data Persistence:
- Ensure profile fetch after auth state changes
- Merge profile data with user metadata
-
Username Login:
- Requires user_emails view
- Two-step lookup process (username -> email -> auth)
-
Profile Updates:
- Must update user_profiles table
- Verify RLS policies allow updates
- Username login produces 400 error in console but successfully completes login
- Error occurs when signing in with username in
auth-context.tsx
- Login still succeeds despite the error
- Low priority - functionality works but needs cleanup
- Related to
user_emails
view and auth flow
- Error occurs when signing in with username in
- Implement channel functionality in chat area
- Priority over fixing auth console error