Skip to content

Conversation

Copy link

Copilot AI commented Nov 7, 2025

Description

Extracted valuable API components from openfoodfacts-androidapp and adapted them for Kotlin Multiplatform. The androidapp is no longer the primary client, but its mature API layer provides comprehensive coverage worth preserving.

What's transferred:

  • ApiFields (338 lines): Field constants, localization helpers, field selection utilities for 200+ API fields
  • Search & filtering: 11 query methods (by name, category, brand, label, additive, allergen, country, packaging, store, contributor, completion state)
  • Robotoff integration: AI-powered product questions and insight annotation
  • Models: Search results, Question, QuestionsState, AnnotationResponse

Key adaptations:

  • Jackson → kotlinx.serialization (multiplatform compatibility)
  • Retrofit → Ktor (cross-platform HTTP)
  • Added FilterType enum for type safety (prevents invalid API paths)
  • Reduced duplication via private helper function

Usage example:

import openfoodfacts.github.scrachx.openfood.api.v0.service.impl.OpenFoodFactsKtorClient
import openfoodfacts.github.scrachx.openfood.api.v0.service.impl.RobotoffKtorClient

val client = OpenFoodFactsKtorClient()
val robotoff = RobotoffKtorClient()

// Search and filter
val results = client.searchProductsByName("nutella", page = 1)
val organic = client.getProductsByLabel("organic")
val french = client.getProductsByCountry("france")

// AI insights
val questions = robotoff.getProductQuestions("3017620422003", "en", 5)
val response = robotoff.annotateInsight(insightId, annotation = 1)

Test coverage:

  • Search/filter endpoints against live API
  • Robotoff question retrieval and annotation
  • ApiFields utility functions

Related issues

Fixes #1

Related PRs

Source: https://github.com/openfoodfacts/openfoodfacts-androidapp

Screenshots

N/A - API library changes only

Link to the automatically generated build APK

N/A - Library project, not an Android app

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • androidx.dev
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx8g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-7.5.1-bin/7jzzequgds1hbszbhq3npc5ng/gradle-7.5.1/lib/gradle-launcher-7.5.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.5.1 (dns block)
  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx8g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-7.5.1-bin/7jzzequgds1hbszbhq3npc5ng/gradle-7.5.1/lib/gradle-launcher-7.5.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.5.1 (dns block)
  • maven.pkg.jetbrains.space
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx8g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-7.5.1-bin/7jzzequgds1hbszbhq3npc5ng/gradle-7.5.1/lib/gradle-launcher-7.5.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.5.1 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Transfer the valuable parts of the codebase to openfoodfacts-kotlin</issue_title>
<issue_description>### Problem

  • We're not using this codebase as our main app anymore (at least for Open Food Facts)
  • It would be a shame to stop using/maintaining this Kotlin codebase
  • Transfer the valuable parts of the codebase to openfoodfacts-kotlin so that other apps can leverage it</issue_description>

Comments on the Issue (you are @copilot in this section)

@VaiTon @lonewolf2208 it's a really big work. We should first decide how to implement the kotlin sdk (also for @teolemon). We have to decide if we want to do it from zero or take the API part from the application and move it to a new repository.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Transfer valuable codebase parts to openfoodfacts-kotlin Transfer API layer from openfoodfacts-androidapp to multiplatform SDK Nov 7, 2025
Copilot AI requested a review from teolemon November 7, 2025 16:01
Copilot finished work on behalf of teolemon November 7, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged backlog

Development

Successfully merging this pull request may close these issues.

Transfer the valuable parts of the codebase to openfoodfacts-kotlin 🎯 What can I work on ? (openfoodfacts-kotlin)

2 participants