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

Description

Backend service that aggregates raw activity records into personal statistics for a single mentor. Computes totals and time-bucketed trends, enforcing role-based scoping so a mentor only ever sees their own data.

Feature: Personal Activity Statistics

stats-aggregation-service

Sources & reasoning

MVP scope in §5 explicitly lists 'Enkel statistikkvisning per likeperson' and §7 Phase 1 repeats 'enkel statistikk' - making this a Phase 1 must_have. It is the data foundation that later gamification (Phase 3 Wrapped/badges) reads from, so it ships first.

Responsibilities

  • Aggregate logged activities into totals for activities, hours, and contacts supported
  • Compute weekly, monthly, and yearly trend series for charting
  • Enforce role-based access so results are scoped to the requesting mentor
  • Return shaped DTOs optimised for mobile rendering and minimal payload size
  • Handle empty datasets gracefully and surface validation errors clearly

Interfaces

getPersonalTotals(mentorId): PersonalTotals
getTrendSeries(mentorId, period: 'week' | 'month' | 'year'): TrendSeries
getPersonalStatsSummary(mentorId): PersonalStatsSummary

Related Data Entities (1)

Data entities managed by this component