Real-Time Impact Calculation Service
Component Detail
Service Layer
high complexity
backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Backend service that receives an activity-summary payload for a user and returns a structured impact object containing computed metric values and the formulas used. Reads the tenant's calculation model configuration to apply sector-appropriate rates. Logic is pure and side-effect-free to facilitate snapshot unit testing.
real-time-impact-calculation-service
Responsibilities
- Accept activity-summary payload (user ID, date range, activity type breakdown) and return an ImpactResult object
- Look up the tenant's calculation model (hourly value rate, cost-per-professional-hour benchmark, social-value multiplier) from org-level config
- Apply calculation formulas and attach formula metadata to each metric in the response
- Expose a REST endpoint consumed by the Flutter screen on mount and on debounced slider change
Interfaces
POST /api/v1/impact/calculate → ImpactResult
calculateImpact(payload: ImpactPayload, config: CalculationModel) → ImpactResult
ImpactPayload: { userId, dateRange, activityBreakdown }
ImpactResult: { metrics: ImpactMetric[], calculatedAt: ISO8601 }