Case Link Service
Component Detail
Service Layer
medium complexity
mobilebackend
1
Dependencies
1
Dependents
2
Entities
0
Integrations
Description
Backend service and corresponding Riverpod provider that manages CRUD operations on the relative_case_links junction table. Enforces cross-organization authorization, replicates mutations via the Drift outbox pattern, and broadcasts reactive updates to both relative and contact Riverpod providers.
case-link-service
Sources & reasoning
The Case Link Service is the core business logic layer for the junction-table pattern described in the implementation notes. It enforces org-scoped authorization and drives the offline-first mutation outbox replication required by the platform architecture.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Create case link records with relative_id, contact_id, linked_at timestamp, and optional notes
- Delete case link records with authorization check preventing cross-organization associations
- Expose REST API endpoints for link creation and removal consumed by mobile and admin portal
- Replicate link mutations through Drift mutation outbox for offline-first support
- Invalidate and refresh Riverpod providers for both relative and contact entities on change
Interfaces
createLink(relativeId: String, contactId: String, notes: String?): CaseLink
removeLink(linkId: String): void
getLinksForRelative(relativeId: String): List<CaseLink>
getLinksForContact(contactId: String): List<CaseLink>
validateCrossOrgAccess(relativeId: String, contactId: String): bool
Relationships
Related Data Entities (2)
Data entities managed by this component