# ═══════════════════════════════════════════════════════════════════════════════
# FRONTEND_INVENTORY.yml - Trading Platform
# ═══════════════════════════════════════════════════════════════════════════════

version: "2.0.0"
fecha_actualizacion: "2026-01-26"
proyecto: "trading-platform"
fuente_auditoria: "orchestration/tareas/TASK-2026-01-25-002-FRONTEND-COMPREHENSIVE-AUDIT"

# ═══════════════════════════════════════════════════════════════════════════════
# RESUMEN
# ═══════════════════════════════════════════════════════════════════════════════

resumen:
  total_paginas: 32
  total_componentes: 146  # 103 reusables + 32 páginas + 4 OQI-005 + 3 OQI-006 + 4 OQI-007
  total_stores: 9  # authStore, tradingStore, mlStore, educationStore, paymentsStore, portfolioStore, investmentStore, llmStore, mt4Store
  total_services: 16  # +1 video-upload.service.ts (ST4.3.5)
  total_hooks: 30+  # useAuth, useTradingData, useVideoPlayer, etc.
  total_tests_e2e: 1  # payments-stripe-elements.test.tsx (20+ cases, ST4.2.3)
  ubicacion: "apps/frontend/src/"
  framework: "React 18.2.0"
  build_tool: "Vite 6.2.0"
  lenguaje: "TypeScript 5.3.3"
  progreso_promedio: "38%"
  componentes_funcionales: "97/123 (79%)"
  fecha_actualizacion: "2026-01-25"
  auditoria_completa: "2026-01-25"

# ═══════════════════════════════════════════════════════════════════════════════
# PAGINAS POR MODULO
# ═══════════════════════════════════════════════════════════════════════════════

paginas:

  auth:
    cantidad: 6
    lista:
      - Login.tsx
      - Register.tsx
      - ForgotPassword.tsx
      - VerifyEmail.tsx
      - ResetPassword.tsx
      - AuthCallback.tsx

  dashboard:
    cantidad: 1
    lista:
      - Dashboard.tsx

  trading:
    cantidad: 1
    lista:
      - Trading.tsx

  ml:
    cantidad: 1
    lista:
      - MLDashboard.tsx

  backtesting:
    cantidad: 1
    lista:
      - BacktestingDashboard.tsx

  investment:
    cantidad: 8
    lista:
      - Investment.tsx
      - Portfolio.tsx
      - Products.tsx
      - ProductDetail.tsx       # Product detail with performance chart (2026-01-25)
      - AccountDetail.tsx       # Account detail with transactions and distributions (2026-01-25)
      - Withdrawals.tsx         # Global withdrawals list (2026-01-25)
      - Transactions.tsx        # Global transactions history (2026-01-25)
      - Reports.tsx             # Analytics and reports (2026-01-25)

  education:
    cantidad: 6
    lista:
      - Courses.tsx
      - CourseDetail.tsx
      - MyLearning.tsx
      - Leaderboard.tsx
      - Lesson.tsx
      - Quiz.tsx

  payments:
    cantidad: 2
    lista:
      - Pricing.tsx
      - Billing.tsx

  admin:
    cantidad: 4
    lista:
      - AdminDashboard.tsx
      - MLModelsPage.tsx
      - AgentsPage.tsx
      - PredictionsPage.tsx

  assistant:
    cantidad: 1
    lista:
      - Assistant.tsx

  settings:
    cantidad: 1
    lista:
      - Settings.tsx

  portfolio:
    cantidad: 4
    lista:
      - PortfolioDashboard.tsx
      - CreatePortfolio.tsx
      - CreateGoal.tsx
      - EditAllocations.tsx

# ═══════════════════════════════════════════════════════════════════════════════
# COMPONENTES
# ═══════════════════════════════════════════════════════════════════════════════

