# ═══════════════════════════════════════════════════════════════════════════════
# BACKEND_INVENTORY.yml - Trading Platform
# ═══════════════════════════════════════════════════════════════════════════════

version: "1.1.0"
fecha_actualizacion: "2026-01-25"
proyecto: "trading-platform"

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

resumen:
  total_modulos: 12
  total_controllers: 24
  total_services: 35
  total_repositories: 4
  total_endpoints: 70
  ubicacion: "apps/backend/src/"
  framework: "Express.js 5.0.1"
  lenguaje: "TypeScript 5.3.3"

# ═══════════════════════════════════════════════════════════════════════════════
# MODULOS
# ═══════════════════════════════════════════════════════════════════════════════

modulos:

  auth:
    descripcion: "Autenticacion OAuth, Email, SMS, 2FA"
    controllers: 5
    services: 5
    routes: 1
    dtos: 6
    servicios_detalle:
      - token.service.ts
      - email.service.ts
      - oauth.service.ts
      - phone.service.ts
      - twofa.service.ts

  users:
    descripcion: "Gestion de perfiles de usuario"
    controllers: 0
    services: 1
    routes: 1

  trading:
    descripcion: "Orders, trades, signals, bots"
    controllers: 0
    services: 8
    routes: 1
    servicios_detalle:
      - signal.service.ts
      - order.service.ts
      - trade.service.ts
      - bot.service.ts
      - watchlist.service.ts
      - position.service.ts
      - backtest.service.ts
      - market-data.service.ts

  education:
    descripcion: "Cursos, quizzes, gamificacion"
    controllers: 3
    services: 4
    routes: 1
    servicios_detalle:
      - course.service.ts
      - enrollment.service.ts
      - gamification.service.ts
      - quiz.service.ts

  investment:
    descripcion: "Productos, cuentas, portafolio, distribuciones"
    controllers: 0
    services: 3
    routes: 1
    jobs: 1
    tests: 1
    servicios_detalle:
      - account.service.ts
      - product.service.ts
      - transaction.service.ts
    jobs_detalle:
      - distribution.job.ts
    tests_detalle:
      - jobs/__tests__/distribution.job.spec.ts

  notifications:
    descripcion: "Notificaciones multi-canal (email, push, in-app, WebSocket)"
    controllers: 1
    services: 1
    routes: 1
    tests: 1
    servicios_detalle:
      - notification.service.ts
    controllers_detalle:
      - notification.controller.ts
    rutas_detalle:
      - notification.routes.ts
    tests_detalle:
      - services/__tests__/notification.service.spec.ts
    endpoints:
      - GET /notifications
      - GET /notifications/unread-count
      - GET /notifications/preferences
      - PATCH /notifications/preferences
      - POST /notifications/read-all
      - PATCH /notifications/:id/read
      - DELETE /notifications/:id
      - POST /notifications/push-token
      - DELETE /notifications/push-token
    integraciones:
      - Firebase Cloud Messaging (FCM)
      - Web Push
      - Nodemailer

  payments:
    descripcion: "Stripe, wallets, subscriptions"
    controllers: 0
    services: 3
    routes: 1
    servicios_detalle:
      - stripe.service.ts
      - wallet.service.ts
      - subscription.service.ts

  ml:
    descripcion: "Predicciones, modelos, backtesting"
    controllers: 0
    services: 6
    routes: 1
    servicios_detalle:
      - prediction.service.ts
      - model.service.ts
      - backtest.service.ts
      - feature.service.ts
      - risk.service.ts
      - ensemble.service.ts

  admin:
    descripcion: "Stats, modelos ML, agentes"
    controllers: 0
    services: 1
    routes: 1

  llm:
    descripcion: "LLM agent, estrategias"
    controllers: 0
    services: 1
    routes: 1

  agents:
    descripcion: "Trading agents orquestacion"
    controllers: 0
    services: 1
    routes: 1

  portfolio:
    descripcion: "Portfolio management, allocations, goals, rebalancing, performance"
    controllers: 1
    services: 1
    repositories: 4
    routes: 1
    websocket: 1
    servicios_detalle:
      - portfolio.service.ts
    controllers_detalle:
      - portfolio.controller.ts
    repositories_detalle:
      - portfolio.repository.ts
      - allocation.repository.ts
      - goal.repository.ts
      - snapshot.repository.ts
    websocket_detalle:
      - portfolio.websocket.ts
    endpoints:
      - GET /portfolio
      - POST /portfolio
      - GET /portfolio/:id
      - PUT /portfolio/:id/allocations
      - GET /portfolio/:id/stats
      - GET /portfolio/:id/rebalance
      - POST /portfolio/:id/rebalance
      - GET /portfolio/:id/performance
      - GET /portfolio/:id/performance/stats
      - GET /portfolio/goals
      - POST /portfolio/goals
      - PATCH /portfolio/goals/:id
      - DELETE /portfolio/goals/:id

# ═══════════════════════════════════════════════════════════════════════════════
# RUTAS API
# ═══════════════════════════════════════════════════════════════════════════════

rutas_api:
  base: "/api/v1"
  endpoints:
    - path: "/auth"
      descripcion: "OAuth, Email, SMS, 2FA"
    - path: "/users"
      descripcion: "Perfil, settings"
    - path: "/trading"
      descripcion: "Orders, trades, signals, bots"
    - path: "/education"
      descripcion: "Cursos, quizzes, gamification"
    - path: "/investment"
      descripcion: "Productos, cuentas, transacciones"
    - path: "/payments"
      descripcion: "Stripe, wallets, subscriptions"
    - path: "/admin"
      descripcion: "Stats, ML models, agents"
    - path: "/ml"
      descripcion: "Predicciones, modelos"
    - path: "/llm"
      descripcion: "Estrategias LLM"
    - path: "/portfolio"
      descripcion: "Portafolio"
    - path: "/agents"
      descripcion: "Trading agents"
    - path: "/notifications"
      descripcion: "Notificaciones multi-canal"

  health:
    - path: "/health"
      descripcion: "Quick check"
    - path: "/health/full"
      descripcion: "Sistema completo"
    - path: "/health/services"
      descripcion: "Health por servicio"

# ═══════════════════════════════════════════════════════════════════════════════
# INFRAESTRUCTURA
# ═══════════════════════════════════════════════════════════════════════════════

infraestructura:
  middleware:
    - auth.middleware.ts
    - error-handler.ts
    - not-found.ts
    - rate-limiter.ts

  websocket:
    - websocket.server.ts
    - trading-stream.service.ts
    - portfolio.websocket.ts  # Real-time portfolio updates (2026-01-25)

  jobs:
    - distribution.job.ts  # Distribución diaria de rendimientos (00:00 UTC)

  clients:
    - firebase.client.ts  # FCM/Web Push integration (2026-01-25)

  config:
    - swagger.config.ts
    - index.ts

# ═══════════════════════════════════════════════════════════════════════════════
# INTEGRACIONES
# ═══════════════════════════════════════════════════════════════════════════════

integraciones:
  base_datos:
    - PostgreSQL
    - Redis
  pagos:
    - Stripe
  oauth:
    - Google
    - Facebook
    - GitHub
    - Apple
  comunicacion:
    - Twilio
    - Nodemailer
  llm:
    - OpenAI
    - Anthropic
  trading:
    - Binance
    - MetaTrader
