Revenue Analytics Engine

BI-grade revenue intelligence with 7-tab dashboard, real-time KPIs, cohort analysis, LTV modeling, revenue forecasting, tenant health scoring, and automated PDF report delivery.

The Revenue Analytics Engine provides comprehensive financial intelligence for your SaaS platform. It aggregates subscription data from all tenants into actionable KPIs, trend visualizations, and predictive models. Nightly background jobs snapshot all metrics, compute tenant health scores, and generate scheduled reports — delivering a complete BI-grade analytics suite without external tools.

KPI Overview

Eight core KPIs are calculated in real-time from subscription and payment data. Each KPI supports date range filtering, period-over-period comparison, and drill-down by edition or tenant.

KPIFormulaDescription
MRRSum of active monthly-normalized revenueMonthly Recurring Revenue
ARRMRR × 12Annual Recurring Revenue
NRR(Start MRR + Expansion − Contraction − Churn) / Start MRR × 100Net Revenue Retention %
ARPUMRR / Active SubscriptionsAverage Revenue Per User
Churn RateCancelled Subs / Total Subs × 100Monthly subscription churn %
Trial→PaidConverted Trials / Total Trials × 100Trial conversion rate
Active SubsCount of Status=ActiveTotal active subscriptions
New SubsCount of subs created in periodNew subscriptions this period

7-Tab Dashboard

The analytics dashboard is organized into 7 lazy-loaded tabs, each focusing on a specific analytical dimension. Tabs are rendered via React.lazy with Suspense fallbacks for optimal bundle splitting.

TabKey VisualizationsData Source
OverviewKPI cards, MRR sparkline, period selectorAnalyticsSummary API
MRR WaterfallStacked bar chart: New, Expansion, Contraction, Churn, ReactivationMRR Movements API
Cohort RetentionHeatmap grid showing retention % by monthly cohortCohort API
LTV by EditionBar chart comparing lifetime value per edition tierLTV API
Revenue ForecastLine chart with 6-month linear regression + confidence bandsForecast API
Health ScoresSortable table with risk badges (Healthy/At-Risk/Critical)Health Scores API
ReportsList of generated/scheduled reports with download linksReports API

AnalyticsSnapshot Entity

The AnalyticsSnapshot entity stores daily metric snapshots. Each night, the AnalyticsSnapshotJob creates one aggregate row (TenantId = null) and one row per active tenant. This enables historical trend analysis without querying live subscription tables.

FieldTypeDescription
SnapshotDateDateTimeUTC date of the snapshot
TenantIdGuid?Null = aggregate row, non-null = tenant-specific
Mrrdecimal(18,2)Monthly Recurring Revenue at snapshot time
Arrdecimal(18,2)Annual Recurring Revenue (MRR × 12)
ActiveSubscriptionsintCount of active subscriptions
NewSubscriptionsintNew subscriptions in the period
ChurnedSubscriptionsintCancelled subscriptions in the period
TrialSubscriptionsintActive trial subscriptions
ConvertedTrialsintTrials that converted to paid
TotalRevenuedecimal(18,2)Cumulative revenue collected

Tenant Health Scoring

The TenantHealthScoreJob computes a composite health score (0–100) for each active tenant using a weighted formula that combines payment reliability, platform activity, and subscription growth signals.

Text
Health Score = (Payment × 0.40) + (Activity × 0.30) + (Growth × 0.30)

Payment Score (0-100):
  - 100 if no failed payments
  - Deduct 25 per failed payment in last 30 days
  - Minimum 0

Activity Score (0-100):
  - Based on admin login frequency in last 30 days
  - 100 = daily, 75 = weekly, 50 = biweekly, 25 = monthly, 0 = inactive

Growth Score (0-100):
  - 100 if user count grew > 20%
  - 75 if grew 10-20%
  - 50 if stable (±10%)
  - 25 if declined 10-20%
  - 0 if declined > 20%

Risk Classification:
  ≥ 70 → Healthy (green)
  40-69 → At-Risk (amber)
  < 40 → Critical (red)

Background Jobs Pipeline

Three background jobs run in strict sequence every night. They are fully provider-agnostic — configurable to run under Native, Hangfire, or Quartz via appsettings.json. Each job implements IAutoRegisteredJob for unified management.

AnalyticsSnapshotJob 3:00 AM UTC
Snapshots ready
TenantHealthScoreJob 4:00 AM UTC
Scores updated
AnalyticsReportJob 6:00 AM UTC
JobSchedulePurposeProvider
AnalyticsSnapshotJobDaily 3:00 AMCaptures MRR/ARR/churn/trial metrics per tenant + aggregateNative / Hangfire / Quartz
TenantHealthScoreJobDaily 4:00 AMComputes weighted health score for every active tenantNative / Hangfire / Quartz
AnalyticsReportJobDaily 6:00 AMGenerates and emails scheduled PDF reportsNative / Hangfire / Quartz

API Endpoints

The AnalyticsController exposes 12 endpoints under /api/v1/analytics. All endpoints require SuperAdmin role and the corresponding analytics permission.

MethodEndpointDescriptionAuth
GET/api/v1/analytics/summaryGet analytics summary (KPI cards + period comparison)🔒 Required
GET/api/v1/analytics/mrr-movementsGet MRR waterfall movements (new/expansion/contraction/churn/reactivation)🔒 Required
GET/api/v1/analytics/cohort-retentionGet cohort retention heatmap data by monthly cohorts🔒 Required
GET/api/v1/analytics/ltv-by-editionGet lifetime value breakdown by edition tier🔒 Required
GET/api/v1/analytics/forecastGet 6-month revenue forecast with linear regression + confidence bands🔒 Required
GET/api/v1/analytics/health-scoresGet tenant health scores with risk classification🔒 Required
GET/api/v1/analytics/snapshotsGet historical daily snapshots for trend charts🔒 Required
GET/api/v1/analytics/export/{format}Export analytics data in specified format (csv/excel/pdf)🔒 Required
GET/api/v1/analytics/reportsList all scheduled reports🔒 Required
POST/api/v1/analytics/reportsCreate a new scheduled report configuration🔒 Required
PUT/api/v1/analytics/reports/{id}Update scheduled report settings🔒 Required
DELETE/api/v1/analytics/reports/{id}Delete a scheduled report🔒 Required

Export System

Analytics data can be exported in three formats. Each export includes the current KPI summary, MRR trends, and subscription breakdown. PDF exports include branded headers and charts.

FormatExtensionFeatures
CSV.csvComma-separated values for spreadsheet import
Excel.xlsxMulti-sheet workbook with charts and formatting
PDF.pdfBranded report with KPI cards, charts, and tables

Scheduled Reports

Administrators can configure automated report delivery. Reports are generated by the AnalyticsReportJob at 6:00 AM UTC and emailed to the configured recipients in the chosen format.

FieldTypeDescription
ReportNamestring(200)User-defined report name
CadenceReportCadenceDaily | Weekly | Monthly
FormatExportFormatCSV | Excel | PDF
Recipientsstring[]Email addresses for delivery
IncludeSectionsstring[]Which KPI sections to include
IsActiveboolWhether the scheduled report is enabled

Permissions

Revenue Analytics uses four granular permissions that can be assigned to roles via the standard RBAC system.

PermissionAction
analytics.viewView analytics dashboard and KPI data
analytics.view_healthView tenant health scores
analytics.exportExport analytics data (CSV/Excel/PDF)
analytics.manage_reportsCreate, edit, delete scheduled reports