# _MAP: MOB-001 - Mobile Foundation **Modulo:** MOB-001 **Nombre:** Mobile App Foundation **Fase:** 03 - Mobile **Story Points:** 31 SP (MOB-001: 13 + MOB-002: 8 + MOB-003: 5 + TEST-010: 5) **Estado:** COMPLETADO **Ultima actualizacion:** 2026-01-07 --- ## Resumen Aplicacion movil para ERP Core construida con Expo/React Native. Incluye autenticacion, navegacion, funcionalidades offline, notificaciones push, escaneo de codigos de barras/QR y autenticacion biometrica. --- ## Metricas | Metrica | Valor | |---------|-------| | Story Points | 31 SP | | Archivos creados | 30+ | | Screens | 6 (Home, Partners, Scanner, Products, Invoices, Settings) | | Auth Screens | 2 (Login, Forgot Password) | | Services | 5 (api, offline, notifications, barcode, biometrics) | | Hooks | 4 (useOfflineQuery, useNotifications, useBarcode, useBiometrics) | | Components | 1 (BarcodeScanner) | | Tests | 57+ | --- ## Estructura del Modulo ``` mobile/ ├── app/ # Expo Router screens │ ├── _layout.tsx # Root layout con auth flow │ ├── (auth)/ # Auth screens │ │ ├── _layout.tsx # Auth stack layout │ │ ├── login.tsx # Login screen │ │ └── forgot-password.tsx │ └── (tabs)/ # Main tab screens │ ├── _layout.tsx # Tab navigation (6 tabs) │ ├── index.tsx # Home/Dashboard │ ├── partners.tsx # Partners list │ ├── scanner.tsx # Barcode scanner │ ├── products.tsx # Products list │ ├── invoices.tsx # Invoices list │ └── settings.tsx # User settings ├── src/ │ ├── __tests__/ # Unit tests │ │ ├── auth.store.test.ts │ │ ├── offline.service.test.ts │ │ └── biometrics.service.test.ts │ ├── components/ # Shared components │ │ ├── index.ts │ │ └── BarcodeScanner.tsx │ ├── hooks/ # Custom hooks │ │ ├── index.ts │ │ ├── useOfflineQuery.ts │ │ ├── useNotifications.ts │ │ ├── useBarcode.ts │ │ └── useBiometrics.ts │ ├── services/ # API y servicios │ │ ├── index.ts │ │ ├── api.ts # Axios client │ │ ├── offline.ts # Offline sync │ │ ├── notifications.ts # Push notifications │ │ ├── barcode.ts # Barcode scanning │ │ └── biometrics.ts # Face ID/Touch ID │ ├── stores/ # Zustand stores │ │ ├── index.ts │ │ └── auth.store.ts │ └── types/ # TypeScript types │ └── index.ts ├── jest.config.js # Jest configuration ├── jest.setup.js # Test setup with mocks ├── package.json ├── app.json └── tsconfig.json ``` --- ## Tareas Completadas ### MOB-001: Foundation (13 SP) | Componente | Descripcion | Estado | |------------|-------------|--------| | Expo Setup | package.json, app.json, tsconfig.json | Completado | | Auth Store | Zustand store para autenticacion | Completado | | API Client | Axios con interceptors y auto-refresh | Completado | | Auth Screens | Login, Forgot Password | Completado | | Tab Screens | Home, Partners, Products, Invoices, Settings | Completado | | Navigation | Expo Router file-based | Completado | | Types | User, Partner, Product, Invoice, etc. | Completado | ### MOB-002: Extended Features (8 SP) | Feature | Descripcion | Estado | |---------|-------------|--------| | Offline Sync | AsyncStorage cache, NetInfo, sync queue | Completado | | Push Notifications | expo-notifications, Android channels | Completado | | Camera/QR Scanner | expo-camera, EAN/UPC validation | Completado | | Biometrics | Face ID/Touch ID/Fingerprint | Completado | ### MOB-003: Scanner Screen (5 SP) | Componente | Descripcion | Estado | |------------|-------------|--------| | Scanner Screen | Pantalla dedicada para escaneo | Completado | | Product Lookup | Busqueda de producto por codigo | Completado | | Scan History | Historial de ultimos 20 escaneos | Completado | | Actions | Agregar a inventario/pedido | Completado | ### TEST-010: Mobile Unit Tests (5 SP) | Test File | Tests | Cobertura | |-----------|------:|-----------| | auth.store.test.ts | 12 | login, logout, loadStoredAuth, setUser | | offline.service.test.ts | 25+ | store, cache, network monitor, sync manager | | biometrics.service.test.ts | 20+ | capabilities, authenticate, enable/disable | | **TOTAL** | **57+** | | --- ## Dependencias Expo | Paquete | Version | Uso | |---------|---------|-----| | expo | ~51.0.0 | Framework base | | expo-router | ~3.5.0 | File-based navigation | | expo-secure-store | ~13.0.1 | Token storage | | expo-camera | ~15.0.14 | Barcode scanning | | expo-barcode-scanner | ~13.0.1 | Barcode types | | expo-notifications | ~0.28.16 | Push notifications | | expo-local-authentication | ~14.0.1 | Biometrics | | expo-haptics | ~13.0.1 | Haptic feedback | | @react-native-async-storage/async-storage | 1.23.1 | Offline cache | | @react-native-community/netinfo | 11.3.1 | Network monitoring | | zustand | ^5.0.1 | State management | | axios | ^1.7.7 | HTTP client | | zod | ^3.23.8 | Validation | --- ## Dependencias de Otros Modulos **Depende de:** - MGN-001 (Auth) - Endpoints de autenticacion - Backend API - Todos los endpoints REST **Requerido por:** - Usuarios moviles del ERP --- ## API Endpoints Consumidos | Metodo | Endpoint | Descripcion | |--------|----------|-------------| | POST | /auth/login | Inicio de sesion | | POST | /auth/logout | Cierre de sesion | | GET | /auth/profile | Perfil del usuario | | POST | /auth/forgot-password | Recuperacion de password | | GET | /partners | Lista de partners | | GET | /products | Lista de productos | | GET | /products?barcode={code} | Buscar por codigo | | GET | /invoices | Lista de facturas | --- ## Features Detalladas ### Offline Sync ```typescript // Store para estado offline useOfflineStore: { isOnline: boolean; syncQueue: SyncAction[]; isSyncing: boolean; lastSyncAt: number | null; } // Hooks disponibles useOfflineQuery(key, fetcher, options) // Fetch con cache useOfflineMutation(mutator, options) // Mutacion offline-capable ``` ### Push Notifications ```typescript // Android channels configurados - default: Notificaciones generales - alerts: Alertas importantes (high priority) - sync: Sincronizacion (low priority) // Hooks disponibles useNotifications() // Gestion de notificaciones ``` ### Barcode Scanner ```typescript // Formatos soportados - EAN-13, EAN-8, UPC-A, UPC-E - Code128, Code39 - QR Code // Hooks disponibles useBarcode() // Escaneo y validacion ``` ### Biometrics ```typescript // Tipos soportados - Face ID (iOS) - Touch ID (iOS) - Fingerprint (Android) - Iris (Android) // Hooks disponibles useBiometrics() // Autenticacion biometrica ``` --- ## Testing ### Jest Configuration ```javascript // jest.config.js module.exports = { preset: 'jest-expo', setupFilesAfterEnv: ['/jest.setup.js'], moduleNameMapper: { '^@/(.*)$': '/src/$1', }, }; ``` ### Mocked Modules - expo-secure-store - @react-native-async-storage/async-storage - @react-native-community/netinfo - expo-notifications - expo-local-authentication - expo-camera - expo-haptics - expo-device --- ## Proximos Pasos | ID | Descripcion | SP | Prioridad | |----|-------------|----|-----------| | MOB-004 | Detox E2E Tests | 5 | Baja | | MOB-005 | Orders/Sales Module | 8 | Baja | | MOB-006 | Offline-first CRUD | 5 | Baja | --- **Actualizado por:** Mobile-Agent (Claude Opus 4.5) **Fecha:** 2026-01-07 **Tareas:** MOB-001, MOB-002, MOB-003, TEST-010 COMPLETADAS