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

Description

Backend service hosting the declarative badge rule engine that evaluates badge eligibility after activity saves, certification events, and summary generation. Manages the badge definition registry and writes earned records to user_achievements, then triggers push notifications on new awards.

Feature: Achievement Badges

achievement-service

Sources & reasoning

A dedicated backend service is required to host the rule engine that determines when badges are awarded. The declarative trigger-condition model (badge ID, trigger, icon) needs a service layer to evaluate events from activity logging, certification, and summary generation, write earned records, and fan out push notifications.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • Evaluate badge eligibility rules after each triggering event (activity save, certification update, summary generation)
  • Maintain the badge definition registry mapping badge ID, trigger condition, and icon asset reference
  • Write new earned records to user_achievements and return awarded badge IDs
  • Trigger push notification delivery when a new badge is awarded
  • Expose REST endpoints for listing available badges and a user's earned badges

Interfaces

evaluateBadgeEligibility(userId: string, triggerEvent: BadgeTrigger): Promise<Achievement[]>
getAvailableBadges(tenantId: string): Promise<Achievement[]>
getUserAchievements(userId: string): Promise<UserAchievement[]>
awardBadge(userId: string, achievementId: string): Promise<UserAchievement>
GET /api/v1/achievements
GET /api/v1/users/:userId/achievements

Related Data Entities (2)

Data entities managed by this component