Data Layer medium complexity backend
0
Dependencies
2
Dependents
9
Entities
0
Integrations

Description

Data access layer providing optimized aggregate query methods against the PostgreSQL database for KPI computation. All queries use parameterized inputs to prevent injection and are structured to avoid N+1 patterns by returning pre-aggregated result sets. Serves as the single data access point for the Analytics Service.

Feature: Admin Dashboard & KPIs

analytics-repository

Responsibilities

  • Execute aggregate COUNT and SUM queries for activity, peer mentor, and reimbursement KPIs
  • Provide time-series query methods returning bucketed data by week, month, or quarter
  • Support multi-association queries for org admin scope using IN clauses
  • Return strongly-typed result objects validated by Zod schemas

Interfaces

countActivities(associationIds, dateRange)
countActivePeerMentors(associationIds, dateRange)
countPendingReimbursements(organizationId)
getActivityTimeSeries(associationIds, granularity, dateRange)
getPeerMentorEngagementScores(associationIds, dateRange)
getAssociationKpiBreakdown(organizationId, dateRange)

Relationships

Dependents (2)

Components that depend on this component