Architecture

Cache Middleware

A perceptual hash cache middleware layer sits between the vision pipeline and the data layer. Items identified for the first time are fingerprinted and stored. Subsequent lookups on the same item resolve from cache without invoking the Vision API.

How it works

When a photo is submitted for identification, a perceptual hash (pHash) is computed from the image. The hash is a 64-dimension vector stored in Supabase with pgvector. Before calling the Vision API, the pipeline queries the cache using cosine similarity at a 0.85 threshold. A match returns the cached identification in under 500ms — no Vision API call required.

On a cache miss, the Vision API identifies the item, the result is stored with the pHash vector, and subsequent lookups on the same or visually similar item are served from cache.

Network effect

Cache density compounds across all deployments. Every item identified by any operator enriches the shared cache. A reseller processing 500 Nike Air Force 1s builds cache density that benefits every subsequent lookup on that item across the network — regardless of which deployment made the original identification.

Fresh lookups cost approximately 6-7 seconds and consume a vision call. Cached lookups return in under 500ms at a fraction of the cost.

Cache response indicator

Every response includes a cache field indicating whether the identification was served from cache:

{
  "cache": {
    "hit": true,
    "key": "phash:a3f2..."
  }
}
Duplicate prevention

Before storing a new cache entry, the pipeline checks for an existing entry with the same pHash. Duplicate entries are not created — the existing entry is updated if identification confidence has improved.