Stats Aggregation Service
Component Detail
Service Layer
medium complexity
backendmobile
1
Dependencies
1
Dependents
6
Entities
0
Integrations
Description
Backend-oriented service that queries and aggregates activity records from the shared PostgreSQL database, grouping by mentor ID, activity type, contact, and configurable time windows. All queries are tenant-scoped to prevent cross-organization data leakage. Provides computed totals, trend calculations, and percentage breakdowns that feed both the dashboard UI and the local cache for offline viewing.
stats-aggregation-service
Responsibilities
- Aggregate activities by type, date range, and contact with tenant-scoped queries
- Compute contribution totals, engagement trends, and period-over-period comparisons
- Provide coordinator-level read access to any mentor's statistics within same local association
- Format aggregated data for chart rendering and accessible table display
Interfaces
getPersonalStats(userId, orgId, dateRange)
getActivityBreakdownByType(userId, orgId, dateRange)
getActivityBreakdownByContact(userId, orgId, dateRange)
getTrendData(userId, orgId, periodType, periodCount)
getContributionTotals(userId, orgId, dateRange)
getMentorStatsForCoordinator(coordinatorId, mentorId, orgId, dateRange)
getEngagementScore(userId, orgId)
refreshAggregations(userId, orgId)
Relationships
Related Data Entities (6)
Data entities managed by this component