# chinmay-url/shopsmart architecture

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

- Interactive diagram: https://gitdiagram.com/chinmay-url/shopsmart
- Repository: https://github.com/chinmay-url/shopsmart

## Overview

ShopSmart turns live shopping results and product reviews into comparison and buying intelligence, with history tracking, saved products, alerts, and a conversational assistant. The main journey is search → compare → inspect product and review signals → decide whether to buy; signed-in users can also save products and track target prices. The graph combines documented capabilities with sampled calls and route wiring. Several page-to-API connections and unsampled implementations are not shown where their exact relationships cannot be verified.

Main entry points: [`server/server.js`](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/server.js) (Express API), [`client/src/App.js`](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/App.js) (React app), [`server/routes/reviews.js`](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/reviews.js) (Product and reviews), [`server/routes/alerts.js`](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/alerts.js) (Alert management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Shopping experience"]
  node_app["React app<br/>[App.js]"]
  node_search_ui["Search and results<br/>[Results.js]"]
  node_product_ui["Product details<br/>[ProductDetails.js]"]
  node_history_ui["Price history view<br/>[PriceHistory.js]"]
  node_alerts_ui["Price alerts view<br/>[PriceAlerts.js]"]
  node_profile_ui["Profile and saved items<br/>[Profile.js]"]
  node_auth_context["Session context<br/>[AuthContext.js]"]
  node_chat_ui["Shopping assistant UI<br/>[ChatWindow.jsx]"]
end

subgraph group_api["Application API"]
  node_server["Express API<br/>[server.js]"]
  node_search_api["Shopping search<br/>[search.js]"]
  node_reviews_api["Product and reviews<br/>[reviews.js]"]
  node_products_api["Saved products API<br/>[products.js]"]
  node_auth_api["Authentication API<br/>[auth.js]"]
  node_alerts_api["Alert management<br/>[alerts.js]"]
  node_history_api["History API<br/>[priceHistory.js]"]
  node_chat_api["Chat API<br/>[chat.js]"]
end

subgraph group_analysis["Intelligence and history"]
  node_research["Buying-signal analysis<br/>[researchAI.js]"]
  node_sentiment["Review sentiment<br/>[sentiment.js]"]
  node_history_analysis["Price-history analysis<br/>[priceHistory.js]"]
  node_store_history[("Store price history")]
  node_category_history["Category price history"]
end

subgraph group_identity["Accounts and alerts"]
  node_user_model[("User and saved items<br/>[User.js]")]
  node_alert_model[("Alert records<br/>[PriceAlert.js]")]
  node_auth_middleware["JWT authorization<br/>[auth.js]"]
  node_scheduler["Alert scheduler"]
  node_email["Email delivery<br/>[emailService.js]"]
end

node_shopper(("Shopper"))
node_serpapi["SerpApi"]
node_groq["Groq"]
node_mongodb[("MongoDB")]
node_mail_service["Email service"]

node_shopper -->|"uses"| node_app
node_app -->|"routes to"| node_search_ui
node_app -->|"routes to"| node_product_ui
node_app -->|"routes to"| node_history_ui
node_app -->|"routes to"| node_alerts_ui
node_app -->|"routes to"| node_profile_ui
node_app -->|"provides session"| node_auth_context
node_app -->|"renders"| node_chat_ui
node_search_ui -.->|"requests search"| node_search_api
node_product_ui -.->|"requests analysis"| node_reviews_api
node_history_ui -.->|"requests history"| node_history_api
node_alerts_ui -.->|"manages alerts"| node_alerts_api
node_profile_ui -.->|"manages saved items"| node_products_api
node_auth_context -->|"fetches user"| node_auth_api
node_chat_ui -->|"sends messages"| node_chat_api
node_server -->|"mounts route"| node_search_api
node_server -->|"mounts route"| node_reviews_api
node_server -->|"mounts route"| node_products_api
node_server -->|"mounts route"| node_auth_api
node_server -->|"mounts route"| node_alerts_api
node_server -->|"mounts route"| node_history_api
node_server -->|"mounts route"| node_chat_api
node_search_api -->|"fetches shopping data"| node_serpapi
node_search_api -->|"logs prices"| node_store_history
node_reviews_api -->|"fetches product details"| node_serpapi
node_reviews_api -->|"analyzes reviews"| node_sentiment
node_reviews_api -->|"gets product history"| node_history_analysis
node_reviews_api -->|"computes buying signals"| node_research
node_history_api -->|"reads history"| node_store_history
node_reviews_api -->|"scores value and credibility"| node_research
node_chat_api -->|"generates replies"| node_groq
node_auth_api -->|"reads and writes"| node_user_model
node_auth_api -->|"protects user route"| node_auth_middleware
node_auth_api -->|"sends OTP"| node_email
node_products_api -->|"requires token"| node_auth_middleware
node_products_api -->|"updates saved items"| node_user_model
node_alerts_api -->|"requires token"| node_auth_middleware
node_alerts_api -->|"manages alerts"| node_alert_model
node_alerts_api -->|"gets user details"| node_user_model
node_alerts_api -->|"sends notifications"| node_email
node_server -->|"starts after connection"| node_scheduler
node_scheduler -->|"checks tracked prices"| node_alert_model
node_scheduler -->|"records price checks"| node_store_history
node_scheduler -->|"sends price alerts"| node_email
node_email -->|"sends email"| node_mail_service
node_server -->|"connects"| node_mongodb
node_category_history -.->|"supplements history"| node_store_history

click node_app "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/App.js"
click node_search_ui "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/Results.js"
click node_product_ui "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/ProductDetails.js"
click node_history_ui "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/PriceHistory.js"
click node_alerts_ui "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/PriceAlerts.js"
click node_profile_ui "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/Profile.js"
click node_auth_context "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/context/AuthContext.js"
click node_chat_ui "https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/components/chatbot/ChatWindow.jsx"
click node_server "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/server.js"
click node_search_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/search.js"
click node_reviews_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/reviews.js"
click node_products_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/products.js"
click node_auth_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/auth.js"
click node_alerts_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/alerts.js"
click node_history_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/priceHistory.js"
click node_chat_api "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/chat.js"
click node_research "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/researchAI.js"
click node_sentiment "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/sentiment.js"
click node_history_analysis "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/priceHistory.js"
click node_store_history "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/storePriceHistory.js"
click node_category_history "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/categoryPriceHistory.js"
click node_user_model "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/models/User.js"
click node_alert_model "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/models/PriceAlert.js"
click node_auth_middleware "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/middleware/auth.js"
click node_scheduler "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/priceAlertScheduler.js"
click node_email "https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/emailService.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_app,node_search_ui,node_product_ui,node_history_ui,node_alerts_ui,node_profile_ui,node_auth_context,node_chat_ui toneBlue
class node_server,node_search_api,node_reviews_api,node_products_api,node_auth_api,node_alerts_api,node_history_api,node_chat_api,node_mongodb toneAmber
class node_research,node_sentiment,node_history_analysis,node_store_history,node_category_history,node_serpapi toneMint
class node_user_model,node_alert_model,node_auth_middleware,node_scheduler,node_email toneRose
class node_shopper,node_groq,node_mail_service toneIndigo
```

## Components

### Shopping experience

- [React app](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/App.js): `client/src/App.js`
- [Search and results](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/Results.js): `client/src/pages/Results.js`
- [Product details](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/ProductDetails.js): `client/src/pages/ProductDetails.js`
- [Price history view](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/PriceHistory.js): `client/src/pages/PriceHistory.js`
- [Price alerts view](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/PriceAlerts.js): `client/src/pages/PriceAlerts.js`
- [Profile and saved items](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/pages/Profile.js): `client/src/pages/Profile.js`
- [Session context](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/context/AuthContext.js): `client/src/context/AuthContext.js`
- [Shopping assistant UI](https://github.com/chinmay-url/shopsmart/blob/Chinmay/client/src/components/chatbot/ChatWindow.jsx): `client/src/components/chatbot/ChatWindow.jsx`

### Application API

- [Express API](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/server.js): `server/server.js`
- [Shopping search](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/search.js): `server/routes/search.js`
- [Product and reviews](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/reviews.js): `server/routes/reviews.js`
- [Saved products API](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/products.js): `server/routes/products.js`
- [Authentication API](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/auth.js): `server/routes/auth.js`
- [Alert management](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/alerts.js): `server/routes/alerts.js`
- [History API](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/priceHistory.js): `server/routes/priceHistory.js`
- [Chat API](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/routes/chat.js): `server/routes/chat.js`

### Intelligence and history

- [Buying-signal analysis](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/researchAI.js): `server/utils/researchAI.js`
- [Review sentiment](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/sentiment.js): `server/utils/sentiment.js`
- [Price-history analysis](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/priceHistory.js): `server/utils/priceHistory.js`
- [Store price history](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/storePriceHistory.js): `server/utils/storePriceHistory.js`
- [Category price history](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/categoryPriceHistory.js): `server/utils/categoryPriceHistory.js`

### Accounts and alerts

- [User and saved items](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/models/User.js): `server/models/User.js`
- [Alert records](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/models/PriceAlert.js): `server/models/PriceAlert.js`
- [JWT authorization](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/middleware/auth.js): `server/middleware/auth.js`
- [Alert scheduler](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/priceAlertScheduler.js): `server/utils/priceAlertScheduler.js`
- [Email delivery](https://github.com/chinmay-url/shopsmart/blob/Chinmay/server/utils/emailService.js): `server/utils/emailService.js`

### Other components

- **Shopper**
- **SerpApi**
- **Groq**
- **MongoDB**
- **Email service**

## Connections

- Shopper → React app: uses
- React app → Search and results: routes to (evidence: `client/src/App.js`)
- React app → Product details: routes to (evidence: `client/src/App.js`)
- React app → Price history view: routes to (evidence: `client/src/App.js`)
- React app → Price alerts view: routes to (evidence: `client/src/App.js`)
- React app → Profile and saved items: routes to (evidence: `client/src/App.js`)
- React app → Session context: provides session (evidence: `client/src/App.js`)
- React app → Shopping assistant UI: renders (evidence: `client/src/App.js`)
- Search and results → Shopping search: requests search
- Product details → Product and reviews: requests analysis
- Price history view → History API: requests history
- Price alerts view → Alert management: manages alerts
- Profile and saved items → Saved products API: manages saved items
- Session context → Authentication API: fetches user (evidence: `client/src/context/AuthContext.js`)
- Shopping assistant UI → Chat API: sends messages (evidence: `client/src/components/chatbot/ChatWindow.jsx`)
- Express API → Shopping search: mounts route (evidence: `server/server.js`)
- Express API → Product and reviews: mounts route (evidence: `server/server.js`)
- Express API → Saved products API: mounts route (evidence: `server/server.js`)
- Express API → Authentication API: mounts route (evidence: `server/server.js`)
- Express API → Alert management: mounts route (evidence: `server/server.js`)
- Express API → History API: mounts route (evidence: `server/server.js`)
- Express API → Chat API: mounts route (evidence: `server/server.js`)
- Shopping search → SerpApi: fetches shopping data
- Shopping search → Store price history: logs prices (evidence: `server/routes/search.js`)
- Product and reviews → SerpApi: fetches product details (evidence: `server/routes/reviews.js`)
- Product and reviews → Review sentiment: analyzes reviews (evidence: `server/routes/reviews.js`)
- Product and reviews → Price-history analysis: gets product history (evidence: `server/routes/reviews.js`)
- Product and reviews → Buying-signal analysis: computes buying signals (evidence: `server/routes/reviews.js`)
- History API → Store price history: reads history (evidence: `server/routes/priceHistory.js`)
- Product and reviews → Buying-signal analysis: scores value and credibility (evidence: `server/routes/reviews.js`)
- Chat API → Groq: generates replies
- Authentication API → User and saved items: reads and writes (evidence: `server/routes/auth.js`)
- Authentication API → JWT authorization: protects user route (evidence: `server/routes/auth.js`)
- Authentication API → Email delivery: sends OTP (evidence: `server/routes/auth.js`)
- Saved products API → JWT authorization: requires token (evidence: `server/routes/products.js`)
- Saved products API → User and saved items: updates saved items (evidence: `server/routes/products.js`)
- Alert management → JWT authorization: requires token (evidence: `server/routes/alerts.js`)
- Alert management → Alert records: manages alerts (evidence: `server/routes/alerts.js`)
- Alert management → User and saved items: gets user details (evidence: `server/routes/alerts.js`)
- Alert management → Email delivery: sends notifications (evidence: `server/routes/alerts.js`)
- Express API → Alert scheduler: starts after connection (evidence: `server/server.js`)
- Alert scheduler → Alert records: checks tracked prices (evidence: `server/utils/priceAlertScheduler.js`)
- Alert scheduler → Store price history: records price checks (evidence: `server/utils/priceAlertScheduler.js`)
- Alert scheduler → Email delivery: sends price alerts (evidence: `server/utils/priceAlertScheduler.js`)
- Email delivery → Email service: sends email (evidence: `server/utils/emailService.js`)
- Express API → MongoDB: connects (evidence: `server/server.js`)
- Category price history → Store price history: supplements history
