Analytics Service
Component Detail
Service Layer
high complexity
backend
2
Dependencies
2
Dependents
11
Entities
0
Integrations
Description
Backend service that computes and serves aggregated KPI metrics for the admin dashboard. Executes optimized PostgreSQL aggregate queries parameterized by organization_id, local_association_id, and date range, enforcing role-based scoping at the API layer. Exposes dedicated summary endpoints (/api/v1/admin/dashboard) returning pre-aggregated counts to prevent N+1 queries.
analytics-service
Responsibilities
- Execute parameterized aggregate SQL queries for activity counts, active peer mentors, pending reimbursements, and engagement trends
- Enforce role-based data scoping (coordinator → local_association_id, org admin → all associations under organization_id)
- Return pre-aggregated KPI snapshots and time-series data in Zod-typed response shapes
- Support configurable date range filtering for trend computations
- Identify underperforming areas and peer mentors below engagement thresholds
Interfaces
getDashboardKpis(organizationId, scope, dateRange)
getActivityCount(associationId, dateRange)
getActivePeerMentorCount(organizationId, dateRange)
getPendingReimbursementCount(organizationId)
getEngagementTrend(organizationId, granularity, dateRange)
getUnderperformingPeerMentors(organizationId, threshold)
getKpisByAssociation(organizationId, dateRange)
Relationships
Dependencies (2)
Components this component depends on
Dependents (2)
Components that depend on this component
Related Data Entities (11)
Data entities managed by this component
Activity
20 fields
core
Course Enrollment
15 fields
core
Event Attendee
11 fields
core
Organization
14 fields
core
Peer Mentor
14 fields
core
Region
6 fields
core
Reimbursement
18 fields
core
Role
11 fields
configuration
User
18 fields
core
User Badge
13 fields
core
User Organization Role
12 fields
core