# codewithmasood007/shopmind-ai architecture

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

- Interactive diagram: https://gitdiagram.com/codewithmasood007/shopmind-ai
- Repository: https://github.com/codewithmasood007/shopmind-ai

## Overview

ShopMind AI is a MERN storefront where shoppers browse or search products, manage a cart, place orders and pay; accounts, reviews and administration support that journey. Its distinct AI-search branch accepts natural-language and image-assisted queries and streams shopping-assistant responses, while product matching returns database-backed results. The graph covers routing, product/order persistence, authentication, Cloudinary uploads and Razorpay, plus frontend state and admin tools. Several frontend API and page modules are indexed but unsampled, so those relationships are shown only where documented or listed in the source index.

Main entry points: [`frontend/src/main.jsx`](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/main.jsx) (App navigation), [`backend/controllers/orderController.js`](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/orderController.js) (Order and payment), [`frontend/src/redux/api/orderApiSlice.js`](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/orderApiSlice.js) (Order API client), [`frontend/src/pages/Shop.jsx`](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Shop.jsx) (Browse products)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Storefront experience"]
  node_navigation["App navigation<br/>[main.jsx]"]
  node_storefront["Browse products<br/>[Shop.jsx]"]
  node_productview["Product detail<br/>[ProductDetails.jsx]"]
  node_cartcheckout["Cart and checkout<br/>[PlaceOrder.jsx]"]
  node_orderpages["Order views<br/>[Order.jsx]"]
  node_adminui["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_chatui["AI chat interface<br/>[AIChat.jsx]"]
end

subgraph group_state["Client state and API"]
  node_redux["Client state<br/>[store.js]"]
  node_authstate["Auth state<br/>[authSlice.js]"]
  node_cartstate["Cart state<br/>[cartSlice.js]"]
  node_productapi["Product API client<br/>[productApiSlice.js]"]
  node_categoryapi["Category API client"]
  node_orderapi["Order API client<br/>[orderApiSlice.js]"]
  node_userapi["User API client<br/>[usersApiSlice.js]"]
end

subgraph group_commerce["Commerce backend"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_productcontroller["Product operations"]
  node_productmodel[("Product catalog<br/>[productModel.js]")]
  node_categoryroutes["Category routes<br/>[categoryRoutes.js]"]
  node_categorycontroller["Category operations"]
  node_categorymodel[("Category records<br/>[categoryModels.js]")]
  node_orderroutes["Order routes<br/>[orderRoutes.js]"]
  node_ordercontroller["Order and payment<br/>[orderController.js]"]
  node_ordermodel[("Order records<br/>[orderModel.js]")]
end

subgraph group_identity["Accounts and access"]
  node_usercontroller["User operations<br/>[userController.js]"]
  node_usermodel[("User records<br/>[userModels.js]")]
  node_authmiddleware["Access control<br/>[authmiddleware.js]"]
end

subgraph group_ai["AI discovery and media"]
  node_chat["Streaming AI assistant<br/>[chatStream.js]"]
  node_productservice["AI product matching<br/>[productService.js]"]
  node_upload["Image uploads<br/>[uploadRoutes.js]"]
  node_cloudinary["Cloudinary storage<br/>[cloudinary.js]"]
end

node_shopper(("Shopper"))
node_admin(("Administrator"))
node_database[("MongoDB")]
node_razorpay["Razorpay"]

node_shopper -->|"opens storefront"| node_navigation
node_admin -->|"opens admin"| node_navigation
node_navigation -->|"routes to"| node_storefront
node_navigation -->|"routes to"| node_productview
node_navigation -->|"routes to"| node_cartcheckout
node_navigation -->|"routes to"| node_orderpages
node_navigation -->|"routes to"| node_adminui
node_storefront -->|"queries products"| node_productapi
node_storefront -->|"queries categories"| node_categoryapi
node_productview -->|"loads product"| node_productapi
node_productview -->|"adds to cart"| node_cartstate
node_cartcheckout -.->|"submits order"| node_orderapi
node_cartcheckout -.->|"reads cart"| node_cartstate
node_orderpages -->|"loads order"| node_orderapi
node_adminui -->|"queries orders"| node_orderapi
node_adminui -->|"queries users"| node_userapi
node_redux -->|"registers reducer"| node_authstate
node_redux -->|"registers reducer"| node_cartstate
node_productapi -.->|"calls API"| node_productroutes
node_categoryapi -.->|"calls API"| node_categoryroutes
node_orderapi -.->|"calls API"| node_orderroutes
node_userapi -.->|"calls API"| node_usercontroller
node_productroutes -->|"dispatches"| node_productcontroller
node_productcontroller -->|"reads and writes"| node_productmodel
node_categoryroutes -->|"dispatches"| node_categorycontroller
node_categorycontroller -->|"reads and writes"| node_categorymodel
node_orderroutes -->|"dispatches"| node_ordercontroller
node_ordercontroller -->|"reads and writes"| node_ordermodel
node_ordercontroller -->|"loads item prices"| node_productmodel
node_ordercontroller -->|"creates payment"| node_razorpay
node_productroutes -->|"guards admin actions"| node_authmiddleware
node_orderroutes -->|"guards orders"| node_authmiddleware
node_usercontroller -->|"reads and writes"| node_usermodel
node_authmiddleware -->|"loads identity"| node_usermodel
node_chatui -->|"streams queries"| node_chat
node_chat -->|"finds products"| node_productservice
node_productservice -->|"searches catalog"| node_productmodel
node_productservice -->|"matches category"| node_categorymodel
node_chatui -.->|"uploads image"| node_upload
node_upload -->|"stores image"| node_cloudinary

click node_navigation "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/main.jsx"
click node_storefront "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Shop.jsx"
click node_productview "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Products/ProductDetails.jsx"
click node_cartcheckout "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Orders/PlaceOrder.jsx"
click node_orderpages "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Orders/Order.jsx"
click node_adminui "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Admin/AdminDashboard.jsx"
click node_redux "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/store.js"
click node_authstate "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/features/auth/authSlice.js"
click node_cartstate "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/features/cart/cartSlice.js"
click node_productapi "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/productApiSlice.js"
click node_categoryapi "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/categoryApiSlice.js"
click node_orderapi "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/orderApiSlice.js"
click node_userapi "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/usersApiSlice.js"
click node_productroutes "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/productRoutes.js"
click node_productcontroller "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/productController.js"
click node_productmodel "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/productModel.js"
click node_categoryroutes "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/categoryRoutes.js"
click node_categorycontroller "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/categoryController.js"
click node_categorymodel "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/categoryModels.js"
click node_orderroutes "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/orderRoutes.js"
click node_ordercontroller "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/orderController.js"
click node_ordermodel "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/orderModel.js"
click node_usercontroller "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/userController.js"
click node_usermodel "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/userModels.js"
click node_authmiddleware "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/middlewares/authmiddleware.js"
click node_chat "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/chatStream.js"
click node_productservice "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/services/productService.js"
click node_chatui "https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/components/AIChat.jsx"
click node_upload "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/uploadRoutes.js"
click node_cloudinary "https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/config/cloudinary.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_navigation,node_storefront,node_productview,node_cartcheckout,node_orderpages,node_adminui,node_chatui toneBlue
class node_redux,node_authstate,node_cartstate,node_productapi,node_categoryapi,node_orderapi,node_userapi,node_database toneAmber
class node_productroutes,node_productcontroller,node_productmodel,node_categoryroutes,node_categorycontroller,node_categorymodel,node_orderroutes,node_ordercontroller,node_ordermodel toneMint
class node_usercontroller,node_usermodel,node_authmiddleware toneRose
class node_chat,node_productservice,node_upload,node_cloudinary,node_shopper,node_admin,node_razorpay toneIndigo
```

## Components

### Storefront experience

- [App navigation](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Browse products](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Shop.jsx): `frontend/src/pages/Shop.jsx`
- [Product detail](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Products/ProductDetails.jsx): `frontend/src/pages/Products/ProductDetails.jsx`
- [Cart and checkout](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Orders/PlaceOrder.jsx): `frontend/src/pages/Orders/PlaceOrder.jsx`
- [Order views](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Orders/Order.jsx): `frontend/src/pages/Orders/Order.jsx`
- [Admin dashboard](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/pages/Admin/AdminDashboard.jsx): `frontend/src/pages/Admin/AdminDashboard.jsx`
- [AI chat interface](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/components/AIChat.jsx): `frontend/src/components/AIChat.jsx`

### Client state and API

- [Client state](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/store.js): `frontend/src/redux/store.js`
- [Auth state](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/features/auth/authSlice.js): `frontend/src/redux/features/auth/authSlice.js`
- [Cart state](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/features/cart/cartSlice.js): `frontend/src/redux/features/cart/cartSlice.js`
- [Product API client](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/productApiSlice.js): `frontend/src/redux/api/productApiSlice.js`
- [Category API client](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/categoryApiSlice.js): `frontend/src/redux/api/categoryApiSlice.js`
- [Order API client](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/orderApiSlice.js): `frontend/src/redux/api/orderApiSlice.js`
- [User API client](https://github.com/codewithmasood007/shopmind-ai/blob/main/frontend/src/redux/api/usersApiSlice.js): `frontend/src/redux/api/usersApiSlice.js`

### Commerce backend

- [Product routes](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/productRoutes.js): `backend/routes/productRoutes.js`
- [Product operations](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Product catalog](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/productModel.js): `backend/models/productModel.js`
- [Category routes](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/categoryRoutes.js): `backend/routes/categoryRoutes.js`
- [Category operations](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/categoryController.js): `backend/controllers/categoryController.js`
- [Category records](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/categoryModels.js): `backend/models/categoryModels.js`
- [Order routes](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/orderRoutes.js): `backend/routes/orderRoutes.js`
- [Order and payment](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`
- [Order records](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/orderModel.js): `backend/models/orderModel.js`

### Accounts and access

- [User operations](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [User records](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/models/userModels.js): `backend/models/userModels.js`
- [Access control](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/middlewares/authmiddleware.js): `backend/middlewares/authmiddleware.js`

### AI discovery and media

- [Streaming AI assistant](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/chatStream.js): `backend/routes/chatStream.js`
- [AI product matching](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/services/productService.js): `backend/services/productService.js`
- [Image uploads](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/routes/uploadRoutes.js): `backend/routes/uploadRoutes.js`
- [Cloudinary storage](https://github.com/codewithmasood007/shopmind-ai/blob/main/backend/config/cloudinary.js): `backend/config/cloudinary.js`

### Other components

- **Shopper**
- **Administrator**
- **MongoDB**
- **Razorpay**

## Connections

- Shopper → App navigation: opens storefront (evidence: `frontend/src/main.jsx`)
- Administrator → App navigation: opens admin (evidence: `frontend/src/main.jsx`)
- App navigation → Browse products: routes to (evidence: `frontend/src/main.jsx`)
- App navigation → Product detail: routes to (evidence: `frontend/src/main.jsx`)
- App navigation → Cart and checkout: routes to (evidence: `frontend/src/main.jsx`)
- App navigation → Order views: routes to (evidence: `frontend/src/main.jsx`)
- App navigation → Admin dashboard: routes to (evidence: `frontend/src/main.jsx`)
- Browse products → Product API client: queries products (evidence: `frontend/src/pages/Shop.jsx`)
- Browse products → Category API client: queries categories (evidence: `frontend/src/pages/Shop.jsx`)
- Product detail → Product API client: loads product (evidence: `frontend/src/pages/Products/ProductDetails.jsx`)
- Product detail → Cart state: adds to cart (evidence: `frontend/src/pages/Products/ProductDetails.jsx`)
- Cart and checkout → Order API client: submits order
- Cart and checkout → Cart state: reads cart
- Order views → Order API client: loads order (evidence: `frontend/src/pages/Orders/Order.jsx`)
- Admin dashboard → Order API client: queries orders (evidence: `frontend/src/pages/Admin/AdminDashboard.jsx`)
- Admin dashboard → User API client: queries users (evidence: `frontend/src/pages/Admin/AdminDashboard.jsx`)
- Client state → Auth state: registers reducer (evidence: `frontend/src/redux/store.js`)
- Client state → Cart state: registers reducer (evidence: `frontend/src/redux/store.js`)
- Product API client → Product routes: calls API
- Category API client → Category routes: calls API
- Order API client → Order routes: calls API
- User API client → User operations: calls API
- Product routes → Product operations: dispatches (evidence: `backend/routes/productRoutes.js`)
- Product operations → Product catalog: reads and writes (evidence: `backend/controllers/productController.js`)
- Category routes → Category operations: dispatches (evidence: `backend/routes/categoryRoutes.js`)
- Category operations → Category records: reads and writes (evidence: `backend/controllers/categoryController.js`)
- Order routes → Order and payment: dispatches (evidence: `backend/routes/orderRoutes.js`)
- Order and payment → Order records: reads and writes (evidence: `backend/controllers/orderController.js`)
- Order and payment → Product catalog: loads item prices (evidence: `backend/controllers/orderController.js`)
- Order and payment → Razorpay: creates payment (evidence: `backend/controllers/orderController.js`)
- Product routes → Access control: guards admin actions (evidence: `backend/routes/productRoutes.js`)
- Order routes → Access control: guards orders (evidence: `backend/routes/orderRoutes.js`)
- User operations → User records: reads and writes (evidence: `backend/controllers/userController.js`)
- Access control → User records: loads identity (evidence: `backend/middlewares/authmiddleware.js`)
- AI chat interface → Streaming AI assistant: streams queries
- Streaming AI assistant → AI product matching: finds products (evidence: `backend/routes/chatStream.js`)
- AI product matching → Product catalog: searches catalog (evidence: `backend/services/productService.js`)
- AI product matching → Category records: matches category (evidence: `backend/services/productService.js`)
- AI chat interface → Image uploads: uploads image
- Image uploads → Cloudinary storage: stores image (evidence: `backend/routes/uploadRoutes.js`)
