# 21. Real API Client Verification & Wire-up meta: id: android-production-21 feature: android-production priority: P1 depends_on: [] tags: [backend, api, production] objective: - Verify and complete the real API client integration, ensuring all endpoints are wired correctly to the production backend deliverables: - API endpoint verification report - AuthRepository using real API - Error handling and retry logic - Environment-based configuration steps: 1. Audit current API integration: - Review android/app/.../data/remote/TRPCApiService.kt - Review all repository implementations - Check AuthRepositoryImpl - Identify any stubbed or mock implementations 2. Verify all endpoints: - Compare TRPCApiService methods with backend routers - Ensure all mobile-needed endpoints are implemented - Verify request/response models match backend schemas - Test each endpoint against staging backend 3. Implement missing endpoints: - Add any missing tRPC procedures - Update request/response models - Add error handling for new endpoints 4. Configure environment: - Debug builds → staging API (10.0.2.2 or staging URL) - Release builds → production API - Use BuildConfig.API_BASE_URL correctly - Add build variant configuration 5. Add error handling: - Map tRPC error codes to user-friendly messages - Handle network errors (timeout, no connection) - Handle 401/403 authentication errors - Handle 500 server errors - Add retry logic with exponential backoff 6. Add logging: - Log API requests in debug builds - Log errors in all builds - Sanitize logs (no tokens, no PII) 7. Test integration: - Test auth flow end-to-end - Test dashboard data loading - Test all service screens - Test offline behavior tests: - Unit: Test API service with MockWebServer - Integration: Test against staging backend - E2E: Complete critical flows on physical device acceptance_criteria: - All TRPC endpoints verified against backend - AuthRepository using real API (no stubs) - All repositories wired to real API service - Debug builds use staging API - Release builds use production API - Error handling for all error types - Retry logic with exponential backoff - Request logging in debug builds - No PII in logs - Unit tests with MockWebServer - Integration tests passing against staging validation: - Build debug → login to staging → success - Build release → login to production → success - Run unit tests → all pass with mocks - Check logs → no sensitive data exposed - Test all screens → data loads correctly notes: - TRPCApiService.kt exists but verify all endpoints are correct - Some endpoints may have changed during development - MockWebServer is already in test dependencies - Coordinate with backend team on any API changes