# Plan B Logistics Flutter App - Implementation Checklist

## Core Architecture & Setup

- [x] CQRS API client with Result<T> pattern
- [x] Strict typing (no `dynamic` or untyped `var`)
- [x] Serializable interface for all models
- [x] Error handling with ApiError types
- [x] HTTP client configuration
- [x] API base URLs (query and command endpoints)
- [x] Riverpod state management setup
- [x] Provider architecture
- [x] Responsive utilities and breakpoints
- [x] Theme configuration (Svrnty design system)
- [x] Material Design 3 implementation
- [x] Dark and light themes

## Authentication & Authorization

- [x] Password Credentials OAuth2 flow with Keycloak
- [x] Username/password login form
- [x] JWT token management
- [x] Secure token storage (flutter_secure_storage)
- [x] Token validation and expiration checking
- [x] User profile decoding from JWT
- [x] Authentication guard in main.dart
- [x] Login page UI with form validation
- [ ] Automatic token refresh on expiration
- [ ] Handle 401 responses with token refresh retry
- [ ] Implement logout with token revocation

## Data Models

- [x] Delivery model
- [x] DeliveryRoute model (updated to match API)
- [x] DeliveryAddress model
- [x] DeliveryContact model
- [x] DeliveryOrder model
- [x] UserInfo model
- [x] UserProfile model
- [x] Command models (CompleteDelivery, MarkAsUncompleted, etc.)
- [x] Query models with Serializable
- [x] All models implement fromJson/toJson

## API Integration

- [x] Remove mock data from providers
- [x] Get delivery routes endpoint
- [x] Get deliveries by route endpoint
- [x] Complete delivery command endpoint
- [x] Mark delivery as uncompleted endpoint
- [x] Bearer token injection in API requests
- [x] Query parameter serialization
- [ ] Upload delivery picture endpoint
- [ ] Skip delivery command endpoint
- [ ] Implement pagination for routes
- [ ] Implement pagination for deliveries
- [ ] Add pull-to-refresh functionality
- [ ] Implement retry logic for failed requests

## Pages & UI Components

### Completed Pages
- [x] Login page with username/password
- [x] Routes page (list/grid view)
- [x] Deliveries page (To Do/Delivered segments)
- [x] Settings page

### Pending Pages
- [ ] Delivery details page
- [ ] Photo capture/upload page
- [ ] Error pages (network error, not found, etc.)

### UI Components
- [x] Route card with progress indicator
- [x] Delivery card with status chips
- [x] Bottom sheet for delivery actions
- [x] User profile menu
- [x] Language selector
- [x] Responsive grid/list layouts
- [ ] Extract reusable components to lib/components/
- [ ] Create DeliveryCard component
- [ ] Create RouteCard component
- [ ] Create CustomAppBar component
- [ ] Create LoadingIndicator component
- [ ] Create ErrorView component
- [ ] Create EmptyStateView component

## Features

### Completed Features
- [x] Phone call integration (url_launcher)
- [x] Maps/navigation integration (Google Maps)
- [x] Mark delivery as completed
- [x] Mark delivery as uncompleted
- [x] Language switching (EN/FR)
- [x] Responsive design (mobile/tablet/desktop)
- [x] Pull-to-refresh on routes page

### Pending Features
- [ ] Photo upload for delivery proof
- [ ] Skip delivery with reason
- [ ] View delivery photos
- [ ] Delivery history/timeline
- [ ] Offline mode support
- [ ] Cache management
- [ ] Push notifications
- [ ] Delivery signatures
- [ ] Barcode/QR code scanning

## Internationalization (i18n)

- [x] ARB files setup (English and French)
- [x] 68+ translation keys defined
- [x] Parameterized strings support
- [x] Language provider in state management
- [ ] Replace ALL hardcoded strings in UI with translations
  - [ ] Login page strings
  - [ ] Routes page strings
  - [ ] Deliveries page strings
  - [ ] Settings page strings
  - [ ] Error messages
  - [ ] Button labels
  - [ ] Form validation messages
- [ ] Test language switching in all screens

## Error Handling & UX

- [x] Basic error display with SnackBar
- [x] Loading states in providers
- [ ] Comprehensive error handling UI
- [ ] Specific error messages for different ApiErrorType
- [ ] Network connectivity detection
- [ ] Offline mode indicators
- [ ] Retry strategies with exponential backoff
- [ ] Error recovery flows
- [ ] User-friendly error messages
- [ ] Toast notifications for success/error

