Service Layer medium complexity mobilebackend
0
Dependencies
0
Dependents
2
Entities
0
Integrations

Description

Backend-bound service responsible for compressing captured images client-side to a target of 500 KB or below, computing a SHA-256 content hash for deduplication, and uploading the resulting blob to the S3-compatible object store. Manages offline queuing via the mutation outbox and returns a structured receipt record linking the storage URL to the parent expense.

Feature: Receipt Photo Upload

receipt-upload-service

Sources & reasoning

Encapsulates compression, hashing, upload, and offline queuing logic so the UI widget stays presentation-only. The implementation notes specify client-side compression to ≤500 KB, SHA-256 deduplication, and offline blob storage in Drift - all owned by this service layer.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • Compress image to target ≤500 KB before upload
  • Compute SHA-256 hash for deduplication and integrity checking
  • Upload compressed blob to S3-compatible object store
  • Queue upload in mutation outbox when offline
  • Return upload result including storage URL and file metadata

Interfaces

compressImage(file: File, targetKb: int) -> Uint8List
hashContent(bytes: Uint8List) -> String
upload(bytes: Uint8List, expenseId: String) -> ReceiptRecord
queueOffline(bytes: Uint8List, expenseId: String) -> void
checkDuplicate(hash: String) -> ReceiptRecord?

Related Data Entities (2)

Data entities managed by this component