componentes:

  chat:
    cantidad: 4
    lista:
      - ChatInput.tsx
      - ChatMessage.tsx
      - ChatPanel.tsx
      - ChatWidget.tsx

  education:
    cantidad: 10  # +4 OQI-002 (VideoUploadForm, CreatorDashboard, CertificateGenerator, LiveStreamPlayer)
    lista:
      - AchievementBadge.tsx
      - CourseCard.tsx
      - LeaderboardTable.tsx
      - QuizQuestion.tsx
      - StreakCounter.tsx
      - XPProgress.tsx
      - VideoUploadForm.tsx           # Multi-step video upload with drag-drop, metadata (2026-01-25)
      - CreatorDashboard.tsx          # Creator stats, courses, activity feed (2026-01-25)
      - CertificateGenerator.tsx      # Certificate templates, PDF/PNG download (2026-01-25)
      - LiveStreamPlayer.tsx          # Live streaming with chat, reactions (2026-01-25)

  payments:
    cantidad: 8  # +4 OQI-005 (StripeElementsWrapper, InvoicePreview, RefundRequestModal, RefundList)
    lista:
      - PricingCard.tsx
      - SubscriptionCard.tsx
      - UsageProgress.tsx
      - WalletCard.tsx
      - StripeElementsWrapper.tsx     # Stripe Elements provider for PCI compliance (2026-01-25)
      - InvoicePreview.tsx            # Pre-checkout invoice preview (2026-01-25)
      - RefundRequestModal.tsx        # Modal for refund requests (2026-01-25)
      - RefundList.tsx                # Paginated refund history (2026-01-25)

  backtesting:
    cantidad: 5
    lista:
      - EquityCurveChart.tsx
      - PerformanceMetricsPanel.tsx
      - PredictionChart.tsx
      - StrategyComparisonChart.tsx
      - TradesTable.tsx

  admin:
    cantidad: 2
    lista:
      - AgentStatsCard.tsx
      - MLModelCard.tsx

  layout:
    cantidad: 2
    lista:
      - MainLayout.tsx
      - AuthLayout.tsx

# ═══════════════════════════════════════════════════════════════════════════════
# COMPONENTES POR MODULO (Detalle adicional)
# ═══════════════════════════════════════════════════════════════════════════════

componentes_modulos:
  trading:
    cantidad: 15
    lista:
      - TradingChart.tsx
      - OrderBook.tsx
      - OrderForm.tsx
      - PositionsPanel.tsx
      - TradeHistory.tsx
      - WatchlistPanel.tsx
      - SymbolSearch.tsx
      - TimeframeSelector.tsx
      - IndicatorPanel.tsx
      - AlertsPanel.tsx         # Price alerts management panel (2026-01-25)
      - TradingStatsPanel.tsx   # Trading statistics and metrics (2026-01-25)
      - OrderBookPanel.tsx      # Market depth order book (2026-01-25)
      - MarketDepth.tsx
      - QuickTrade.tsx
      - ChartToolbar.tsx

  ml:
    cantidad: 7
    lista:
      - AMDPhaseIndicator.tsx
      - PredictionCard.tsx
      - SignalsTimeline.tsx
      - ConfidenceMeter.tsx
      - ModelSelector.tsx
      - EnsemblePanel.tsx
      - ICTAnalysisPanel.tsx

  auth:
    cantidad: 4
    lista:
      - SocialLoginButtons.tsx
      - PhoneLoginForm.tsx
      - TwoFactorForm.tsx
      - PasswordStrengthMeter.tsx

  assistant:
    cantidad: 4
    lista:
      - ChatWindow.tsx
      - ChatMessage.tsx
      - ChatInput.tsx
      - SignalCard.tsx

  portfolio:
    cantidad: 5
    lista:
      - AllocationChart.tsx      # Donut chart de allocaciones
      - AllocationTable.tsx      # Tabla de posiciones
      - PerformanceChart.tsx     # Line chart de rendimiento (canvas)
      - RebalanceCard.tsx        # Card de recomendaciones
      - GoalCard.tsx             # Card de metas financieras

  investment:
    cantidad: 6  # +4 OQI-004 (CreateAccountWizard, RiskAnalysisPanel, PortfolioOptimizerWidget, AccountTransferModal)
    lista:
      - DepositForm.tsx               # Stripe deposit form with card input
      - WithdrawForm.tsx              # Withdrawal form with bank/crypto options
      - CreateAccountWizard.tsx       # Multi-step wizard for account creation (2026-01-25)
      - RiskAnalysisPanel.tsx         # Risk metrics display VaR, Sharpe, etc. (2026-01-25)
      - PortfolioOptimizerWidget.tsx  # Interactive portfolio optimizer (2026-01-25)
      - AccountTransferModal.tsx      # Modal for inter-account transfers (2026-01-25)

