Skip to content

Feature: Search with local OpenFoodFacts database file#319

Open
manum45 wants to merge 15 commits intosimonoppowa:developfrom
manum45:off_local_db
Open

Feature: Search with local OpenFoodFacts database file#319
manum45 wants to merge 15 commits intosimonoppowa:developfrom
manum45:off_local_db

Conversation

@manum45
Copy link
Copy Markdown

@manum45 manum45 commented Apr 3, 2026

Description

Recently the OpenFoodFacts search API often isn't working, due to rate limiting or server issues. See https://status.openfoodfacts.org/. See also #157 and #229.
A new API seems to be planned, but I couldn't find any info on a timeline.

This pull request provides the option to search in a local database file (subset of the OpenFoodFacts database) to avoid using the search API. Nutrition details of a product are then fetched via the Barcode API when a product is select in the search results list. The barcode API seems to be a lot more reliable.

The database for search is roughly 230MB and could probably be reduced further.

This feature could also be extended so that the app can be used fully locally with the full OFF database, however this is 4GB (although some reduction should be possible, e.g. unused info, other languages, ...).

Usage description is available in Local_OpenFoodFacts_Database.md.

Open topics

I wanted to get some early feedback, especially on these points:

  • fetching of nutrition data is currently done synchronously when a meal item card is pressed. This causes noticeable stutter. What would be the right way to fetch this data?
  • I hardcoded the UI texts because I didn't figure out how to correctly run the l10n generator. It would give me error for the cz file and generate to the wrong directory. Can you give me a hint how to use it?
  • I noticed that I modified a generated file, to fix an issue where the barcode API response of a product does not provide nutriments. This currently leads to an exception in lib/features/add_meal/data/dto/off/off_product_dto.g.dart:OFFProductDTOFromJson(). I think this is described in [Bug] Query crashes during OFF search when products have missing nutriments data #306. What would be the right way to solve this?
  • Users have to create their own DB with the python script described in the markdown file. Should the reduced database be hosted somewhere and downloadable within the app?

Testing

I have tested this roughly my Android phone, and will daily drive it for the next days.
I don't have an iPhone, so I am not able to test it there.

@manum45
Copy link
Copy Markdown
Author

manum45 commented Apr 7, 2026

I think this app could be made to work fully offline.

Do you think this is a valuable feature? What would be required from your perspective?
I would be willing to invest some time for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant