Repository navigation
Closed
Description
Feature: Backend User Preferences Integration
Overview
Update existing composables and create new infrastructure to handle authenticated vs guest user states for preferences, ensuring seamless data management across user authentication states.
Parent Issue
Part of #37 - Add Settings Page with Authentication and User Management
Current Status
- ✅ Authentication system fully implemented
- ✅ Composables exist for preferences (currency, categories)
- ❌ Composables don't differentiate between guest vs authenticated users
- ❌ No data migration system for guest → authenticated transition
- ❌ No unified preferences management system
Requirements
Composable Updates
- Update
useCurrency.tsto handle auth vs guest states - Update
useCategoryStore.tsfor user-specific categories - Create
useUserPreferences.tsas central preferences manager - Implement preference loading priority system
- Add preference synchronization capabilities
Authentication State Handling
- Detect authentication state changes
- Trigger preference loading on sign-in
- Handle preference cleanup on sign-out
- Manage preference conflicts during auth transitions
Data Migration System
- Create guest → authenticated user data migration
- Handle preference conflicts (guest vs server data)
- Implement user choice for conflicting preferences
- Ensure data integrity during migration
Preference Management
- Centralized preference loading/saving
- Cache management for performance
- Offline/online state handling
- Preference validation and error handling
Technical Architecture
New Composable: useUserPreferences.ts
interface UserPreferences {
currency: CurrencyConfig
categories: Category[]
// Future: theme, notifications, etc.
}
// Functions:
- loadUserPreferences()
- saveUserPreferences()
- migrateGuestPreferences()
- handleAuthStateChange()Updated Composables
- useCurrency.ts: Integrate with user preferences system
- useCategoryStore.ts: Support user-specific categories
- useAuth.ts: Trigger preference loading on auth changes
Data Flow
App Startup → Check Auth State → Load Preferences
Guest → localStorage
Authenticated → Database + localStorage cache
Auth State Change → Migrate Data → Update UI
Implementation Details
Preference Loading Priority
- Database (authenticated users)
- localStorage cache (performance optimization)
- Default values (fallback)
Migration Strategy
Sign In:
1. Load current localStorage preferences
2. Load database preferences
3. Merge/conflict resolution
4. Save merged preferences to database
5. Update UI state
Sign Out:
1. Clear user-specific data
2. Reset to default/guest preferences
3. Clean up cache
Acceptance Criteria
- Composables properly handle authenticated vs guest users
- Preferences load automatically on authentication changes
- Guest preferences migrate smoothly to authenticated accounts
- No data loss during authentication transitions
- Performance optimized with proper caching
- Robust error handling for all preference operations
- Clean separation between guest and user data
Technical Considerations
- Implement proper TypeScript types for all preference data
- Handle race conditions during rapid auth state changes
- Ensure proper cleanup to prevent memory leaks
- Consider preference versioning for future schema changes
- Implement comprehensive error recovery mechanisms
Priority
Medium - Foundation for other preference features
Dependencies
- Database schema for user_preferences table
- Currency preference storage implementation
- Category management system
Related Issues
- Add Settings Page with Authentication and User Management #37 - Parent issue for Settings page
- Implement Currency Preference Database Storage #41 - Currency Preference Database Storage
- Implement Category Management System #40 - Category Management System
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat: implement user preferences system with database integration
feat: Add Settings page with authentication UI and improved components (
laminko commentedon Jun 23, 2025
✅ Issue Completed Successfully
Backend user preferences integration has been fully implemented with comprehensive guest/authenticated user state management:
🔄 User Preferences Integration Features:
📁 Key Implementation Files:
🎯 Core Requirements Met:
🔧 Technical Implementation:
🌟 Advanced Features:
🔗 Related Issues:
The user preferences system now provides seamless integration between guest and authenticated states with complete data preservation.
🤖 Generated with Claude Code
Release: Major authentication and user management features (#50)
Release v1.3.0: Facebook OAuth UI removal and version bump (#51)