KPI Aggregation Service
Component Detail
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).
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
Related Data Entities (13)
Data entities managed by this component
Activity
25 fields
core
Activity Type
15 fields
configuration
Assignment
19 fields
core
Bufdir Report
21 fields
core
Course Enrollment
15 fields
core
Event
18 fields
core
Event Participant
14 fields
core
Expense Claim
24 fields
core
Notification
18 fields
core
Organization
21 fields
core
Organization Membership
18 fields
core
User
24 fields
core
User Role
13 fields
core