Skip to content

Latest commit

 

History

History
97 lines (77 loc) · 2.76 KB

context_record.md

File metadata and controls

97 lines (77 loc) · 2.76 KB

Project Context Record

Project Overview

Leeway - A real-time chat application built with Next.js, Supabase, and TypeScript

Key Technical Decisions

  1. 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
  2. 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
  3. Frontend Architecture:

    • Next.js App Router
    • Client-side auth context for state management
    • Shadcn/UI components
    • TypeScript for type safety

Current Implementation Status

  1. Completed:

    • User authentication (email/username login)
    • Profile management
    • Basic routing
    • Auth context setup
    • Database schema design
    • RLS policies
  2. Next Steps:

    • Channel implementation
    • Real-time messaging
    • Direct messages
    • File attachments
    • Emoji reactions

Critical Implementation Details

  1. 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
  2. Database Access:

    • RLS policies control data access
    • user_profiles table extends auth.users functionality
    • Joins handled through UUID relationships
  3. Security Considerations:

    • RLS policies on all tables
    • Secure email access through view
    • Profile updates restricted to own user

Known Limitations/Constraints

  1. auth.users table cannot be modified (Supabase managed)
  2. Profile updates require separate table from auth data
  3. Username login requires additional lookup step

Development Environment

  1. Required Services:

    • Supabase project with Auth enabled
    • Database with RLS policies
    • Required tables and views created
  2. Environment Variables:

    • NEXT_PUBLIC_SUPABASE_URL
    • NEXT_PUBLIC_SUPABASE_ANON_KEY

Common Issues/Solutions

  1. Profile Data Persistence:

    • Ensure profile fetch after auth state changes
    • Merge profile data with user metadata
  2. Username Login:

    • Requires user_emails view
    • Two-step lookup process (username -> email -> auth)
  3. Profile Updates:

    • Must update user_profiles table
    • Verify RLS policies allow updates

Known Issues

Auth

  • 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

Next Steps

Channels

  • Implement channel functionality in chat area
  • Priority over fixing auth console error