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

Description

Backend service exposing REST endpoints POST /api/v1/activities/:id/flags and PATCH /api/v1/activities/:id/flags/:flagId for flag creation and resolution. Enforces authorization so only org admins and coordinators within the activity's organization can flag or resolve. Triggers notification dispatch to the peer mentor and coordinator when a flag is created.

Feature: Activity Flagging

activity-flag-service

Sources & reasoning

Core business logic layer required to persist and lifecycle-manage flags, enforce the reason code enum, and apply org-scoped authorization. The distributed multi-level org structure (NHF: 1 400 local chapters) means regional coordinators flag for national admins to resolve, making service-layer authorization enforcement essential for correctness.

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

Responsibilities

  • Create activity flag records with reason code, comment, flagged_by, and timestamp
  • Validate reason code against the controlled enum before persisting
  • Resolve flags by writing resolved_at and resolved_by fields
  • Enforce org-scoped authorization via role guard before any flag mutation
  • Dispatch flag-created notification events to relevant users

Interfaces

createFlag(activityId, reasonCode, comment, flaggedBy): Flag
resolveFlag(flagId, resolvedBy): Flag
listFlags(activityId): Flag[]
getFlaggedActivities(orgId, filters): PaginatedActivities

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component