[APP-AB-02] Reactive Fridge Updates via WebSocket

Ingestion Event Integration

Published

August 14, 2026

NoteTask Brief
  • Repository / Component: food_tracker_mobile (Dart / Flutter).
  • Task Type: Frontend / Integration.
  • Technology Stack: WebSockets / web_socket_channel.
  • Status: Under Analysis

Task Description

To avoid making the user wait for the completion of the AI processing and queue pipeline on the ingestion screen, the data updates must be transitioned to a reactive workflow. The user should be able to exit the ingestion screen immediately, and new products will automatically appear in their fridge in real time.

Step-by-Step Instructions for Flutter

  1. WebSocket Connection: Upon application startup, initialize a persistent WebSocket connection inside a background service: wss://://foodtracker.com{user_token}.
  2. Subscribing to Queue Events: Implement data stream listening from the WebSocket to intercept events of type PRODUCTS_PROCESSED.
  3. Event Handling: Upon receiving a PRODUCTS_PROCESSED event (which the backend transmits immediately after a worker reads the message from the topic and commits it to Postgres):
    • Trigger a product list update event: context.read<FridgeBloc>().add(FetchProducts()).
    • Display an in-app pop-up notification to the user: “Successfully recognized X products from your receipt!”.
  4. Closing the Screen: On the manual entry or receipt scanning screens, immediately allow the user to navigate away using the “Back” button once the ID is received from S3, without blocking the interface.