Service Layer medium complexity mobile
2
Dependencies
1
Dependents
2
Entities
0
Integrations

Description

Business logic layer that validates a complete activity registration payload, applies organisation-specific rules (e.g. compensation eligibility thresholds), and orchestrates the Supabase insert. Handles optimistic state by returning a locally-constructed record immediately while the remote write proceeds asynchronously.

Feature: Quick Activity Registration

activity-registration-service

Summaries

The Activity Registration Service is the core business engine that ensures every activity logged by employees is accurate, policy-compliant, and eligible for the correct compensation. By enforcing organisation-specific rules at the point of entry — such as minimum duration thresholds for compensation eligibility — it directly protects the organisation from over-payment errors and audit risk. Its optimistic submission design means employees experience instant confirmation rather than waiting on network round-trips, improving adoption rates and reducing abandonment. Accurate, rule-validated activity data also feeds reporting dashboards that inform workforce planning and ROI measurement for wellness or training programmes.

This service sits at the critical path of the activity registration feature and is a medium-complexity deliverable. It has two hard dependencies — the Activity Repository and the Registration Preferences Store — both of which must be stable before integration testing can begin. The optimistic-write pattern introduces a reconciliation scenario that requires thorough edge-case testing: network failures, server rejections, and partial saves must all be handled gracefully. Plan for dedicated QA cycles covering compensation-eligibility boundary conditions, since these are organisation-configurable and may vary between client deployments.

Deployment risk is moderate; changes to business rules here propagate immediately to all users without a release cycle for rule logic stored externally.

Activity Registration Service is a mobile-tier service component responsible for the full lifecycle of an activity submission. It consumes a raw ActivityRegistrationPayload, runs synchronous validation via validatePayload(), applies compensation eligibility logic (isCompensationEligible() checks activity type and duration against org-configured thresholds), then calls buildRecord() to construct a Supabase-compatible ActivityRecord. submitActivity() performs an optimistic insert: the locally-constructed record is returned immediately to the Cubit layer while the async Supabase write proceeds in the background. On success, last-used values are persisted to RegistrationPreferencesStore.

Errors surface through handleSubmissionError() which maps raw exceptions to typed RegistrationError objects. Depends on activity and activity-type data models; ensure compensation threshold config is injected rather than hardcoded to support multi-org deployments.

Responsibilities

  • Validate the full registration payload against business rules
  • Determine compensation eligibility based on organisation and activity type
  • Build the Supabase-ready ActivityRecord from wizard state
  • Execute optimistic insert and reconcile with remote confirmation
  • Persist last-used values to RegistrationPreferencesStore after successful save

Interfaces

validatePayload(ActivityRegistrationPayload payload) -> ValidationResult
buildRecord(ActivityRegistrationPayload payload) -> ActivityRecord
submitActivity(ActivityRecord record) -> Future<ActivityRecord>
handleSubmissionError(Object error) -> RegistrationError
isCompensationEligible(ActivityType type, int durationMinutes) -> bool

Relationships

Dependencies (2)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/activity-registrations 5 endpoints
GET /api/v1/activity-registrations List submitted registrations
GET /api/v1/activity-registrations/:id Get a single registration by ID
POST /api/v1/activity-registrations Validate payload, build ActivityRecord, and submit — mirrors validatePayload + buildRecord + submitActivity in one atomic call
PUT /api/v1/activity-registrations/:id Update a registration (e.g. correct duration or activity type before confirmation)
DELETE /api/v1/activity-registrations/:id Delete a registration record