## Routing & Navigation

- [x] Basic Navigator.push navigation
- [x] Route parameters passing
- [ ] Configure GoRouter
- [ ] Named routes
- [ ] Deep linking support
- [ ] Route guards for authentication
- [ ] Handle back navigation properly
- [ ] Navigation animations/transitions

## Native Features

- [x] Phone calls with url_launcher
- [x] Maps integration with url_launcher
- [ ] Camera access with image_picker
- [ ] Photo gallery access
- [ ] File system access for photos
- [ ] Location services
- [ ] Background location tracking
- [ ] Local notifications

## Testing

- [ ] Unit tests for AuthService
- [ ] Unit tests for CqrsApiClient
- [ ] Unit tests for data models
- [ ] Provider tests with ProviderContainer
- [ ] Widget tests for LoginPage
- [ ] Widget tests for RoutesPage
- [ ] Widget tests for DeliveriesPage
- [ ] Widget tests for SettingsPage
- [ ] Integration tests for auth flow
- [ ] Integration tests for delivery flow
- [ ] Golden tests for UI components
- [ ] Achieve >80% code coverage

## Build Configuration

- [ ] Set up build flavors (dev, staging, prod)
- [ ] Environment-specific configurations
- [ ] API URL configuration per environment
- [ ] App signing for iOS
- [ ] App signing for Android
- [ ] Build scripts for CI/CD
- [ ] Icon and splash screen configuration
- [ ] Version management
- [ ] Build number automation

## Performance Optimization

- [ ] Image caching (cached_network_image)
- [ ] List virtualization optimizations
- [ ] Lazy loading for deliveries
- [ ] Pagination implementation
- [ ] Memory leak detection
- [ ] App size optimization
- [ ] Startup time optimization
- [ ] Frame rate monitoring

## Documentation

- [x] CLAUDE.md project instructions
- [x] README.md with project overview
- [ ] API documentation
- [ ] Component documentation
- [ ] Architecture documentation
- [ ] Deployment guide
- [ ] User manual
- [ ] Developer onboarding guide

## Security

- [x] Secure token storage
- [x] No hardcoded secrets in code (client_secret removed)
- [x] Public client configuration (no client secret in frontend)
- [ ] Certificate pinning
- [ ] Encryption for sensitive data
- [ ] Obfuscation for production builds
- [ ] Security audit
- [ ] Penetration testing
- [ ] OWASP compliance check

## Deployment

- [ ] iOS App Store submission
- [ ] Android Play Store submission
- [ ] Internal testing distribution
- [ ] Beta testing program
- [ ] Production release
- [ ] Crash reporting (Sentry, Firebase Crashlytics)
- [ ] Analytics integration (Firebase Analytics)
- [ ] Remote configuration

## Known Issues to Fix

- [ ] Fix macOS secure storage error (-34018)
- [ ] Update AppAuth deployment target (10.12 -> 10.13)
- [ ] Handle "Failed to foreground app" warning
- [ ] Add proper error boundaries
- [ ] Fix any linter warnings

## Production Blockers (Critical)

- [x] ~~Authentication disabled~~ (FIXED)
- [x] ~~Using mock data~~ (FIXED)
- [ ] Photo upload not implemented
- [ ] Limited error handling
- [ ] No tests written
- [ ] Hardcoded strings instead of i18n
- [ ] No offline support

## Priority Levels

### HIGH PRIORITY (Must have for v1.0)
1. Replace hardcoded strings with i18n translations
2. Implement photo upload feature
3. Create delivery details page
4. Add comprehensive error handling
5. Write critical unit and widget tests
6. Implement automatic token refresh
7. Add skip delivery feature

### MEDIUM PRIORITY (Should have for v1.0)
1. Configure GoRouter with named routes
2. Extract reusable components
3. Implement pagination
4. Add offline mode indicators
5. Set up build flavors
6. Add image caching

### LOW PRIORITY (Nice to have for v1.0)
1. Performance optimizations
2. Golden tests
3. Enhanced animations
4. Advanced features (signatures, barcodes)
5. Push notifications

## Version History

### v0.1.0 (Current)
- Core architecture implemented
- Real API integration completed
- Authentication with Keycloak working
- Basic UI for routes and deliveries
- Phone and maps integration

### v1.0.0 (Target)
- All production blockers resolved
- Complete i18n implementation
- Photo upload working
- Comprehensive error handling
- Test coverage >80%
- Ready for App Store/Play Store submission
