Service Layer medium complexity backend
0
Dependencies
2
Dependents
13
Entities
0
Integrations

Description

Backend service that executes scoped aggregation queries against PostgreSQL to compute KPI values for the authenticated user's organization. Enforces tenant isolation at the query level and supports role-differentiated metric sets (coordinator, org admin, global admin).

Feature: Dashboard KPIs

kpi-aggregation-service

Responsibilities

  • Aggregate active peer mentor count scoped to the user's organization
  • Count activities logged in the current calendar month per organization
  • Count pending expense claims awaiting approval
  • Count unread/unacknowledged encrypted assignments
  • Enforce tenant isolation on all aggregation queries
  • Expose GET /api/v1/admin/kpis endpoint with role-aware metric selection

Interfaces

getKpis(userId: string, orgId: string, role: UserRole): Promise<KpiPayload>
getActivePeerMentorCount(orgId: string): Promise<number>
getMonthlyActivityCount(orgId: string): Promise<number>
getPendingExpenseCount(orgId: string): Promise<number>
getUnreadAssignmentCount(orgId: string, role: UserRole): Promise<number>

Relationships

Dependents (2)

Components that depend on this component