# ═══════════════════════════════════════════════════════════════════════════════
# STATE MANAGEMENT
# ═══════════════════════════════════════════════════════════════════════════════

stores:
  framework: "Zustand 4.4.7"
  lista:
    - auth.store.ts
    - trading.store.ts
    - dashboard.store.ts
    - app.store.ts
    - portfolioStore.ts          # Portfolio management con WebSocket (2026-01-25)

# ═══════════════════════════════════════════════════════════════════════════════
# SERVICES API
# ═══════════════════════════════════════════════════════════════════════════════

services:
  cantidad: 12
  lista:
    - auth.service.ts
    - trading.service.ts
    - ml.service.ts
    - education.service.ts
    - video-upload.service.ts    # Multipart video upload to S3/R2 (ST4.3.5 - 2026-01-26)
    - investment.service.ts      # Investment accounts, products, transactions API (2026-01-25)
    - payments.service.ts
    - admin.service.ts
    - assistant.service.ts
    - portfolio.service.ts
    - notification.service.ts
    - websocket.service.ts       # WebSocket connections (trading, ml, portfolio)

# ═══════════════════════════════════════════════════════════════════════════════
# HOOKS CUSTOM
# ═══════════════════════════════════════════════════════════════════════════════

hooks:
  cantidad: 3
  lista:
    - useAuth.ts
    - useTrading.ts
    - usePortfolioUpdates (websocket.service.ts)  # Real-time portfolio updates

# ═══════════════════════════════════════════════════════════════════════════════
# TESTS E2E
# ═══════════════════════════════════════════════════════════════════════════════

tests_e2e:
  framework: "Jest 30 + React Testing Library"
  ubicacion: "apps/frontend/src/__tests__/e2e/"
  cantidad: 1
  test_suites: 7
  test_cases: 20+
  archivos:
    - payments-stripe-elements.test.tsx:
        descripcion: "E2E tests for Stripe Elements integration (ST4.2.3)"
        lineas: 550
        fecha: "2026-01-26"
        suites:
          - "Stripe CardElement Rendering"
          - "Payment Intent Flow"
          - "Checkout Session Flow"
          - "Payment Method Attachment"
          - "Component State Validation"
          - "Error Handling"
          - "Security Best Practices"
        validaciones_criticas:
          - "CardElement renders as iframe (NOT native input)"
          - "NO card data in React state"
          - "NO card data sent to backend"
          - "confirmCardPayment called with clientSecret"
          - "NO sensitive data in console logs"
        pci_dss_compliance: true

# ═══════════════════════════════════════════════════════════════════════════════
# RUTAS
# ═══════════════════════════════════════════════════════════════════════════════

rutas:
  publicas:
    - /login
    - /register
    - /forgot-password
    - /verify-email
    - /auth/callback

  protegidas:
    - /dashboard
    - /trading
    - /ml-dashboard
    - /backtesting
    - /investment
    - /investment/portfolio
    - /investment/products
    - /investment/products/:productId
    - /investment/accounts/:accountId
    - /investment/withdrawals
    - /investment/transactions
    - /investment/reports
    - /portfolio
    - /portfolio/new
    - /portfolio/goals/new
    - /portfolio/:portfolioId/edit
    - /education/courses
    - /education/my-learning
    - /education/leaderboard
    - /pricing
    - /billing
    - /settings
    - /assistant

  admin:
    - /admin
    - /admin/models
    - /admin/agents
    - /admin/predictions

  fullscreen:
    - /education/courses/:courseSlug/lesson/:lessonId
    - /education/courses/:courseSlug/lesson/:lessonId/quiz

# ═══════════════════════════════════════════════════════════════════════════════
# LIBRERIAS
# ═══════════════════════════════════════════════════════════════════════════════

