Service Layer medium complexity backend
0
Dependencies
0
Dependents
6
Entities
0
Integrations

Description

Backend service responsible for aggregating KPI data from multiple domain sources into a single dashboard response. It queries activity logs, peer mentor records, approval queues, and expense entries, then computes summary metrics and returns them in a normalized shape. Caches results with a short TTL to reduce repeated aggregation load on high-traffic dashboard refreshes.

Feature: Dashboard KPIs

dashboard-kpi-service

Sources & reasoning

Line 195 explicitly names dashboards and KPIs as a core Admin Web Portal capability. Line 158 classifies the admin panel as MUST HAVE in Fase 1 (MVP). Line 326 confirms activity overview and basic statistics are in the MVP admin scope, directly motivating a KPI-centric landing screen for immediate operational visibility without manual navigation.

Responsibilities

  • Aggregate total activities logged across all organizational units
  • Count currently active peer mentors from the mentor registry
  • Calculate the size of the pending approval queue
  • Sum expense totals from the expense ledger within the current period
  • Return a unified KpiSummary object with all metrics and a cache timestamp

Interfaces

getKpiSummary(orgId: string): Promise<KpiSummary>
getActivityCount(orgId: string): Promise<number>
getActiveMentorCount(orgId: string): Promise<number>
getPendingApprovalCount(orgId: string): Promise<number>
getExpenseTotal(orgId: string, period: DateRange): Promise<number>