Add Cloud Run Vertex AI backend proxy#20
Merged
Bhagat-Atul merged 1 commit intoJun 9, 2026
Conversation
FastAPI service under backend/ that accepts OCR-extracted ingredient text and calls Gemini via Vertex AI using the Cloud Run service-account identity (ADC). No user API keys, no service-account JSON. Returns NOVA classification, ingredient analysis, ultra-processed markers, and likely allergens in a shape aligned to the app's existing Kotlin contract. Includes Dockerfile, tests with a mocked Gemini call, and Cloud Run deploy instructions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bhagat-Atul
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a small production-ready FastAPI backend under
backend/so the Android app can move off user-supplied AI API keys to a GCP-hosted proxy.POST /analyze), plus optional product name / barcode / locale.NovaClassification+IngredientListAnalysis+AllergenDetection) for drop-in future integration.Dockerfileand full deploy instructions inbackend/README.md.Endpoints
GET /healthz→{status:ok}POST /analyze→ combinednova/ingredients/allergensJSON.Robustness
Testing
pytest(8 tests, Gemini call mocked — no live creds needed): all pass.uvicornsmoke:/healthzok;/analyzereturns 502 without ADC (expected); overlong input → 422.$PORT.Deploy (see backend/README.md)
--allow-unauthenticatedis for initial testing only; protect before production (App Check / Firebase Auth / API Gateway).Notes
gemini-2.5-flashvaries; README documents aglobal/us-central1fallback ifus-east1rejects the model.🤖 Generated with Claude Code