# sohaibwaheed2006-beep/priceout architecture

> Architecture diagram of the GitHub repository sohaibwaheed2006-beep/priceout, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sohaibwaheed2006-beep/priceout
- Repository: https://github.com/sohaibwaheed2006-beep/priceout

## Overview

PriceScout Pakistan lets shoppers search live prices across Pakistani stores, compare matching listings, assess fair prices, check a proposed purchase price, and find nearby branches. The main flow runs from React pages through the shared API client to Express routes and controllers, then into search, comparison, or location services and MongoDB. Separate branches cover AI description/advice, store scraping, deals, and OpenStreetMap shops. Some subsystem links are documented in the README or source index; unsampled implementation details are not inferred.

Main entry points: [`server/src/services/searchService.js`](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/searchService.js) (Search service), [`client/src/services/api.js`](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/services/api.js) (API client), [`server/src/routes/index.js`](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/routes/index.js) (REST routes), [`server/src/controllers/priceCheckController.js`](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/priceCheckController.js) (Price-check controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Shopper experience"]
  node_pages["React pages"]
  node_searchbox["Search box<br/>[SearchBar.jsx]"]
  node_itemui["Product details<br/>[ItemPage.jsx]"]
  node_nearbyui["Nearby page<br/>[NearbyPage.jsx]"]
  node_checkui["Price check page<br/>[PriceCheckPage.jsx]"]
  node_clientapi["API client<br/>[api.js]"]
end

subgraph group_api["API workflow"]
  node_express["Express app<br/>[app.js]"]
  node_routes["REST routes<br/>[index.js]"]
  node_searchctl["Search controller"]
  node_itemctl["Item controller<br/>[itemController.js]"]
  node_checkctl["Price-check controller"]
  node_nearbyctl["Nearby controller"]
end

subgraph group_sourcing["Price intelligence"]
  node_searchsvc["Search service<br/>[searchService.js]"]
  node_comparesvc["Comparison service<br/>[compareService.js]"]
  node_scrapers["Store adapters<br/>[stores.js]"]
  node_models[("MongoDB models")]
  node_matching["Product matching<br/>[matching.js]"]
  node_ranges["Fair price range<br/>[priceRange.js]"]
  node_pricecheck["Price verdict<br/>[priceCheck.js]"]
  node_aisvc["AI services<br/>[aiService.js]"]
end

subgraph group_location["Nearby services"]
  node_nearby["Nearby service<br/>[nearbyService.js]"]
  node_shopmodel[("Shop records<br/>[Shop.js]")]
end

node_shopper(("Shopper"))
node_stores{{"Online stores"}}
node_gemini{{"Gemini AI"}}
node_osm{{"OpenStreetMap"}}

node_shopper -->|"uses"| node_pages
node_pages -->|"requests"| node_clientapi
node_searchbox -->|"suggests"| node_clientapi
node_pages -->|"renders"| node_searchbox
node_clientapi -->|"REST requests"| node_express
node_express -->|"mounts"| node_routes
node_routes -->|"routes"| node_searchctl
node_routes -->|"routes"| node_itemctl
node_routes -->|"routes"| node_checkctl
node_routes -->|"routes"| node_nearbyctl
node_searchctl -->|"searches"| node_searchsvc
node_itemctl -->|"loads details"| node_comparesvc
node_itemctl -->|"requests advice"| node_aisvc
node_checkctl -->|"searches query"| node_searchsvc
node_checkctl -->|"loads listing"| node_comparesvc
node_checkctl -->|"evaluates price"| node_pricecheck
node_checkctl -->|"finds branches"| node_nearby
node_nearbyctl -->|"finds shops"| node_nearby
node_searchsvc -->|"searches stores"| node_scrapers
node_scrapers -->|"fetches listings"| node_stores
node_searchsvc -->|"reads and saves"| node_models
node_searchsvc -->|"filters matches"| node_matching
node_searchsvc -->|"computes range"| node_ranges
node_comparesvc -->|"reads prices"| node_models
node_comparesvc -->|"matches products"| node_matching
node_comparesvc -->|"computes range"| node_ranges
node_aisvc -->|"requests advice"| node_gemini
node_nearby -->|"reads and saves"| node_shopmodel
node_nearby -->|"downloads shop data"| node_osm
node_nearby -->|"uses store names"| node_scrapers
node_nearbyui -.->|"requests shops"| node_clientapi
node_checkui -.->|"submits check"| node_clientapi
node_itemui -.->|"loads product"| node_clientapi

click node_pages "https://github.com/sohaibwaheed2006-beep/priceout/tree/main/client/src/pages"
click node_searchbox "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/components/SearchBar.jsx"
click node_itemui "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/pages/ItemPage.jsx"
click node_nearbyui "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/pages/NearbyPage.jsx"
click node_checkui "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/pages/PriceCheckPage.jsx"
click node_clientapi "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/services/api.js"
click node_express "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/app.js"
click node_routes "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/routes/index.js"
click node_searchctl "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/searchController.js"
click node_itemctl "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/itemController.js"
click node_checkctl "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/priceCheckController.js"
click node_nearbyctl "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/nearbyController.js"
click node_searchsvc "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/searchService.js"
click node_comparesvc "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/compareService.js"
click node_scrapers "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/scrapers/stores.js"
click node_models "https://github.com/sohaibwaheed2006-beep/priceout/tree/main/server/src/models"
click node_matching "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/utils/matching.js"
click node_ranges "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/utils/priceRange.js"
click node_pricecheck "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/utils/priceCheck.js"
click node_aisvc "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/aiService.js"
click node_nearby "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/nearbyService.js"
click node_shopmodel "https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/models/Shop.js"

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_pages,node_searchbox,node_itemui,node_nearbyui,node_checkui,node_clientapi toneBlue
class node_express,node_routes,node_searchctl,node_itemctl,node_checkctl,node_nearbyctl toneAmber
class node_searchsvc,node_comparesvc,node_scrapers,node_models,node_matching,node_ranges,node_pricecheck,node_aisvc toneMint
class node_nearby,node_shopmodel toneRose
class node_shopper,node_stores,node_gemini,node_osm toneIndigo
```

## Components

### Shopper experience

- [React pages](https://github.com/sohaibwaheed2006-beep/priceout/tree/main/client/src/pages): `client/src/pages`
- [Search box](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/components/SearchBar.jsx): `client/src/components/SearchBar.jsx`
- [Product details](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/pages/ItemPage.jsx): `client/src/pages/ItemPage.jsx`
- [Nearby page](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/pages/NearbyPage.jsx): `client/src/pages/NearbyPage.jsx`
- [Price check page](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/pages/PriceCheckPage.jsx): `client/src/pages/PriceCheckPage.jsx`
- [API client](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/client/src/services/api.js): `client/src/services/api.js`

### API workflow

- [Express app](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/app.js): `server/src/app.js`
- [REST routes](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/routes/index.js): `server/src/routes/index.js`
- [Search controller](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/searchController.js): `server/src/controllers/searchController.js`
- [Item controller](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/itemController.js): `server/src/controllers/itemController.js`
- [Price-check controller](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/priceCheckController.js): `server/src/controllers/priceCheckController.js`
- [Nearby controller](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/controllers/nearbyController.js): `server/src/controllers/nearbyController.js`

### Price intelligence

- [Search service](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/searchService.js): `server/src/services/searchService.js`
- [Comparison service](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/compareService.js): `server/src/services/compareService.js`
- [Store adapters](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/scrapers/stores.js): `server/src/scrapers/stores.js`
- [MongoDB models](https://github.com/sohaibwaheed2006-beep/priceout/tree/main/server/src/models): `server/src/models`
- [Product matching](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/utils/matching.js): `server/src/utils/matching.js`
- [Fair price range](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/utils/priceRange.js): `server/src/utils/priceRange.js`
- [Price verdict](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/utils/priceCheck.js): `server/src/utils/priceCheck.js`
- [AI services](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/aiService.js): `server/src/services/aiService.js`

### Nearby services

- [Nearby service](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/services/nearbyService.js): `server/src/services/nearbyService.js`
- [Shop records](https://github.com/sohaibwaheed2006-beep/priceout/blob/main/server/src/models/Shop.js): `server/src/models/Shop.js`

### Other components

- **Shopper**
- **Online stores**
- **Gemini AI**
- **OpenStreetMap**

## Connections

- Shopper → React pages: uses
- React pages → API client: requests (evidence: `client/src/pages/SearchPage.jsx`)
- Search box → API client: suggests (evidence: `client/src/components/SearchBar.jsx`)
- React pages → Search box: renders (evidence: `client/src/pages/SearchPage.jsx`)
- API client → Express app: REST requests (evidence: `client/src/services/api.js`)
- Express app → REST routes: mounts (evidence: `server/src/app.js`)
- REST routes → Search controller: routes (evidence: `server/src/routes/index.js`)
- REST routes → Item controller: routes (evidence: `server/src/routes/index.js`)
- REST routes → Price-check controller: routes (evidence: `server/src/routes/index.js`)
- REST routes → Nearby controller: routes (evidence: `server/src/routes/index.js`)
- Search controller → Search service: searches (evidence: `server/src/controllers/searchController.js`)
- Item controller → Comparison service: loads details (evidence: `server/src/controllers/itemController.js`)
- Item controller → AI services: requests advice (evidence: `server/src/controllers/itemController.js`)
- Price-check controller → Search service: searches query (evidence: `server/src/controllers/priceCheckController.js`)
- Price-check controller → Comparison service: loads listing (evidence: `server/src/controllers/priceCheckController.js`)
- Price-check controller → Price verdict: evaluates price (evidence: `server/src/controllers/priceCheckController.js`)
- Price-check controller → Nearby service: finds branches (evidence: `server/src/controllers/priceCheckController.js`)
- Nearby controller → Nearby service: finds shops (evidence: `server/src/controllers/nearbyController.js`)
- Search service → Store adapters: searches stores (evidence: `server/src/services/searchService.js`)
- Store adapters → Online stores: fetches listings (evidence: `README.md`)
- Search service → MongoDB models: reads and saves (evidence: `server/src/services/searchService.js`)
- Search service → Product matching: filters matches (evidence: `server/src/services/searchService.js`)
- Search service → Fair price range: computes range (evidence: `server/src/services/searchService.js`)
- Comparison service → MongoDB models: reads prices (evidence: `server/src/services/compareService.js`)
- Comparison service → Product matching: matches products (evidence: `server/src/services/compareService.js`)
- Comparison service → Fair price range: computes range (evidence: `server/src/services/compareService.js`)
- AI services → Gemini AI: requests advice (evidence: `server/src/services/aiService.js`)
- Nearby service → Shop records: reads and saves (evidence: `server/src/services/nearbyService.js`)
- Nearby service → OpenStreetMap: downloads shop data (evidence: `README.md`)
- Nearby service → Store adapters: uses store names (evidence: `server/src/services/nearbyService.js`)
- Nearby page → API client: requests shops
- Price check page → API client: submits check
- Product details → API client: loads product (evidence: `client/src/pages/ItemPage.jsx`)
