Expired Solutions — System Architecture

End-to-end technical map of the Expired Solutions platform: from iOS CoreML inference to Python/Azure backend and the marketing web layer.

iOS (SwiftUI + CoreML) Python (FastAPI) Azure (Cosmos/Blob/ML) Firebase (Web) Resend (Email) Hybrid Inference

Table of contents

1) System Component Inventory 2) iOS Scanning Pipeline 3) Backend & ML Architecture 4) Web & Marketing Layer 5) Data Flywheel & Training 6) Security & Operations

Overview

Expired Solutions is a hybrid AI platform. It combines instant on-device computer vision (CoreML) for shopper convenience with a powerful server-side pipeline (PyTorch + GPT-4o) for high-accuracy verification and training data collection.

Key Metrics:
  • ProduceClassifier: 99.04% Accuracy (77 classes)
  • FreshnessClassifier: 97.31% Quality Accuracy
  • Latency: ~50ms (On-device) vs ~500ms (Server)

1) System Component Inventory

Component Tech Stack Primary Responsibility Key Data
iOS App (Shopper) SwiftUI, Vision, CoreML User interface, real-time scanning, inventory management, local notifications Local CoreData, Keychain secrets
Backend API Python, FastAPI, Uvicorn Auth, sync, heavy inference, recipe generation, admin tools Azure Cosmos DB (MongoDB API)
ML Models PyTorch -> CoreML Produce ID & Freshness scoring (EfficientNet-B0 backbone) Azure Blob (Training Data)
Marketing Site Static HTML, Vercel Functions Landing pages, waitlist signups, legal docs Firebase Firestore (Signups)
Infrastructure Azure App Service, Vercel Hosting, scaling, serverless execution Resend (Email), Redis (Cache)

2) iOS Scanning Pipeline

The "HoverScan" experience prioritizes speed using local models, falling back to the server only when confidence is low.

Scan Flow (Device → Cloud)
Decision Logic
Camera Frame (CVPixelBuffer)
  |
  v
FreshnessAnalyzer (CoreML)
  |-- ProduceClassifier (EfficientNet-B0) -> { type: "apple", conf: 0.95 }
  |-- FreshnessClassifier (MobileNetV3)   -> { score: 85, days: 7 }
  |
  v
Decision Gate
  |
  |-- High Confidence (>0.85)?
  |     -> Show result immediately (Green Flash)
  |
  `-- Low Confidence?
        -> Trigger "/api/v1/hover/quick-analyze"
        -> Backend runs TwoModelService (PyTorch)
        -> If still ambiguous -> GPT-4 Vision (Fallback)
          
Key iOS Files
  • Pilot/HoverScanView.swift: Real-time camera & UI coordinator
  • Pilot/FreshnessAnalyzer.swift: CoreML inference wrapper
  • Services/SyncEngine.swift: Offline-first inventory sync

3) Backend & ML Architecture

The Python backend handles complex logic, user data sync, and the continuous learning pipeline.

API Request Flow
POST /api/v1/shopper/analyze
  |
  |-- Auth Middleware (JWT Validation)
  |-- Rate Limit (Redis/Memory)
  |
  |-- Image Upload -> Azure Blob Storage (Permanent Archive)
  |
  |-- Inference Pipeline:
  |     1. TwoModelService (PyTorch - Fast)
  |     2. If Low Confidence -> HybridClassifier (GPT-4o Vision)
  |
  |-- Data Enrichment:
  |     - Fetch Nutrition Data (Local DB)
  |     - Check Diet Compatibility (User Prefs)
  |     - Fetch Storage Tips
  |
  `-- Return JSON + Async Training Log
          
ML Training Loop (Azure)
1. Data Ingestion
   - User scans (Azure Blob)
   - Open Datasets (Kaggle/Fruits360)
   - Timelapse Frames

2. Automated Labeling
   - High conf -> Auto-label
   - Medium conf -> GPT-4o Labeling
   - Low conf -> Human Review Queue

3. Weekly Retraining (Azure ML Pipeline)
   - Train EfficientNet-B0 on new data
   - Eval vs Gold Set (Must pass gates: F1 > 0.85)
   - Export .mlpackage for iOS
          

4) Web & Marketing Layer

This repository (ExpiredSolutionsWeb). Lightweight, high-performance static site with serverless hooks.

Signup & Contact Flow
User submits form (Shoppers/Interest/Contact)
  |
  v
Vercel Serverless Function (/api/*.js)
  |
  |-- Validation (Honeypot, Email Regex)
  |-- Auth (Service Account via Env Vars)
  |
  |-- Firestore Write
  |     -> "shoppers_waitlist" / "contact_submissions"
  |
  `-- Resend Email
        -> To User: "Welcome to Waitlist"
        -> To Admin: "New Submission Alert"
          
Admin Dashboard Flow
GET /admin-shoppers.html
  |
  v
Client JS requests /api/shoppers-signups
  |-- Header: x-admin-token
  |
  v
API validates token vs Env Var
  -> Fetches Firestore collection
  -> Returns JSON list
  -> Rendered in browser (Table + CSV Export)
          

5) Data Flywheel & Training

How the system gets smarter over time.

6) Security & Operations