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

Description

Backend rule engine that evaluates badge trigger conditions as a post-save hook whenever an activity, course enrollment, or contact record is created or updated. Each badge type is implemented as a class with a common interface, enabling new badge types to be added without schema changes.

Feature: Achievement Badges

badge-award-service

Responsibilities

  • Evaluate badge trigger rules as post-save hooks on activities, enrollments, and contact records
  • Implement rule engine pattern with each badge type as a class implementing a common interface
  • Record newly awarded badges in User Achievements table with timestamp and triggering entity reference
  • Expose badge catalogue endpoint returning all badge definitions with trigger descriptions
  • Integrate badge award events into the Annual Summary payload for year-in-review inclusion

Interfaces

evaluateAwards(userId, triggerEntityType, triggerEntityId) → Promise<UserAchievement[]>
getBadgeCatalogue() → Promise<BadgeDefinition[]>
getUserAchievements(userId) → Promise<UserAchievement[]>
awardBadge(userId, badgeId, triggerEntityType, triggerEntityId) → Promise<UserAchievement>
getBadgesForAnnualSummary(userId, year) → Promise<UserAchievement[]>
registerBadgeRule(badgeRule: IBadgeRule) → void

Relationships

Dependencies (4)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component