configuration PK: id 10 required 1 unique

Description

Configuration entity defining the categories of peer mentor activities that can be registered, such as home visits, phone calls, or group sessions. Scoped to an organization and drives conditional field visibility, validation rules, and Bufdir reporting categorization.

14
Attributes
4
Indexes
7
Validation Rules
22
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Unique identifier for the activity type record, generated by the database.
PKrequiredunique
organization_id uuid Foreign key referencing the organization that owns this activity type. Scopes the type to a single organization; RLS policies enforce isolation.
required
name string Human-readable label for the activity type, displayed on the Activity Type Selection Screen. Must be unique within the organization (e.g., 'Home Visit', 'Phone Call', 'Group Session', 'Career Workshop').
required
description text Optional extended description providing context for coordinators and administrators on when to use this activity type.
-
bufdir_category_code string Maps this activity type to a canonical Bufdir grant reporting category code. Used by the Bufdir Report Generator Service to aggregate activities into the correct reporting line items. Must match a code from the official Bufdir taxonomy (e.g., 'individual_contact', 'group_activity', 'telephone_contact', 'digital_meeting').
-
requires_contact boolean When true, the activity wizard enforces selection of a contact record before the activity can be submitted. Set to false for group activities or activities that do not target a specific individual.
required
requires_summary boolean When true, the summary/notes field is mandatory in the activity wizard for this type. Driven by organization policy and Bufdir audit requirements.
required
allows_group_registration boolean When true, this activity type can be used with the Event Creation Wizard for group activities with multiple participants. When false, only single-contact activity registration is permitted.
required
default_duration_minutes integer Optional pre-filled default duration in minutes for the activity wizard. Reduces friction for common activity types with a known typical duration (e.g., a standard phone call = 30 minutes). Can be overridden by the user at registration time.
-
conditional_fields json JSON configuration object specifying which additional wizard fields are shown or hidden based on this activity type being selected. Supports keys: 'show_location' (boolean), 'show_document_attachment' (boolean), 'show_participant_count' (boolean), 'show_expense_section' (boolean). Drives dynamic wizard rendering in the Activity Wizard Screen.
-
is_active boolean Soft-delete and visibility flag. When false, this activity type is hidden from the Activity Type Selection Screen and cannot be used in new registrations. Existing activities referencing this type are preserved. Administrators use this instead of hard deletion to maintain historical data integrity.
required
sort_order integer Controls the display ordering of activity types in the selection UI. Lower values appear first. Configured by administrators per organization to surface the most-used types at the top. Must be a positive integer and is recommended to be unique per organization.
required
created_at datetime Timestamp of when this activity type configuration record was created. Set automatically by the database on insert.
required
updated_at datetime Timestamp of the most recent update to this record. Maintained automatically via a database trigger on update.
required

Database Indexes

idx_activity_types_organization_id
btree

Columns: organization_id

idx_activity_types_org_name_unique
btree unique

Columns: organization_id, name

idx_activity_types_org_active_sort
btree

Columns: organization_id, is_active, sort_order

idx_activity_types_bufdir_code
btree

Columns: organization_id, bufdir_category_code

Validation Rules

name_non_empty_max_100 error

Validation failed

sort_order_positive_integer error

Validation failed

default_duration_in_valid_range error

Validation failed

bufdir_code_from_allowlist error

Validation failed

conditional_fields_valid_json_schema error

Validation failed

organization_id_references_valid_org error

Validation failed

name_unique_per_organization_on_update error

Validation failed

Business Rules

organization_scoped_uniqueness
on_create

Activity type names must be unique within a single organization. The same name can exist across different organizations. Enforced via a composite unique index on (organization_id, name) and a Supabase RLS policy that scopes all queries to the authenticated user's active organization.

soft_delete_only_with_existing_activities
on_delete

An activity type that has one or more associated activity records must never be hard-deleted. Deletion is handled exclusively by setting is_active = false. A hard DELETE is blocked by a database trigger or foreign key constraint to preserve historical data integrity and Bufdir audit trails.

inactive_types_hidden_from_registration
always

Activity types with is_active = false must not appear in the Activity Type Selection Screen or any activity wizard flow. The Activity Types Store filters all queries by is_active = true. Coordinators and admins can still see inactive types in the admin settings screen.

bufdir_code_required_for_reporting
always

Activity types used in organizations that submit Bufdir reports should have a valid bufdir_category_code configured. The Bufdir Report Generator Service will warn (but not block) if activities of a type with no code are encountered during report generation, and will place them in an 'uncategorized' line item.

contact_required_enforced_in_wizard
always

When requires_contact = true, the Activity Registration Service and Activity Validation Service block wizard submission if no contact has been selected. The Activity Wizard Screen disables the 'Next' action on the contact step until a valid contact is chosen.

group_type_routes_to_event_wizard
always

When allows_group_registration = true and the user selects this activity type, the Activity Registration Service routes the flow to the Event Creation Wizard Screen instead of the single-contact Activity Wizard Screen. This is evaluated at type selection time.

minimum_one_active_type_per_organization
on_update

An organization must retain at least one active activity type at all times to prevent peer mentors from being unable to register any activities. Attempts to deactivate the last active type are blocked.

Storage Configuration

Storage Type
lookup_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage

Entity Relationships

activities
incoming many_to_one

Each activity is categorized by a single organization-specific activity type

required
organizations
outgoing many_to_one

Activity types are defined per organization to reflect their specific Bufdir reporting categories

required