# Plan de Features Adicionales **Proyecto:** template-saas **Fecha:** 2026-01-10 **SP Total:** 18 (5 + 8 + 5) --- ## 1. Resumen Ejecutivo | Feature | ID | SP | Prioridad | Dependencias | |---------|-----|-----|-----------|--------------| | OAuth 2.0 | SAAS-015 | 5 | P1 | DDL existe | | Dashboard Analytics | SAAS-016 | 8 | P2 | SAAS-015 opcional | | Reportes Exportables | SAAS-017 | 5 | P2 | SAAS-016 opcional | --- ## 2. SAAS-015: OAuth 2.0 Endpoints ### 2.1 Estado Actual - [x] DDL: Tabla `auth.oauth_connections` existe - [x] DDL: Enum `auth.oauth_provider` existe - [x] RLS: Policies configuradas - [ ] Backend: Entity, Service, Controller - [ ] Backend: Passport Strategies - [ ] Frontend: Botones y UI - [ ] Tests ### 2.2 Tareas Backend | # | Tarea | Archivos | |---|-------|----------| | 1 | Instalar dependencias | package.json | | 2 | Crear OAuthConnection entity | entities/oauth-connection.entity.ts | | 3 | Crear OAuth Service | services/oauth.service.ts | | 4 | Crear Google Strategy | strategies/google.strategy.ts | | 5 | Crear Microsoft Strategy | strategies/microsoft.strategy.ts | | 6 | Crear GitHub Strategy | strategies/github.strategy.ts | | 7 | Crear OAuth Controller | oauth.controller.ts | | 8 | Actualizar Auth Module | auth.module.ts | | 9 | Actualizar env config | config/env.config.ts | | 10 | Tests unitarios | __tests__/oauth.service.spec.ts | ### 2.3 Endpoints a Implementar | Metodo | Endpoint | Descripcion | |--------|----------|-------------| | GET | /auth/oauth/:provider | Iniciar OAuth flow | | GET | /auth/oauth/:provider/callback | Callback del proveedor | | POST | /auth/oauth/link/:provider | Vincular cuenta existente | | DELETE | /auth/oauth/:provider | Desvincular proveedor | | GET | /auth/oauth/connections | Listar conexiones | ### 2.4 Tareas Frontend | # | Tarea | Archivos | |---|-------|----------| | 1 | Crear OAuthButtons component | components/auth/OAuthButtons.tsx | | 2 | Actualizar LoginPage | pages/auth/LoginPage.tsx | | 3 | Actualizar RegisterPage | pages/auth/RegisterPage.tsx | | 4 | Crear OAuthCallback page | pages/auth/OAuthCallback.tsx | | 5 | Crear OAuthConnections component | components/settings/OAuthConnections.tsx | | 6 | Actualizar Settings page | pages/settings/SecuritySettings.tsx | | 7 | Crear oauth.api.ts | services/oauth.api.ts | | 8 | Crear useOAuth hook | hooks/useOAuth.ts | ### 2.5 Dependencias NPM **Backend:** ```bash npm install passport-google-oauth20 passport-microsoft passport-github2 npm install -D @types/passport-google-oauth20 @types/passport-github2 ``` **Frontend:** Ninguna adicional requerida --- ## 3. SAAS-016: Dashboard Analytics ### 3.1 Funcionalidades - Metricas de usuarios (activos, nuevos, churn) - Metricas de billing (MRR, revenue, subscriptions) - Metricas de uso (API calls, storage, AI usage) - Graficos temporales (7d, 30d, 90d, 1y) - KPIs por tenant y globales (superadmin) ### 3.2 Tareas Backend | # | Tarea | Archivos | |---|-------|----------| | 1 | Crear Analytics Module | modules/analytics/analytics.module.ts | | 2 | Crear Analytics Service | modules/analytics/analytics.service.ts | | 3 | Crear Analytics Controller | modules/analytics/analytics.controller.ts | | 4 | Crear DTOs | modules/analytics/dto/*.ts | | 5 | Tests unitarios | modules/analytics/__tests__/*.ts | ### 3.3 Endpoints | Metodo | Endpoint | Descripcion | |--------|----------|-------------| | GET | /analytics/users | Metricas de usuarios | | GET | /analytics/billing | Metricas de billing | | GET | /analytics/usage | Metricas de uso | | GET | /analytics/summary | Resumen KPIs | | GET | /analytics/trends | Tendencias temporales | ### 3.4 Tareas Frontend | # | Tarea | Archivos | |---|-------|----------| | 1 | Instalar chart library | package.json (recharts) | | 2 | Crear AnalyticsDashboard | pages/admin/AnalyticsDashboard.tsx | | 3 | Crear MetricCard component | components/analytics/MetricCard.tsx | | 4 | Crear TrendChart component | components/analytics/TrendChart.tsx | | 5 | Crear useAnalytics hook | hooks/useAnalytics.ts | | 6 | Crear analytics.api.ts | services/analytics.api.ts | --- ## 4. SAAS-017: Reportes Exportables ### 4.1 Funcionalidades - Exportar a PDF (reportes formateados) - Exportar a Excel (datos tabulares) - Exportar a CSV (datos crudos) - Templates de reportes predefinidos - Reportes programados (futuro) ### 4.2 Tareas Backend | # | Tarea | Archivos | |---|-------|----------| | 1 | Instalar dependencias | package.json (pdfkit, exceljs) | | 2 | Crear Reports Module | modules/reports/reports.module.ts | | 3 | Crear PDF Service | modules/reports/pdf.service.ts | | 4 | Crear Excel Service | modules/reports/excel.service.ts | | 5 | Crear Reports Controller | modules/reports/reports.controller.ts | | 6 | Tests unitarios | modules/reports/__tests__/*.ts | ### 4.3 Endpoints | Metodo | Endpoint | Descripcion | |--------|----------|-------------| | GET | /reports/users/pdf | Exportar usuarios a PDF | | GET | /reports/users/excel | Exportar usuarios a Excel | | GET | /reports/billing/pdf | Exportar billing a PDF | | GET | /reports/billing/excel | Exportar billing a Excel | | GET | /reports/audit/csv | Exportar audit logs a CSV | ### 4.4 Tareas Frontend | # | Tarea | Archivos | |---|-------|----------| | 1 | Crear ExportButton component | components/common/ExportButton.tsx | | 2 | Crear ExportModal component | components/common/ExportModal.tsx | | 3 | Actualizar tablas con export | Multiples componentes | | 4 | Crear reports.api.ts | services/reports.api.ts | | 5 | Crear useExport hook | hooks/useExport.ts | ### 4.5 Dependencias NPM **Backend:** ```bash npm install pdfkit exceljs npm install -D @types/pdfkit ``` --- ## 5. Orden de Ejecucion ``` FASE 1: SAAS-015 OAuth 2.0 ├── Backend (entity, service, strategies, controller) ├── Frontend (buttons, callback, settings) └── Tests FASE 2: SAAS-016 Dashboard Analytics ├── Backend (module, service, controller) ├── Frontend (dashboard, charts, metrics) └── Tests FASE 3: SAAS-017 Reportes Exportables ├── Backend (module, pdf, excel services) ├── Frontend (export buttons, modals) └── Tests ``` --- ## 6. Estimacion de Tiempo | Feature | Backend | Frontend | Tests | Total | |---------|---------|----------|-------|-------| | OAuth 2.0 | 3h | 2h | 1h | 6h | | Analytics | 3h | 3h | 1h | 7h | | Reportes | 3h | 2h | 1h | 6h | | **Total** | **9h** | **7h** | **3h** | **19h** | --- **Creado:** 2026-01-10 **Autor:** Claude Code