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

Description

Business logic layer responsible for validating, enriching, and persisting activity log entries. Applies smart defaults when optional fields are omitted and enforces business rules before delegating persistence to ActivityRepository. Acts as the single entry point for all activity creation operations.

Feature: Simple Activity Logging

activity-service

Sources & reasoning

All four organizations named activity logging their top priority; line 18 identifies systemic underreporting as the core problem; line 22 demonstrates scale (380 registrations/year); line 24 establishes the minimal cognitive load design principle. Blueprint assigns [MVP] matching the Fase 1 roadmap mandate for 'Aktivitetsregistrering med lavest mulig antall klikk'.

  • docs/source/likeperson.md · line 18
    Fellesnevneren er at rapporteringen er så tungvint at det fører til massiv underrapportering - enten fordi folk ikke orker, eller fordi de ikke engang skjønner at det de gjør teller.
  • docs/source/likeperson.md · line 22
    En likeperson hadde 380 enkeltregistreringer på ett år. Standardverdier (dagens dato, 30 min) som kan overstyres. 60-70 % av registreringene er uten refusjon og skal være ekstremt enkle.
  • docs/source/likeperson.md · line 24
    Designprinsipp: Lavest mulig kognitiv belastning. Standardvalg, gjenkjennelig logikk, færrest mulig steg.

Responsibilities

  • Apply default date (today) and duration (30 minutes) when not provided by the caller
  • Validate required fields such as contact reference and activity type
  • Coordinate with ActivityRepository to persist validated activity records
  • Return a confirmed activity record or a structured error to the caller

Interfaces

logActivity(draft: ActivityDraft): Promise<Activity>
applyDefaults(draft: Partial<ActivityDraft>): ActivityDraft
validateActivity(draft: ActivityDraft): ValidationResult