# johnweslykurasa/buy-pilot architecture

> Architecture diagram of the GitHub repository johnweslykurasa/buy-pilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/johnweslykurasa/buy-pilot
- Repository: https://github.com/johnweslykurasa/buy-pilot

## Overview

Buy Pilot is a product-search and comparison application, with a Next.js frontend and two visible API implementations: a root-level Next.js API and a separate Express backend. The search workflow collects marketplace offers and groups matching products; the UI also exposes visual search, account access, and wishlists. The tree and excerpts show both stacks but do not establish which one the frontend uses for every feature, so those connections are omitted. Several backend routes and integrations are represented by their source paths, but their internal behavior was not sampled.

Main entry points: [`backend/src/routes/search.ts`](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/search.ts) (Search route), [`backend/src/server.ts`](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/server.ts) (API server), [`frontend/src/components/SearchHeader.tsx`](https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/SearchHeader.tsx) (Search interface), [`backend/src/routes/auth.ts`](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/auth.ts) (Authentication routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Frontend experience"]
  node_searchui["Search interface<br/>[SearchHeader.tsx]"]
  node_visual["Visual search"]
  node_authui["Account modal<br/>[AuthModal.tsx]"]
  node_wishlistui["Wishlist drawer<br/>[WishlistDrawer.tsx]"]
  node_home["Home page<br/>[page.tsx]"]
end

subgraph group_nextapi["Next.js API"]
  node_nextsearch["Search route<br/>[route.ts]"]
  node_nextanalyze["Analysis route<br/>[route.ts]"]
end

subgraph group_express["Express API"]
  node_expressserver["API server<br/>[server.ts]"]
  node_expresssearch["Search route<br/>[search.ts]"]
  node_analyze["Analysis route<br/>[analyze.ts]"]
  node_vision["Vision route<br/>[vision.ts]"]
  node_auth["Authentication routes<br/>[auth.ts]"]
  node_jwt["JWT middleware<br/>[auth.ts]"]
  node_wishlist["Wishlist route<br/>[wishlist.ts]"]
  node_dbclient["Prisma client<br/>[prisma.ts]"]
end

subgraph group_searchdata["Search providers and data"]
  node_nextproviders["Marketplace scrapers"]
  node_providers["Marketplace providers"]
  node_yahoo["Yahoo fallback<br/>[yahooHelper.ts]"]
  node_producttypes["Product types<br/>[types.ts]"]
  node_serp["SerpApi provider<br/>[SerpApiProvider.ts]"]
  node_amazon["Amazon provider<br/>[AmazonProvider.ts]"]
  node_flipkart["Flipkart provider"]
  node_myntra["Myntra provider<br/>[MyntraProvider.ts]"]
end

node_shopper(("Shopper"))
node_store[("Database")]

node_shopper -->|"searches"| node_searchui
node_shopper -.->|"opens"| node_home
node_searchui -->|"opens"| node_visual
node_searchui -->|"opens"| node_authui
node_searchui -->|"opens"| node_wishlistui
node_expressserver -->|"mounts route"| node_expresssearch
node_expressserver -->|"mounts route"| node_analyze
node_expressserver -->|"mounts route"| node_vision
node_expressserver -->|"mounts route"| node_auth
node_expressserver -->|"mounts route"| node_wishlist
node_expresssearch -->|"dispatches searches"| node_providers
node_expresssearch -->|"queries"| node_serp
node_expresssearch -->|"queries"| node_amazon
node_expresssearch -->|"queries"| node_flipkart
node_expresssearch -->|"queries"| node_myntra
node_expresssearch -->|"groups offers"| node_providers
node_auth -->|"authenticates with"| node_jwt
node_auth -->|"reads and writes"| node_dbclient
node_wishlist -->|"authenticates with"| node_jwt
node_wishlist -->|"reads and writes"| node_dbclient
node_dbclient -.->|"accesses"| node_store
node_amazon -.->|"uses fallback"| node_yahoo
node_flipkart -.->|"uses fallback"| node_yahoo
node_amazon -.->|"uses types"| node_producttypes
node_flipkart -.->|"uses types"| node_producttypes
node_myntra -.->|"uses types"| node_producttypes
node_nextsearch -->|"dispatches searches"| node_nextproviders
node_nextanalyze -.->|"analyzes search results"| node_nextsearch

click node_searchui "https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/SearchHeader.tsx"
click node_visual "https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/VisualSearchModal.tsx"
click node_authui "https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/AuthModal.tsx"
click node_wishlistui "https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/WishlistDrawer.tsx"
click node_home "https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/app/page.tsx"
click node_nextsearch "https://github.com/johnweslykurasa/buy-pilot/blob/main/src/app/api/search/route.ts"
click node_nextanalyze "https://github.com/johnweslykurasa/buy-pilot/blob/main/src/app/api/analyze/route.ts"
click node_nextproviders "https://github.com/johnweslykurasa/buy-pilot/tree/main/src/lib/providers"
click node_expressserver "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/server.ts"
click node_expresssearch "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/search.ts"
click node_analyze "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/analyze.ts"
click node_vision "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/vision.ts"
click node_auth "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/auth.ts"
click node_jwt "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/middleware/auth.ts"
click node_wishlist "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/wishlist.ts"
click node_dbclient "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/prisma.ts"
click node_providers "https://github.com/johnweslykurasa/buy-pilot/tree/main/backend/src/lib/providers"
click node_yahoo "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/yahooHelper.ts"
click node_producttypes "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/types.ts"
click node_serp "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/SerpApiProvider.ts"
click node_amazon "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/AmazonProvider.ts"
click node_flipkart "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/FlipkartProvider.ts"
click node_myntra "https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/MyntraProvider.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_searchui,node_visual,node_authui,node_wishlistui,node_home toneBlue
class node_nextsearch,node_nextanalyze,node_store toneAmber
class node_expressserver,node_expresssearch,node_analyze,node_vision,node_auth,node_jwt,node_wishlist,node_dbclient toneMint
class node_nextproviders,node_providers,node_yahoo,node_producttypes,node_serp,node_amazon,node_flipkart,node_myntra toneRose
class node_shopper toneIndigo
```

## Components

### Frontend experience

- [Search interface](https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/SearchHeader.tsx): `frontend/src/components/SearchHeader.tsx`
- [Visual search](https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/VisualSearchModal.tsx): `frontend/src/components/VisualSearchModal.tsx`
- [Account modal](https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/AuthModal.tsx): `frontend/src/components/AuthModal.tsx`
- [Wishlist drawer](https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/components/WishlistDrawer.tsx): `frontend/src/components/WishlistDrawer.tsx`
- [Home page](https://github.com/johnweslykurasa/buy-pilot/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`

### Next.js API

- [Search route](https://github.com/johnweslykurasa/buy-pilot/blob/main/src/app/api/search/route.ts): `src/app/api/search/route.ts`
- [Analysis route](https://github.com/johnweslykurasa/buy-pilot/blob/main/src/app/api/analyze/route.ts): `src/app/api/analyze/route.ts`

### Express API

- [API server](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Search route](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/search.ts): `backend/src/routes/search.ts`
- [Analysis route](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/analyze.ts): `backend/src/routes/analyze.ts`
- [Vision route](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/vision.ts): `backend/src/routes/vision.ts`
- [Authentication routes](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [JWT middleware](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`
- [Wishlist route](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/routes/wishlist.ts): `backend/src/routes/wishlist.ts`
- [Prisma client](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/prisma.ts): `backend/src/lib/prisma.ts`

### Search providers and data

- [Marketplace scrapers](https://github.com/johnweslykurasa/buy-pilot/tree/main/src/lib/providers): `src/lib/providers`
- [Marketplace providers](https://github.com/johnweslykurasa/buy-pilot/tree/main/backend/src/lib/providers): `backend/src/lib/providers`
- [Yahoo fallback](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/yahooHelper.ts): `backend/src/lib/yahooHelper.ts`
- [Product types](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/types.ts): `backend/src/lib/types.ts`
- [SerpApi provider](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/SerpApiProvider.ts): `backend/src/lib/providers/SerpApiProvider.ts`
- [Amazon provider](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/AmazonProvider.ts): `backend/src/lib/providers/AmazonProvider.ts`
- [Flipkart provider](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/FlipkartProvider.ts): `backend/src/lib/providers/FlipkartProvider.ts`
- [Myntra provider](https://github.com/johnweslykurasa/buy-pilot/blob/main/backend/src/lib/providers/MyntraProvider.ts): `backend/src/lib/providers/MyntraProvider.ts`

### Other components

- **Shopper**
- **Database**

## Connections

- Shopper → Search interface: searches (evidence: `frontend/src/components/SearchHeader.tsx`)
- Shopper → Home page: opens
- Search interface → Visual search: opens (evidence: `frontend/src/components/SearchHeader.tsx`)
- Search interface → Account modal: opens (evidence: `frontend/src/components/SearchHeader.tsx`)
- Search interface → Wishlist drawer: opens (evidence: `frontend/src/components/SearchHeader.tsx`)
- API server → Search route: mounts route (evidence: `backend/src/server.ts`)
- API server → Analysis route: mounts route (evidence: `backend/src/server.ts`)
- API server → Vision route: mounts route (evidence: `backend/src/server.ts`)
- API server → Authentication routes: mounts route (evidence: `backend/src/server.ts`)
- API server → Wishlist route: mounts route (evidence: `backend/src/server.ts`)
- Search route → Marketplace providers: dispatches searches (evidence: `backend/src/routes/search.ts`)
- Search route → SerpApi provider: queries (evidence: `backend/src/routes/search.ts`)
- Search route → Amazon provider: queries (evidence: `backend/src/routes/search.ts`)
- Search route → Flipkart provider: queries (evidence: `backend/src/routes/search.ts`)
- Search route → Myntra provider: queries (evidence: `backend/src/routes/search.ts`)
- Search route → Marketplace providers: groups offers (evidence: `backend/src/routes/search.ts`)
- Authentication routes → JWT middleware: authenticates with (evidence: `backend/src/routes/auth.ts`)
- Authentication routes → Prisma client: reads and writes (evidence: `backend/src/routes/auth.ts`)
- Wishlist route → JWT middleware: authenticates with (evidence: `backend/src/routes/wishlist.ts`)
- Wishlist route → Prisma client: reads and writes (evidence: `backend/src/routes/wishlist.ts`)
- Prisma client → Database: accesses
- Amazon provider → Yahoo fallback: uses fallback (evidence: `backend/src/lib/providers/AmazonProvider.ts`)
- Flipkart provider → Yahoo fallback: uses fallback (evidence: `backend/src/lib/providers/FlipkartProvider.ts`)
- Amazon provider → Product types: uses types (evidence: `backend/src/lib/providers/AmazonProvider.ts`)
- Flipkart provider → Product types: uses types (evidence: `backend/src/lib/providers/FlipkartProvider.ts`)
- Myntra provider → Product types: uses types (evidence: `backend/src/lib/providers/MyntraProvider.ts`)
- Search route → Marketplace scrapers: dispatches searches (evidence: `src/app/api/search/route.ts`)
- Analysis route → Search route: analyzes search results
