# bhavygandhi125273-sketch/ai-product-finder architecture

> Architecture diagram of the GitHub repository bhavygandhi125273-sketch/ai-product-finder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhavygandhi125273-sketch/ai-product-finder
- Repository: https://github.com/bhavygandhi125273-sketch/ai-product-finder
- Video tour (about a minute): https://gitdiagram.com/bhavygandhi125273-sketch/ai-product-finder/video

## Overview

Product Finder is a web app for uploading a product photo, identifying the primary item with AI, and finding similar products through visual search. The main workflow runs through the client page, which prepares the image and calls separate analysis and product-search endpoints, then displays the identification and product results. The product-search endpoint compresses and uploads the image before querying Google Lens via SerpApi. The README is only the Next.js starter template; the supplied page excerpt omits some request and state-handling code, so the graph shows only wiring supported by the excerpts.

Main entry points: [`app/page.tsx`](https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/page.tsx) (Upload and results UI), [`app/api/products/route.ts`](https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/api/products/route.ts) (Image product-search API), [`app/api/analyze/route.ts`](https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/api/analyze/route.ts) (Product identification API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_page["Upload and results UI<br/>[page.tsx]"]
end

subgraph group_identification["AI Identification"]
  node_analyze["Product identification API<br/>[route.ts]"]
end

subgraph group_search["Visual Product Search"]
  node_products["Image product-search API<br/>[route.ts]"]
end

node_user(("Photo uploader"))
node_openai{{"OpenAI"}}
node_serpapi{{"SerpApi / Google Lens"}}

node_user -->|"uploads photo"| node_page
node_page -->|"submits image"| node_analyze
node_page -->|"submits image"| node_products
node_analyze -->|"requests identification"| node_openai
node_openai -->|"returns analysis"| node_analyze
node_analyze -->|"returns result"| node_page
node_products -->|"uploads image"| node_serpapi
node_products -->|"searches products"| node_serpapi
node_products -->|"returns matches"| node_page

click node_page "https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/page.tsx"
click node_analyze "https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/api/analyze/route.ts"
click node_products "https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/api/products/route.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page toneBlue
class node_analyze toneAmber
class node_products,node_serpapi toneMint
class node_user,node_openai toneIndigo
```

## Components

### User Interface

- [Upload and results UI](https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/page.tsx): `app/page.tsx`

### AI Identification

- [Product identification API](https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/api/analyze/route.ts): `app/api/analyze/route.ts`

### Visual Product Search

- [Image product-search API](https://github.com/bhavygandhi125273-sketch/ai-product-finder/blob/main/app/api/products/route.ts): `app/api/products/route.ts`

### Other components

- **Photo uploader**
- **OpenAI**
- **SerpApi / Google Lens**

## Connections

- Photo uploader → Upload and results UI: uploads photo
- Upload and results UI → Product identification API: submits image
- Upload and results UI → Image product-search API: submits image
- Product identification API → OpenAI: requests identification
- OpenAI → Product identification API: returns analysis
- Product identification API → Upload and results UI: returns result
- Image product-search API → SerpApi / Google Lens: uploads image
- Image product-search API → SerpApi / Google Lens: searches products
- Image product-search API → Upload and results UI: returns matches
