# moodgame/ecommerce architecture

> Architecture diagram of the GitHub repository moodgame/ecommerce, 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/moodgame/ecommerce
- Repository: https://github.com/moodgame/ecommerce

## Overview

This repository implements a fashion e-commerce application: shoppers browse products, manage a cart, and place or review orders; administrators manage catalog items and orders. The backend exposes user, product, cart, and order APIs, with MongoDB-backed models and Cloudinary image uploads. The tree contains three closely related storefront copies (`frontend`, `frontsnd`, and `play`); the graph uses `frontend` as the representative storefront and includes `play`’s additional welcome route. Several UI and route relationships are supported only by the SOURCE INDEX, so unsampled behavior is not expanded.

Main entry points: [`backend/server.js`](https://github.com/moodgame/ecommerce/blob/main/backend/server.js) (API server), [`frontend/src/App.jsx`](https://github.com/moodgame/ecommerce/blob/main/frontend/src/App.jsx) (Storefront routes), [`frontend/src/context/Shopcontext.jsx`](https://github.com/moodgame/ecommerce/blob/main/frontend/src/context/Shopcontext.jsx) (Shop state), [`admin/src/App.jsx`](https://github.com/moodgame/ecommerce/blob/main/admin/src/App.jsx) (Admin routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shopper["Storefront"]
  node_store_app["Storefront routes<br/>[App.jsx]"]
  node_catalog_browse["Catalog browsing<br/>[Collection.jsx]"]
  node_product_view["Product details<br/>[Product.jsx]"]
  node_shop_context["Shop state<br/>[Shopcontext.jsx]"]
  node_cart_checkout["Cart and checkout<br/>[PlaceOrder.jsx]"]
  node_account_orders["Accounts and orders<br/>[Orders.jsx]"]
  node_search["Product search<br/>[SearchBar.jsx]"]
end

subgraph group_admin["Admin console"]
  node_admin_app["Admin routes<br/>[App.jsx]"]
  node_admin_login["Admin login<br/>[Login.jsx]"]
  node_admin_catalog["Catalog management<br/>[Add.jsx]"]
  node_admin_orders["Order management<br/>[Orders.jsx]"]
end

subgraph group_api["Backend API"]
  node_server["API server<br/>[server.js]"]
  node_user_api["User API<br/>[userRoute.js]"]
  node_product_api["Product API<br/>[productRoute.js]"]
  node_cart_api["Cart API<br/>[cartRoute.js]"]
  node_order_api["Order API<br/>[orderRoute.js]"]
  node_user_controller["User operations<br/>[userController.js]"]
  node_product_controller["Product operations"]
  node_cart_controller["Cart operations<br/>[cartController.js]"]
  node_order_controller["Order operations<br/>[orderController.js]"]
end

subgraph group_data["Persistence and media"]
  node_mongo_config["MongoDB connection<br/>[mongodb.js]"]
  node_cloudinary_config["Cloudinary connection<br/>[cloudinary.js]"]
  node_user_model[("User records<br/>[userModel.js]")]
  node_product_model[("Product records<br/>[productModel.js]")]
  node_order_model[("Order records<br/>[orderModel.js]")]
end

node_shopper(("Shopper"))
node_admin_user(("Administrator"))
node_cloudinary(("Cloudinary"))

node_shopper -->|"uses"| node_store_app
node_store_app -->|"routes to"| node_catalog_browse
node_store_app -->|"routes to"| node_product_view
node_store_app -->|"routes to"| node_cart_checkout
node_store_app -->|"routes to"| node_account_orders
node_store_app -->|"renders"| node_search
node_catalog_browse -.->|"uses state"| node_shop_context
node_product_view -.->|"uses state"| node_shop_context
node_cart_checkout -->|"uses state"| node_shop_context
node_search -->|"reads state"| node_shop_context
node_shop_context -->|"requests API"| node_server
node_admin_user -->|"uses"| node_admin_app
node_admin_app -->|"renders"| node_admin_login
node_admin_app -->|"routes to"| node_admin_catalog
node_admin_app -->|"routes to"| node_admin_orders
node_server -->|"connects"| node_mongo_config
node_server -->|"connects"| node_cloudinary_config
node_server -->|"mounts"| node_user_api
node_server -->|"mounts"| node_product_api
node_server -->|"mounts"| node_cart_api
node_server -->|"mounts"| node_order_api
node_user_api -->|"routes to"| node_user_controller
node_product_api -->|"routes to"| node_product_controller
node_cart_api -.->|"routes to"| node_cart_controller
node_order_api -->|"routes to"| node_order_controller
node_user_controller -->|"queries"| node_user_model
node_product_controller -->|"queries"| node_product_model
node_product_controller -->|"uploads images"| node_cloudinary
node_order_controller -->|"reads and updates"| node_user_model
node_order_controller -->|"stores orders"| node_order_model
node_cart_controller -->|"updates cart"| node_user_model
node_cloudinary_config -.->|"configures"| node_cloudinary

click node_store_app "https://github.com/moodgame/ecommerce/blob/main/frontend/src/App.jsx"
click node_catalog_browse "https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/Collection.jsx"
click node_product_view "https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/Product.jsx"
click node_shop_context "https://github.com/moodgame/ecommerce/blob/main/frontend/src/context/Shopcontext.jsx"
click node_cart_checkout "https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/PlaceOrder.jsx"
click node_account_orders "https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/Orders.jsx"
click node_search "https://github.com/moodgame/ecommerce/blob/main/frontend/src/components/SearchBar.jsx"
click node_admin_app "https://github.com/moodgame/ecommerce/blob/main/admin/src/App.jsx"
click node_admin_login "https://github.com/moodgame/ecommerce/blob/main/admin/src/components/Login.jsx"
click node_admin_catalog "https://github.com/moodgame/ecommerce/blob/main/admin/src/pages/Add.jsx"
click node_admin_orders "https://github.com/moodgame/ecommerce/blob/main/admin/src/pages/Orders.jsx"
click node_server "https://github.com/moodgame/ecommerce/blob/main/backend/server.js"
click node_user_api "https://github.com/moodgame/ecommerce/blob/main/backend/routes/userRoute.js"
click node_product_api "https://github.com/moodgame/ecommerce/blob/main/backend/routes/productRoute.js"
click node_cart_api "https://github.com/moodgame/ecommerce/blob/main/backend/routes/cartRoute.js"
click node_order_api "https://github.com/moodgame/ecommerce/blob/main/backend/routes/orderRoute.js"
click node_user_controller "https://github.com/moodgame/ecommerce/blob/main/backend/controllers/userController.js"
click node_product_controller "https://github.com/moodgame/ecommerce/blob/main/backend/controllers/productController.js"
click node_cart_controller "https://github.com/moodgame/ecommerce/blob/main/backend/controllers/cartController.js"
click node_order_controller "https://github.com/moodgame/ecommerce/blob/main/backend/controllers/orderController.js"
click node_mongo_config "https://github.com/moodgame/ecommerce/blob/main/backend/config/mongodb.js"
click node_cloudinary_config "https://github.com/moodgame/ecommerce/blob/main/backend/config/cloudinary.js"
click node_user_model "https://github.com/moodgame/ecommerce/blob/main/backend/models/userModel.js"
click node_product_model "https://github.com/moodgame/ecommerce/blob/main/backend/models/productModel.js"
click node_order_model "https://github.com/moodgame/ecommerce/blob/main/backend/models/orderModel.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_store_app,node_catalog_browse,node_product_view,node_shop_context,node_cart_checkout,node_account_orders,node_search toneBlue
class node_admin_app,node_admin_login,node_admin_catalog,node_admin_orders toneAmber
class node_server,node_user_api,node_product_api,node_cart_api,node_order_api,node_user_controller,node_product_controller,node_cart_controller,node_order_controller toneMint
class node_mongo_config,node_cloudinary_config,node_user_model,node_product_model,node_order_model toneRose
class node_shopper,node_admin_user,node_cloudinary toneIndigo
```

## Components

### Storefront

- [Storefront routes](https://github.com/moodgame/ecommerce/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Catalog browsing](https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/Collection.jsx): `frontend/src/pages/Collection.jsx`
- [Product details](https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/Product.jsx): `frontend/src/pages/Product.jsx`
- [Shop state](https://github.com/moodgame/ecommerce/blob/main/frontend/src/context/Shopcontext.jsx): `frontend/src/context/Shopcontext.jsx`
- [Cart and checkout](https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/PlaceOrder.jsx): `frontend/src/pages/PlaceOrder.jsx`
- [Accounts and orders](https://github.com/moodgame/ecommerce/blob/main/frontend/src/pages/Orders.jsx): `frontend/src/pages/Orders.jsx`
- [Product search](https://github.com/moodgame/ecommerce/blob/main/frontend/src/components/SearchBar.jsx): `frontend/src/components/SearchBar.jsx`

### Admin console

- [Admin routes](https://github.com/moodgame/ecommerce/blob/main/admin/src/App.jsx): `admin/src/App.jsx`
- [Admin login](https://github.com/moodgame/ecommerce/blob/main/admin/src/components/Login.jsx): `admin/src/components/Login.jsx`
- [Catalog management](https://github.com/moodgame/ecommerce/blob/main/admin/src/pages/Add.jsx): `admin/src/pages/Add.jsx`
- [Order management](https://github.com/moodgame/ecommerce/blob/main/admin/src/pages/Orders.jsx): `admin/src/pages/Orders.jsx`

### Backend API

- [API server](https://github.com/moodgame/ecommerce/blob/main/backend/server.js): `backend/server.js`
- [User API](https://github.com/moodgame/ecommerce/blob/main/backend/routes/userRoute.js): `backend/routes/userRoute.js`
- [Product API](https://github.com/moodgame/ecommerce/blob/main/backend/routes/productRoute.js): `backend/routes/productRoute.js`
- [Cart API](https://github.com/moodgame/ecommerce/blob/main/backend/routes/cartRoute.js): `backend/routes/cartRoute.js`
- [Order API](https://github.com/moodgame/ecommerce/blob/main/backend/routes/orderRoute.js): `backend/routes/orderRoute.js`
- [User operations](https://github.com/moodgame/ecommerce/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Product operations](https://github.com/moodgame/ecommerce/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Cart operations](https://github.com/moodgame/ecommerce/blob/main/backend/controllers/cartController.js): `backend/controllers/cartController.js`
- [Order operations](https://github.com/moodgame/ecommerce/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`

### Persistence and media

- [MongoDB connection](https://github.com/moodgame/ecommerce/blob/main/backend/config/mongodb.js): `backend/config/mongodb.js`
- [Cloudinary connection](https://github.com/moodgame/ecommerce/blob/main/backend/config/cloudinary.js): `backend/config/cloudinary.js`
- [User records](https://github.com/moodgame/ecommerce/blob/main/backend/models/userModel.js): `backend/models/userModel.js`
- [Product records](https://github.com/moodgame/ecommerce/blob/main/backend/models/productModel.js): `backend/models/productModel.js`
- [Order records](https://github.com/moodgame/ecommerce/blob/main/backend/models/orderModel.js): `backend/models/orderModel.js`

### Other components

- **Shopper**
- **Administrator**
- **Cloudinary**

## Connections

- Shopper → Storefront routes: uses (evidence: `frontend/src/App.jsx`)
- Storefront routes → Catalog browsing: routes to (evidence: `frontend/src/App.jsx`)
- Storefront routes → Product details: routes to (evidence: `frontend/src/App.jsx`)
- Storefront routes → Cart and checkout: routes to (evidence: `frontend/src/App.jsx`)
- Storefront routes → Accounts and orders: routes to (evidence: `frontend/src/App.jsx`)
- Storefront routes → Product search: renders (evidence: `frontend/src/App.jsx`)
- Catalog browsing → Shop state: uses state
- Product details → Shop state: uses state
- Cart and checkout → Shop state: uses state (evidence: `frontend/src/pages/PlaceOrder.jsx`)
- Product search → Shop state: reads state (evidence: `frontend/src/components/SearchBar.jsx`)
- Shop state → API server: requests API (evidence: `frontend/src/context/Shopcontext.jsx`)
- Administrator → Admin routes: uses (evidence: `admin/src/App.jsx`)
- Admin routes → Admin login: renders (evidence: `admin/src/App.jsx`)
- Admin routes → Catalog management: routes to (evidence: `admin/src/App.jsx`)
- Admin routes → Order management: routes to (evidence: `admin/src/App.jsx`)
- API server → MongoDB connection: connects (evidence: `backend/server.js`)
- API server → Cloudinary connection: connects (evidence: `backend/server.js`)
- API server → User API: mounts (evidence: `backend/server.js`)
- API server → Product API: mounts (evidence: `backend/server.js`)
- API server → Cart API: mounts (evidence: `backend/server.js`)
- API server → Order API: mounts (evidence: `backend/server.js`)
- User API → User operations: routes to (evidence: `backend/routes/userRoute.js`)
- Product API → Product operations: routes to (evidence: `backend/routes/productRoute.js`)
- Cart API → Cart operations: routes to
- Order API → Order operations: routes to (evidence: `backend/routes/orderRoute.js`)
- User operations → User records: queries (evidence: `backend/controllers/userController.js`)
- Product operations → Product records: queries (evidence: `backend/controllers/productController.js`)
- Product operations → Cloudinary: uploads images (evidence: `backend/controllers/productController.js`)
- Order operations → User records: reads and updates (evidence: `backend/controllers/orderController.js`)
- Order operations → Order records: stores orders (evidence: `backend/controllers/orderController.js`)
- Cart operations → User records: updates cart (evidence: `backend/controllers/cartController.js`)
- Cloudinary connection → Cloudinary: configures
