Service Layer high complexity backend
2
Dependencies
2
Dependents
11
Entities
0
Integrations

Description

Backend service that computes and serves aggregated KPI metrics for the admin dashboard. Executes optimized PostgreSQL aggregate queries parameterized by organization_id, local_association_id, and date range, enforcing role-based scoping at the API layer. Exposes dedicated summary endpoints (/api/v1/admin/dashboard) returning pre-aggregated counts to prevent N+1 queries.

Feature: Admin Dashboard & KPIs

analytics-service

Responsibilities

  • Execute parameterized aggregate SQL queries for activity counts, active peer mentors, pending reimbursements, and engagement trends
  • Enforce role-based data scoping (coordinator → local_association_id, org admin → all associations under organization_id)
  • Return pre-aggregated KPI snapshots and time-series data in Zod-typed response shapes
  • Support configurable date range filtering for trend computations
  • Identify underperforming areas and peer mentors below engagement thresholds

Interfaces

getDashboardKpis(organizationId, scope, dateRange)
getActivityCount(associationId, dateRange)
getActivePeerMentorCount(organizationId, dateRange)
getPendingReimbursementCount(organizationId)
getEngagementTrend(organizationId, granularity, dateRange)
getUnderperformingPeerMentors(organizationId, threshold)
getKpisByAssociation(organizationId, dateRange)

Relationships

Dependencies (2)

Components this component depends on

Dependents (2)

Components that depend on this component