LIVE · App Store & Google PlayCase study · Mobile Dev · AI/ML · Full Stack

plantUSA: plant identification in ~300 ms instead of ~8 s.

Sending every photo to a large vision model was slow and expensive. I moved identification onto a retrieval path: a short Gemini description, a vector search over our own plant catalog, and a quick verification step.

Role
Freelance AI engineer — mobile, data, AI pipeline
Result
~8 s → ~300 ms identification
Stack
Flutter · Supabase · pgvector · Gemini
plantUSA — AI Plant Identifier screenshot
01 / The problem

Full-model detection took ~8 seconds per photo — too slow for a camera app.

Users point the camera at a plant and expect an answer right away. The original flow asked a vision model to produce the full plant profile from scratch every time: slow, costly per call, and free to describe plants that are not in our catalog.

02 / Architecture

Describe, embed, retrieve, verify — then read from our own database.

  1. Flutter app
    compress to 512px
  2. Gemini
    name + embedding
  3. Supabase Postgres
    pgvector · match_plants
DETECTPhoto → Gemini returns common + scientific name → gemini-embedding-001 (768-dim) → match_plants top-5 by cosine distance → Gemini picks the best of the 5 → full record from the plants table
BACKFILLAdmin tool embeds every catalog plant and disease and stores vectors in Postgres; match_diseases serves the diagnosis side
03 / Key decisions

Trade-offs I made on purpose.

Retrieve from our catalog instead of generating answers

Results always come from curated plant records, so the app never shows a species we have no care data for.

Verify against 5 candidates, not 1

The nearest vector is not always right. A short second Gemini call picks from the top 5 by number, which is cheap and fixes most near-misses.

Strict timeouts and a fallback path

Each step has a timeout. If the RAG path fails or the catalog is not embedded yet, the app falls back to full model detection instead of showing an error.

Strict JSON for diagnosis

Health status, disease name and confidence level come back as structured JSON, so the Flutter UI renders them without parsing free text.

04 / Code excerpt
// match_plants.sql
CREATE OR REPLACE FUNCTION public.match_plants(
  query_embedding vector(768),
  match_count integer DEFAULT 5
) RETURNS TABLE (id uuid, common_name text, similarity double precision)
LANGUAGE sql STABLE AS $$
  SELECT id, common_name,
         1 - (embedding <=> query_embedding) AS similarity
  FROM public.plants
  WHERE embedding IS NOT NULL
  ORDER BY embedding <=> query_embedding
  LIMIT match_count;
$$;
Want this kind of ownership on your team?Let's talk