librerias:
  core:
    - "React Router v6"
    - "TanStack Query (React Query)"
    - "React Hook Form"
    - "Zod"
  ui:
    - "Tailwind CSS 3.4"
    - "Lucide React"
  charts:
    - "Recharts 3.5"
    - "Lightweight Charts 4.1"
  utilities:
    - "Axios"
    - "Date-fns"
  payments:
    - "Stripe"

# ═══════════════════════════════════════════════════════════════════════════════
# AUDITORIA COMPREHENSIVA (2026-01-25)
# ═══════════════════════════════════════════════════════════════════════════════

auditoria:
  fecha: "2026-01-25"
  tarea: "TASK-2026-01-25-002-FRONTEND-COMPREHENSIVE-AUDIT"
  metodologia: "CAPVED + 9 agentes paralelos"
  documentos_generados: 48
  total_lineas_analisis: 19117

  metricas_globales:
    total_componentes: 123
    total_paginas: 32
    total_componentes_reutilizables: 91
    total_apis: 113
    componentes_con_multimedia: 25  # ~20%
    completitud_promedio: "38%"
    componentes_100_funcionales: "97 (79%)"
    componentes_parciales: "15 (12%)"
    componentes_no_funcionales: "11 (9%)"

  progreso_por_epic:
    OQI-001:
      nombre: "Fundamentos Auth"
      componentes: 11
      progreso: "70%"
      gaps_criticos: 3  # P0-P1
      esfuerzo_pendiente: "140h"

    OQI-002:
      nombre: "Educativo"
      componentes: 18  # +4 (VideoUploadForm, CreatorDashboard, CertificateGenerator, LiveStreamPlayer)
      progreso: "40%"  # +10% por 4 componentes nuevos (2026-01-25)
      gaps_criticos: 2  # P1-P2 (video upload OK, live stream OK, falta integración backend)
      esfuerzo_pendiente: "200h"  # -80h por componentes creados
      componente_destacado: "VideoProgressPlayer (554 líneas, 11 states)"
      componentes_nuevos_2026_01_25:
        - VideoUploadForm.tsx (450 LOC)
        - CreatorDashboard.tsx (450 LOC)
        - CertificateGenerator.tsx (453 LOC)
        - LiveStreamPlayer.tsx (480 LOC)

    OQI-003:
      nombre: "Trading Charts"
      componentes: 37
      progreso: "40%"
      gaps_criticos: 8  # P0-P1
      esfuerzo_pendiente: "420h"
      hub_critico: "tradingStore (25 dependientes)"

    OQI-004:
      nombre: "Cuentas Inversión"
      componentes: 14  # +4 (CreateAccountWizard, RiskAnalysisPanel, PortfolioOptimizerWidget, AccountTransferModal)
      progreso: "55%"  # +20% por 4 componentes criticos nuevos (2026-01-25)
      gaps_criticos: 0  # P0 Account creation y P1 Risk/Optimizer ahora tienen UI
      esfuerzo_pendiente: "100h"  # -80h por componentes creados
      componentes_nuevos_2026_01_25:
        - CreateAccountWizard.tsx (620 LOC)
        - RiskAnalysisPanel.tsx (480 LOC)
        - PortfolioOptimizerWidget.tsx (520 LOC)
        - AccountTransferModal.tsx (450 LOC)

    OQI-005:
      nombre: "Pagos Stripe"
      componentes: 19  # +4 (StripeElementsWrapper, InvoicePreview, RefundRequestModal, RefundList)
      progreso: "65%"  # +15% por foundation PCI y refund components (2026-01-25)
      gaps_criticos: 2  # P0 PCI ahora tiene foundation, falta refactor PaymentMethodForm
      esfuerzo_pendiente: "120h"  # -80h por componentes creados
      componentes_nuevos_2026_01_25:
        - StripeElementsWrapper.tsx (220 LOC)
        - InvoicePreview.tsx (350 LOC)
        - RefundRequestModal.tsx (480 LOC)
        - RefundList.tsx (450 LOC)

    OQI-006:
      nombre: "ML Signals"
      componentes: 15  # +3 (ModelSelector, EnsemblePanel, ICTAnalysisPanel)
      progreso: "70%"  # +10% por utility panels completados (2026-01-26)
      gaps_criticos: 0  # Todos los gaps cerrados
      esfuerzo_pendiente: "100h"  # -40h por componentes creados
      componentes_nuevos_2026_01_26:
        - ModelSelector.tsx (280 LOC)
        - EnsemblePanel.tsx (320 LOC)
        - ICTAnalysisPanel.tsx (350 LOC)

    OQI-007:
      nombre: "LLM Strategy Agent"
      componentes: 22  # +4 (ErrorBoundary, ConnectionStatus, TokenUsageDisplay, PromptLibrary)
      progreso: "35%"  # +10% por componentes críticos completados (2026-01-26)
      gaps_criticos: 2  # Reducidos - WebSocket service y hooks pendientes
      esfuerzo_pendiente: "130h"  # -30h por componentes creados
      componentes_nuevos_2026_01_26:
        - ErrorBoundary.tsx (200 LOC)
        - ConnectionStatus.tsx (280 LOC)
        - TokenUsageDisplay.tsx (380 LOC)
        - PromptLibrary.tsx (350 LOC)

    OQI-008:
      nombre: "Portfolio Manager"
      componentes: 9
      progreso: "20%"
      gaps_criticos: 3  # P2-P3
      esfuerzo_pendiente: "220h"

    OQI-009:
      nombre: "MT4 Gateway"
      componentes: 3
      progreso: "15%"
      gaps_criticos: 1  # P0 BLOCKER (0% funcional)
      esfuerzo_pendiente: "180h"

  multimedia_handling:
    video:
      componentes: 2  # VideoProgressPlayer, Lesson
      formatos: "MP4, WebM"
      operaciones: "GET (streaming) ✅, POST (upload) ❌"
      estado: "70%"

    charts:
      componentes: 7
      tecnologias:
        - "lightweight-charts 4.1.1 (Canvas)"
        - "recharts 2.x (SVG)"
        - "Custom SVG (AllocationChart)"
        - "Custom Canvas 2D (PerformanceChart)"
      estado: "90%"

    images:
      componentes: 5
      formatos: "JPG, PNG"
      operaciones: "GET (carga) ✅, POST (upload) ❌"
      optimizaciones_pendientes:
        - "WebP support"
        - "Responsive images (srcset)"
        - "Lazy loading avanzado"
        - "CDN integration"
      estado: "60%"

    icons:
      total: "120+"
      librerias:
        - "Lucide React (~50 icons)"
        - "Heroicons (~30 icons)"
        - "Custom SVG (~40 icons)"
      bundle_impact: "~8 KB (gzip, tree-shaken)"
      estado: "100%"

    pdf:
      componentes: 2  # CertificatePreview, InvoiceDetail
      operaciones: "GET (preview/download) ⚠️, POST (generate) ❌"
      estado: "50%"

    audio:
      estado: "0% - NO IMPLEMENTADO"

  componentes_hub:  # Alto impacto (≥5 dependientes)
    - nombre: "authStore"
      dependientes: 40
      riesgo: "CRÍTICO"
      ubicacion: "stores/auth.store.ts"

    - nombre: "Button"
      dependientes: 35
      riesgo: "ALTO"
      ubicacion: "components/ui/Button.tsx"

    - nombre: "Card"
      dependientes: 30
      riesgo: "ALTO"
      ubicacion: "components/ui/Card.tsx"

    - nombre: "tradingStore"
      dependientes: 25
      riesgo: "ALTO"
      ubicacion: "stores/trading.store.ts"

    - nombre: "apiClient"
      dependientes: 90
      riesgo: "CRÍTICO"
      ubicacion: "lib/apiClient.ts"

    - nombre: "useAuth"
      dependientes: 30
      riesgo: "ALTO"
      ubicacion: "hooks/useAuth.ts"

    - nombre: "CandlestickChart"
      dependientes: 3
      riesgo: "MEDIO"
      ubicacion: "modules/trading/components/CandlestickChart.tsx"

  dependencias_cross_epic:
    total: 18
    criticas:
      - origen: "OQI-003"
        destino: "OQI-006"
        componente: "CandlestickChartWithML"
      - origen: "OQI-007"
        destino: "OQI-003"
        componente: "SignalExecutionPanel"
      - origen: "OQI-001"
        destino: "TODOS"
        componente: "authStore"

  gaps_documentacion:
    especificaciones_tecnicas_faltantes: 8  # ET-*
    user_stories_faltantes: 8  # US-*
    swagger_docs_faltantes: 34  # ~30% de 113 APIs
    module_readmes_faltantes: 8

  deuda_tecnica_critica:
    P0:
      - issue: "Manual token refresh"
        ubicacion: "authStore.ts:67"
        esfuerzo: "60h"
      - issue: "PCI-DSS non-compliant"
        ubicacion: "PaymentMethodForm.tsx"
        esfuerzo: "80h"
      - issue: "MT4 Gateway stub (0% funcional)"
        ubicacion: "modules/mt4/"
        esfuerzo: "180h"

    P1:
      - issue: "VideoProgressPlayer sin upload"
        ubicacion: "modules/education/"
        esfuerzo: "60h"
      - issue: "OrderBookPanel polling (no WebSocket)"
        ubicacion: "modules/trading/components/"
        esfuerzo: "40h"
      - issue: "Sin Error Boundaries"
        ubicacion: "apps/frontend/src/"
        esfuerzo: "15h"

  performance:
    bundle_size_multimedia: "~283 KB (gzip)"  # Excelente
    metricas_actuales:
      fcp: "~3.5s"
      tti: "~6s"
      lcp: "~4.2s"
      cls: "0.15"

    metricas_target_q4_2026:
      fcp: "<1.5s"
      tti: "<3s"
      lcp: "<2.5s"
      cls: "<0.1"

  security:
    vulnerabilidades:
      - tipo: "Tokens en localStorage"
        owasp: "A02:2021"
        severidad: "ALTA"
      - tipo: "No CSRF protection"
        owasp: "A01:2021"
        severidad: "ALTA"
      - tipo: "PCI-DSS non-compliant"
        severidad: "CRÍTICA"
      - tipo: "XSS en MarkdownRenderer"
        owasp: "A03:2021"
        severidad: "MEDIA"

  roadmap_propuesto:
    fase_1_q1_2026:
      nombre: "Security & Blockers"
      esfuerzo: "60h"  # 141h completados: PCI-DSS (18h) + Video upload (41h) + E2E tests (8h)
      items_completados:
        - "✅ PCI-DSS compliance (18h real vs 80h estimado) - ST4.2"
        - "✅ Video upload (41h real vs 60h estimado) - ST4.3"
        - "✅ E2E tests payments (8h) - ST4.2.3"
      items_pendientes:
        - "Auto-refresh tokens (60h)"

    fase_2_q2_2026:
      nombre: "Core Features"
      esfuerzo: "362h"
      items:
        - "MT4 Gateway funcional (180h)"
        - "Live streaming educativo (80h)"
        - "WebSocket real-time trading (60h)"
        - "Portfolio optimizer (80h)"

    fase_3_q3_2026:
      nombre: "Scalability & UX"
      esfuerzo: "372h"  # 8h de E2E ya completados
      items:
        - "WebP + Lazy loading (60h)"
        - "Code-splitting (40h)"
        - "Tests E2E adicionales (112h)"  # ✅ 8h completados (payments), 112h pendientes (resto)
        - "Error boundaries (15h)"

    fase_4_q4_2026:
      nombre: "Advanced Features"
      esfuerzo: "1514h"
      items:
        - "Audio/Podcast (120h)"
        - "Voice input (50h)"
        - "Advanced ML models (200h)"

  referencias_auditoria:
    executive_summary: "entregables/EXECUTIVE-SUMMARY.md"
    components_matrix: "entregables/COMPONENTS-MASTER-MATRIX.md"
    api_contracts: "entregables/API-CONTRACTS-MASTER-MATRIX.md"
    multimedia_matrix: "entregables/MULTIMEDIA-MASTER-MATRIX.md"
    dependency_graph: "entregables/DEPENDENCY-GRAPH.md"
    purge_plan: "entregables/PURGE-PLAN.md"
    integration_plan: "entregables/INTEGRATION-PLAN.md"
    recommendations: "entregables/RECOMMENDATIONS.md"
