Service Layer medium complexity backend
1
Dependencies
1
Dependents
14
Entities
0
Integrations

Description

Server-side service that aggregates KPI metrics for an organization by executing optimized SQL aggregate queries against PostgreSQL. Enforces multi-tenancy by scoping all queries to organization_id and applies role-based scope (local association vs. full org).

Feature: Dashboard KPIs

kpi-data-service

Responsibilities

  • Aggregate active peer mentor count scoped to organization
  • Count activities registered in the current reporting period
  • Count pending expense and activity approvals
  • Return Bufdir reporting status for the current period
  • Apply role-based scope: coordinator sees local association, org admin sees full org

Interfaces

getKpis(organizationId: string, roleScope: RoleScope): Promise<KpiData>
getActivePeerMentorCount(organizationId: string, localAssociationId?: string): Promise<number>
getPendingApprovalsCount(organizationId: string): Promise<number>
getActivityCountForPeriod(organizationId: string, period: ReportingPeriod): Promise<number>
getBufdirReportingStatus(organizationId: string): Promise<BufdirStatus>

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component