feat: BI-CCC evolution — 6-phase platform upgrade (45→85 maturity)

Phase 1: Refactor queries.js (1787 lines) into domain modules with facade pattern
  - src/queries/{helpers,payin,payout,corporate,bi,client,provider,compliance}.queries.js
  - New provider performance + compliance data layer queries
  - Health check endpoint (GET /health)

Phase 2: Provider Performance Dashboard (src/admin-providers.js)
  - Hero cards, sortable tables, Chart.js charts, date range filter
  - API routes: /admin/api/providers, /admin/api/providers/failed, /admin/api/providers/trend

Phase 3: Excel Export (exceljs)
  - CambioReal-branded exports for BI, clients, providers, transactions
  - Export buttons added to BI and Client 360 dashboards

Phase 4: Alert System (node-cron + nodemailer)
  - 5 alert rules: volume spike, spread anomaly, large tx, failed tx spike, provider inactivity
  - SQLite alerts table, bell icon UI with acknowledge workflow
  - Email notifications via SMTP

Phase 5: Enhanced Analytics
  - Churn prediction: weighted RFM model (src/services/churn-predictor.js)
  - Volume forecasting: exponential smoothing with confidence bands (src/services/forecast.js)
  - Forecast chart in BI dashboard, churn risk in Client 360

Phase 6: SQLite Analytics Store (ETL)
  - src/db-analytics.js: daily_metrics, client_health_daily, monthly_revenue tables
  - src/etl/daily-sync.js: MySQL RDS → SQLite daily sync at 1 AM + 90-day backfill
  - src/etl/data-quality.js: post-sync validation (row counts, reconciliation)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-16 20:22:23 -05:00
parent a76ab30730
commit 844f931076
25 changed files with 5686 additions and 1786 deletions

1074
src/admin-providers.js Normal file

File diff suppressed because it is too large Load Diff