Back to Articles
AI Vision & Android SystemsJuly 20266 min read

Engineering Expiry Alert Pro: Gemini 2.0 Flash Vision & 16KB Page Size Architecture

By Rahul Lagariya • Developer of Expiry Alert Pro

Food and medication expiration causes billions in financial losses and unnecessary waste. When building Expiry Alert Pro, we recognized that user friction was the primary enemy: if logging a grocery item takes more than a few seconds, people abandon the app. Here is how we engineered sub-second multimodal capture and offline reliability.

At A Glance

  • • Package: com.expiryalertpro (Version 1.2.0, Target SDK 36)
  • • AI Core: Google Gemini 2.0 Flash Vision OCR with rate limiters
  • • Scanning: CameraX stream + Google ML Kit Barcode Analyzer
  • • Architecture: Android 15 16KB page-size compliant, 64-bit ABI filter

1. The Problem: The High Friction of Data Entry

Traditional inventory apps require manual typing of product names, brands, categories, purchase dates, and expiry dates. In a real-world supermarket or kitchen, nobody will manually enter 20 items after shopping. We set a hard requirement: point the camera at the package or receipt, tap once, and let AI do the rest.

2. Gemini 2.0 Flash Vision OCR Pipeline

We integrated the official com.google.ai.client.generativeai SDK with the gemini-2.0-flash model. Unlike traditional OCR that only produces unstructured text blocks, Gemini 2.0 Flash understands visual context: it differentiates between manufacturing dates, batch numbers, and actual expiry dates printed in varied formats (e.g. "EXP 08/26", "BEST BEFORE 12 MONTHS FROM MFD", or dot-matrix stamps).

By tuning generation parameters (temperature 0.15, maxOutputTokens 512) and applying strict client-side JSON serialization, the pipeline extracts structured data in under 800 milliseconds:

{
  "name": "Organic Almond Milk",
  "brand": "Silk",
  "category": "Dairy & Alternatives",
  "price": 280.0,
  "expiryDate": "2026-10-15",
  "quantity": "1L"
}

3. Algorithmic Risk Tiers & Waste Analytics

Once saved, products enter our algorithmic ExpiryRiskEngine:

  • Safe: More than 7 days remaining.
  • Upcoming: 2 to 7 days remaining (prompts consumption planning).
  • Critical: 0 to 1 days remaining (high-priority urgent alert).
  • Expired: Moved to waste auditing log.

Our WasteAnalyticsEngine aggregates historical logs to show users exact financial metrics: total monetary value of items saved versus wasted, enabling households and merchants to see tangible ROI.

4. Android 15 & 16 KB Page Size Readiness

Starting with Android 15, devices support 16 KB memory page sizes (replacing traditional 4 KB pages) for dramatic performance improvements. However, native C++ libraries (JNI) must be recompiled and packaged appropriately.

We restricted NDK ABI filters to pure 64-bit architectures (arm64-v8a and x86_64), eliminated 32-bit legacy packaging, and audited all dependencies (CameraX, ML Kit, Room) to ensure zero page-fault crashes on Android 15+ devices.

5. Resilient Background Alert Scheduling

Push notifications for expiring stock cannot fail. We deployed a dual-scheduling mechanism: WorkManager handles daily periodic inventory scans, while AlarmManager schedules exact alarm triggers for critical deadlines. A dedicated BootReceiver listens for ACTION_BOOT_COMPLETED to reschedule all alarms immediately whenever the user restarts their phone.

Experience Expiry Alert Pro

Expiry Alert Pro is available globally on Google Play and features an interactive browser shelf-life simulator on our companion web platform.