Note Service
Component Detail
Description
Riverpod-backed service managing the full lifecycle of notes including create, read, update, and delete operations against the REST API and local Drift database. Emits a single mutation to the Mutation Outbox on save so the Sync Queue Service propagates changes when connectivity is restored. Applies last-write-wins conflict resolution at the note level.
note-service
Sources & reasoning
Note Service encapsulates all business logic for note persistence and sync. The outbox mutation pattern is required by the platform's offline-first architecture; last-write-wins is explicitly called out in the implementation notes for this feature.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Provide CRUD operations for notes linked to a contact and user
- Emit outbox mutations on save for offline-first sync
- Apply last-write-wins conflict resolution strategy
- Expose note state stream for Riverpod consumption by the editor screen
- Validate note ownership and contact association before save
Interfaces
createNote(contactId: String, content: String): Future<Note>
updateNote(noteId: String, content: String): Future<Note>
deleteNote(noteId: String): Future<void>
getNoteById(noteId: String): Future<Note?>
watchNote(noteId: String): Stream<Note?>
getNotesByContact(contactId: String): Future<List<Note>>
Relationships
Dependencies (2)
Components this component depends on