Files
Sage/.planning/phases/01-authentication/01-02-PLAN.md
Dani B f9150e04d5 docs(01): create phase 1 authentication plans
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
2026-01-28 00:26:56 -05:00

136 lines
5.1 KiB
Markdown

---
phase: 01-authentication
plan: 02
type: execute
wave: 1
depends_on: []
files_modified: ["lib/features/authentication/data/models/auth_user.dart", "lib/core/errors/auth_exceptions.dart", "lib/features/authentication/domain/repositories/auth_repository.dart"]
autonomous: true
user_setup: []
must_haves:
truths:
- "Auth model represents user data consistently"
- "Auth exceptions provide clear error messages"
- "Auth repository defines interface for auth operations"
artifacts:
- path: "lib/features/authentication/data/models/auth_user.dart"
provides: "User data model"
min_lines: 15
- path: "lib/core/errors/auth_exceptions.dart"
provides: "Custom auth error handling"
min_lines: 20
- path: "lib/features/authentication/domain/repositories/auth_repository.dart"
provides: "Auth operations interface"
min_lines: 25
key_links:
- from: "lib/features/authentication/domain/repositories/auth_repository.dart"
to: "lib/features/authentication/data/models/auth_user.dart"
via: "method signatures"
pattern: "Future<AuthUser>|AuthUser"
- from: "lib/core/errors/auth_exceptions.dart"
to: "lib/features/authentication/domain/repositories/auth_repository.dart"
via: "exception handling"
pattern: "throws.*Exception"
---
<objective>
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.
</objective>
<execution_context>
@~/.opencode/get-shit-done/workflows/execute-plan.md
@~/.opencode/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/01-authentication/01-RESEARCH.md
</context>
<tasks>
<task type="auto">
<name>Create AuthUser model</name>
<files>lib/features/authentication/data/models/auth_user.dart</files>
<action>
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
</action>
<verify>AuthUser model compiles without errors and properly handles Supabase User conversion</verify>
<done>AuthUser model provides clean abstraction over Supabase User with necessary fields</done>
</task>
<task type="auto">
<name>Create custom auth exceptions</name>
<files>lib/core/errors/auth_exceptions.dart</files>
<action>
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
</action>
<verify>Custom exceptions compile and provide meaningful error messages for different auth scenarios</verify>
<done>Comprehensive error handling system that maps Supabase errors to user-friendly messages</done>
</task>
<task type="auto">
<name>Create AuthRepository interface</name>
<files>lib/features/authentication/domain/repositories/auth_repository.dart</files>
<action>
Create abstract AuthRepository class that:
1. Defines interface for all auth operations:
- Future<AuthUser> signUp(String email, String password)
- Future<AuthUser> signIn(String email, String password)
- Future<void> signOut()
- Future<void> resetPassword(String email)
- Future<AuthUser?> getCurrentUser()
- Stream<AuthUser?> 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
</action>
<verify>AuthRepository interface compiles without implementation and clearly defines all required auth methods</verify>
<done>Clean interface that abstracts authentication operations from Supabase implementation</done>
</task>
</tasks>
<verification>
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
</verification>
<success_criteria>
Authentication domain foundation is established with proper models, error handling, and repository interface ready for implementation.
</success_criteria>
<output>
After completion, create `.planning/phases/01-authentication/01-02-SUMMARY.md`
</output>