# adityayadav0708/krishna-sweets-new architecture

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

- Interactive diagram: https://gitdiagram.com/adityayadav0708/krishna-sweets-new
- Repository: https://github.com/adityayadav0708/krishna-sweets-new

## Overview

Krishna Sweets is a sweets-commerce application with a React storefront and an Express/MongoDB API. The principal customer journey is browsing products, managing a cart, and placing and tracking orders; account, address, and admin analytics/management are additional capabilities. The tree also shows informational pages and customer reviews. Edges are limited to relationships visible in excerpts or the source index; client-side wiring and unsampled analytics behavior remain uncertain.

Main entry points: [`backend/src/controllers/orderController.js`](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/orderController.js) (Order operations), [`client/kp/src/api/client.js`](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/api/client.js) (API client), [`backend/server.js`](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/server.js) (HTTP API server), [`backend/src/controllers/userController.js`](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/userController.js) (Account operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_webapp["Storefront UI<br/>[App.jsx]"]
  node_catalogui["Product browsing<br/>[ProductsPage.jsx]"]
  node_productdetail["Product detail"]
  node_cartui["Cart and checkout"]
  node_accountui["Account UI"]
  node_ordersui["Order history<br/>[MyOrdersPage.jsx]"]
  node_content["Brand and info pages"]
  node_reviews["Customer reviews<br/>[ReviewsGrid.jsx]"]
  node_clientapi["API client<br/>[client.js]"]
end

subgraph group_identity["Accounts"]
  node_authroutes["Auth routes<br/>[userRoutes.js]"]
  node_authcontroller["Account operations<br/>[userController.js]"]
  node_authguard["Authentication guard<br/>[authMiddleware.js]"]
  node_users[("User records<br/>[User.js]")]
end

subgraph group_commerce["Commerce API"]
  node_apiserver["HTTP API server<br/>[server.js]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_productcontroller["Catalog operations"]
  node_products[("Product records<br/>[Product.js]")]
  node_cartcontroller["Cart operations<br/>[CartController.js]"]
  node_carts[("Cart records<br/>[Cart.js]")]
  node_orderroutes["Order routes<br/>[Order.js]"]
  node_ordercontroller["Order operations<br/>[orderController.js]"]
  node_orders[("Order records<br/>[Order.js]")]
  node_addresses["Address operations"]
  node_addressrecords[("Address records<br/>[Address.js]")]
  node_upload["Image upload"]
end

subgraph group_admin["Administration"]
  node_analyticsroutes["Analytics routes<br/>[analyticsRoutes.js]"]
  node_analytics["Sales analytics"]
  node_adminui["Admin dashboard<br/>[AdminPage.jsx]"]
end

node_customer(("Customer"))
node_cloudinary["Cloudinary"]

node_customer -.->|"uses"| node_webapp
node_apiserver -->|"mounts"| node_authroutes
node_apiserver -->|"mounts"| node_productroutes
node_apiserver -->|"mounts"| node_orderroutes
node_apiserver -->|"mounts"| node_analyticsroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_users
node_authcontroller -->|"uploads avatar"| node_upload
node_productroutes -->|"dispatches"| node_productcontroller
node_productcontroller -->|"reads and writes"| node_products
node_productcontroller -->|"uploads images"| node_upload
node_upload -->|"uploads"| node_cloudinary
node_cartcontroller -->|"reads and writes"| node_carts
node_cartcontroller -->|"populates items"| node_products
node_orderroutes -->|"dispatches"| node_ordercontroller
node_ordercontroller -->|"creates and reads"| node_orders
node_ordercontroller -->|"reads and clears"| node_carts
node_ordercontroller -->|"reads and updates stock"| node_products
node_ordercontroller -->|"reads and creates"| node_users
node_ordercontroller -->|"reads"| node_addressrecords
node_addresses -->|"reads and writes"| node_addressrecords
node_analyticsroutes -->|"dispatches"| node_analytics
node_analyticsroutes -->|"applies guards"| node_authguard
node_adminui -.->|"requests data"| node_clientapi
node_webapp -.->|"requests data"| node_clientapi
node_catalogui -.->|"requests catalog"| node_clientapi
node_productdetail -.->|"requests product"| node_clientapi
node_cartui -.->|"requests cart"| node_clientapi
node_accountui -.->|"requests account"| node_clientapi
node_ordersui -.->|"requests orders"| node_clientapi
node_reviews -->|"reads user"| node_accountui
node_content -->|"includes reviews page"| node_reviews

click node_webapp "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/app/App.jsx"
click node_catalogui "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/ProductsPage/ProductsPage.jsx"
click node_productdetail "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/ProductDetailPage/ProductDetailPage.jsx"
click node_cartui "https://github.com/adityayadav0708/krishna-sweets-new/tree/main/client/kp/src/components/cart"
click node_accountui "https://github.com/adityayadav0708/krishna-sweets-new/tree/main/client/kp/src/components/auth"
click node_ordersui "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/MyOrdersPage/MyOrdersPage.jsx"
click node_content "https://github.com/adityayadav0708/krishna-sweets-new/tree/main/client/kp/src/pages"
click node_reviews "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/ReviewsPage/sections/ReviewsGrid.jsx"
click node_clientapi "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/api/client.js"
click node_authroutes "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/userRoutes.js"
click node_authcontroller "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/userController.js"
click node_authguard "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Middleware/authMiddleware.js"
click node_users "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/User.js"
click node_apiserver "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/server.js"
click node_productroutes "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/productRoutes.js"
click node_productcontroller "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/productController.js"
click node_products "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Product.js"
click node_cartcontroller "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/CartController.js"
click node_carts "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Cart.js"
click node_orderroutes "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/Order.js"
click node_ordercontroller "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/orderController.js"
click node_orders "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Order.js"
click node_addresses "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/addressController.js"
click node_addressrecords "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Address.js"
click node_analyticsroutes "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/analyticsRoutes.js"
click node_analytics "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/analyticsController.js"
click node_adminui "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/AdminPage/AdminPage.jsx"
click node_upload "https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/utils/uploadImagecloudinary.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_webapp,node_catalogui,node_productdetail,node_cartui,node_accountui,node_ordersui,node_content,node_reviews,node_clientapi toneBlue
class node_authroutes,node_authcontroller,node_authguard,node_users toneAmber
class node_apiserver,node_productroutes,node_productcontroller,node_products,node_cartcontroller,node_carts,node_orderroutes,node_ordercontroller,node_orders,node_addresses,node_addressrecords,node_upload toneMint
class node_analyticsroutes,node_analytics,node_adminui toneRose
class node_customer,node_cloudinary toneIndigo
```

## Components

### Storefront

- [Storefront UI](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/app/App.jsx): `client/kp/src/app/App.jsx`
- [Product browsing](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/ProductsPage/ProductsPage.jsx): `client/kp/src/pages/ProductsPage/ProductsPage.jsx`
- [Product detail](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/ProductDetailPage/ProductDetailPage.jsx): `client/kp/src/pages/ProductDetailPage/ProductDetailPage.jsx`
- [Cart and checkout](https://github.com/adityayadav0708/krishna-sweets-new/tree/main/client/kp/src/components/cart): `client/kp/src/components/cart`
- [Account UI](https://github.com/adityayadav0708/krishna-sweets-new/tree/main/client/kp/src/components/auth): `client/kp/src/components/auth`
- [Order history](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/MyOrdersPage/MyOrdersPage.jsx): `client/kp/src/pages/MyOrdersPage/MyOrdersPage.jsx`
- [Brand and info pages](https://github.com/adityayadav0708/krishna-sweets-new/tree/main/client/kp/src/pages): `client/kp/src/pages`
- [Customer reviews](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/ReviewsPage/sections/ReviewsGrid.jsx): `client/kp/src/pages/ReviewsPage/sections/ReviewsGrid.jsx`
- [API client](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/api/client.js): `client/kp/src/api/client.js`

### Accounts

- [Auth routes](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/userRoutes.js): `backend/src/Routes/userRoutes.js`
- [Account operations](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/userController.js): `backend/src/controllers/userController.js`
- [Authentication guard](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Middleware/authMiddleware.js): `backend/src/Middleware/authMiddleware.js`
- [User records](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/User.js): `backend/src/models/User.js`

### Commerce API

- [HTTP API server](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/server.js): `backend/server.js`
- [Product routes](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/productRoutes.js): `backend/src/Routes/productRoutes.js`
- [Catalog operations](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/productController.js): `backend/src/controllers/productController.js`
- [Product records](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Product.js): `backend/src/models/Product.js`
- [Cart operations](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/CartController.js): `backend/src/controllers/CartController.js`
- [Cart records](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Cart.js): `backend/src/models/Cart.js`
- [Order routes](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/Order.js): `backend/src/Routes/Order.js`
- [Order operations](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/orderController.js): `backend/src/controllers/orderController.js`
- [Order records](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Order.js): `backend/src/models/Order.js`
- [Address operations](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/addressController.js): `backend/src/controllers/addressController.js`
- [Address records](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/models/Address.js): `backend/src/models/Address.js`
- [Image upload](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/utils/uploadImagecloudinary.js): `backend/utils/uploadImagecloudinary.js`

### Administration

- [Analytics routes](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/Routes/analyticsRoutes.js): `backend/src/Routes/analyticsRoutes.js`
- [Sales analytics](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/backend/src/controllers/analyticsController.js): `backend/src/controllers/analyticsController.js`
- [Admin dashboard](https://github.com/adityayadav0708/krishna-sweets-new/blob/main/client/kp/src/pages/AdminPage/AdminPage.jsx): `client/kp/src/pages/AdminPage/AdminPage.jsx`

### Other components

- **Customer**
- **Cloudinary**

## Connections

- Customer → Storefront UI: uses
- HTTP API server → Auth routes: mounts (evidence: `backend/server.js`)
- HTTP API server → Product routes: mounts (evidence: `backend/server.js`)
- HTTP API server → Order routes: mounts (evidence: `backend/server.js`)
- HTTP API server → Analytics routes: mounts (evidence: `backend/server.js`)
- Auth routes → Account operations: dispatches (evidence: `backend/src/Routes/userRoutes.js`)
- Account operations → User records: reads and writes (evidence: `backend/src/controllers/userController.js`)
- Account operations → Image upload: uploads avatar (evidence: `backend/src/controllers/userController.js`)
- Product routes → Catalog operations: dispatches (evidence: `backend/src/Routes/productRoutes.js`)
- Catalog operations → Product records: reads and writes (evidence: `backend/src/controllers/productController.js`)
- Catalog operations → Image upload: uploads images (evidence: `backend/src/controllers/productController.js`)
- Image upload → Cloudinary: uploads (evidence: `backend/utils/uploadImagecloudinary.js`)
- Cart operations → Cart records: reads and writes (evidence: `backend/src/controllers/CartController.js`)
- Cart operations → Product records: populates items (evidence: `backend/src/controllers/CartController.js`)
- Order routes → Order operations: dispatches (evidence: `backend/src/Routes/Order.js`)
- Order operations → Order records: creates and reads (evidence: `backend/src/controllers/orderController.js`)
- Order operations → Cart records: reads and clears (evidence: `backend/src/controllers/orderController.js`)
- Order operations → Product records: reads and updates stock (evidence: `backend/src/controllers/orderController.js`)
- Order operations → User records: reads and creates (evidence: `backend/src/controllers/orderController.js`)
- Order operations → Address records: reads (evidence: `backend/src/controllers/orderController.js`)
- Address operations → Address records: reads and writes (evidence: `backend/src/controllers/addressController.js`)
- Analytics routes → Sales analytics: dispatches (evidence: `backend/src/Routes/analyticsRoutes.js`)
- Analytics routes → Authentication guard: applies guards (evidence: `backend/server.js`)
- Admin dashboard → API client: requests data
- Storefront UI → API client: requests data
- Product browsing → API client: requests catalog
- Product detail → API client: requests product
- Cart and checkout → API client: requests cart
- Account UI → API client: requests account
- Order history → API client: requests orders
- Customer reviews → Account UI: reads user (evidence: `client/kp/src/pages/ReviewsPage/sections/ReviewsGrid.jsx`)
- Brand and info pages → Customer reviews: includes reviews page (evidence: `client/kp/src/pages/ReviewsPage/ReviewsPage.jsx`)
