Phase 1: Authentication & Account Basics
- 7 plans in 4 waves
- Covers AUTH-01 through AUTH-05 requirements
- Foundation for household features in Phase 2
- Ready for execution
Create authentication data models, error handling system, and repository interface.
Purpose: Establish clean architecture foundations that separate concerns and provide type safety for authentication operations.
Output: Domain models, custom exceptions, and repository interface that abstract Supabase implementation details.
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/01-authentication/01-RESEARCH.md
Create AuthUser model
lib/features/authentication/data/models/auth_user.dart
Create AuthUser data class that:
1. Extends or wraps Supabase User model for flexibility
2. Contains essential user fields (id, email, created_at, email_verified)
3. Includes fromSupabase() factory constructor
4. Includes copyWith() method for immutability
5. Includes toString() for debugging
6. Follows clean architecture pattern (data layer)
7. Has proper null safety handling
AuthUser model compiles without errors and properly handles Supabase User conversion
AuthUser model provides clean abstraction over Supabase User with necessary fields
Create custom auth exceptions
lib/core/errors/auth_exceptions.dart
Create custom exception classes that:
1. Extend Exception base class
2. Include specific auth error types:
- AuthException (base)
- InvalidCredentialsException
- UserNotFoundException
- WeakPasswordException
- EmailAlreadyInUseException
- NetworkException
- SessionExpiredException
3. Each exception has user-friendly message field
4. Include fromSupabaseError() factory for converting Supabase errors
5. Follow consistent error code patterns
6. Include proper documentation
Custom exceptions compile and provide meaningful error messages for different auth scenarios
Comprehensive error handling system that maps Supabase errors to user-friendly messages
Create AuthRepository interface
lib/features/authentication/domain/repositories/auth_repository.dart
Create abstract AuthRepository class that:
1. Defines interface for all auth operations:
- Future signUp(String email, String password)
- Future signIn(String email, String password)
- Future signOut()
- Future resetPassword(String email)
- Future getCurrentUser()
- Stream authStateChanges()
2. Returns custom exceptions for error cases
3. Follows clean architecture (domain layer)
4. Has comprehensive documentation
5. Uses proper async/await patterns
6. Includes null safety throughout
AuthRepository interface compiles without implementation and clearly defines all required auth methods
Clean interface that abstracts authentication operations from Supabase implementation
1. All models and interfaces compile without errors
2. Type safety is maintained throughout (no 'any' types)
3. Error handling covers all major auth scenarios
4. Clean architecture layers are properly separated
5. Documentation is comprehensive for future implementers
<success_criteria>
Authentication domain foundation is established with proper models, error handling, and repository interface ready for implementation.
</success_criteria>
After completion, create `.planning/phases/01-authentication/01-02-SUMMARY.md`