Statistics Aggregation Endpoint
Component Detail
Service Layer
medium complexity
backend
1
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Backend REST API endpoint that computes per-user activity totals scoped strictly to the authenticated user - count by activity type, total hours, and monthly trend - using SQL aggregation over the activities table. Enforces user-scoped data isolation so no peer mentor can access another user's statistics.
statistics-aggregation-endpoint
Sources & reasoning
Dedicated aggregation endpoint required so the backend computes totals in SQL rather than transferring raw activity records to the client. User-scoped isolation is a security requirement given the multi-tenant architecture.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Aggregate activity count by type for the authenticated user
- Compute total hours and monthly trend from the activities table
- Enforce strict user-scoped data isolation in all queries
- Return a typed JSON payload consumed by the mobile Statistics Service
Interfaces
GET /api/v1/statistics/me → StatisticsSummaryResponse
validateUserScope(token) → UserId
aggregateByType(userId: string) → TypeBreakdown[]
aggregateMonthlyTrend(userId: string, months: number) → MonthlyTrend[]
Relationships
Related Data Entities (1)
Data entities managed by this component