# hadhee17/e-commerce architecture

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

- Interactive diagram: https://gitdiagram.com/hadhee17/e-commerce
- Repository: https://github.com/hadhee17/e-commerce

## Overview

This is a full-stack e-commerce application. Shoppers browse products, inspect product details and reviews, authenticate, manage a cart, and proceed through checkout, payment, and orders; sellers manage their listings. The React client routes pages and coordinates shared authentication and cart state, while service modules call the Express API. The API routes requests to controllers, which use MongoDB models for users, products, carts, reviews, and orders. The tree and excerpts support these main stages, but several page, route, and controller internals are unsampled; their finer interactions are therefore not asserted.

Main entry points: [`client/src/App.jsx`](https://github.com/hadhee17/e-commerce/blob/main/client/src/App.jsx) (Page router), [`server/app.js`](https://github.com/hadhee17/e-commerce/blob/main/server/app.js) (API router), [`client/src/services/api.js`](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/api.js) (HTTP client), [`client/src/services/productService.js`](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/productService.js) (Product requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Storefront client"]
  node_app["Page router<br/>[App.jsx]"]
  node_header["Store navigation<br/>[Header.jsx]"]
  node_product_card["Product card<br/>[ProductCard.jsx]"]
  node_home["Product browsing<br/>[Home.jsx]"]
  node_product_detail["Product details<br/>[ProductDetail.jsx]"]
  node_reviews_ui["Review section<br/>[ReviewSection.jsx]"]
  node_login["Sign-in and signup<br/>[Login.jsx]"]
  node_auth_state["Authentication state<br/>[AuthContext.jsx]"]
  node_cart_state["Cart state<br/>[CartContext.jsx]"]
  node_cart_page["Cart page<br/>[Cart.jsx]"]
  node_buy_now["Direct checkout<br/>[BuyNow.jsx]"]
  node_payment_page["Payment page<br/>[Payment.jsx]"]
  node_orders_page["Order history<br/>[Orders.jsx]"]
  node_profile["User profile<br/>[Profile.jsx]"]
  node_seller_products["Seller listings<br/>[MyProducts.jsx]"]
  node_api_client["HTTP client<br/>[api.js]"]
  node_auth_service["Auth requests<br/>[authService.js]"]
  node_product_service["Product requests<br/>[productService.js]"]
  node_cart_service["Cart requests<br/>[cartService.js]"]
  node_order_service["Order requests<br/>[orderServices.js]"]
  node_payment_service["Payment requests<br/>[paymentService.js]"]
  node_review_service["Review requests<br/>[reviewService.js]"]
  node_user_service["User requests<br/>[userService.js]"]
end

subgraph group_api["API and access"]
  node_express_app["API router<br/>[app.js]"]
  node_auth_routes["User routes<br/>[user.js]"]
  node_auth_controller["Authentication logic<br/>[authController.js]"]
  node_jwt["Token middleware<br/>[jwt.js]"]
end

subgraph group_catalog["Catalog and feedback"]
  node_product_routes["Product routes<br/>[product.js]"]
  node_product_controller["Product operations"]
  node_review_routes["Review routes<br/>[review.js]"]
  node_review_controller["Review operations"]
end

subgraph group_commerce["Cart and transactions"]
  node_cart_routes["Cart routes<br/>[cart.js]"]
end

subgraph group_data["Persistent data"]
end

node_shopper(("Shopper"))
node_seller(("Seller"))

node_shopper -->|"uses storefront"| node_app
node_seller -->|"uses storefront"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_product_detail
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_cart_page
node_app -->|"routes to"| node_buy_now
node_app -->|"routes to"| node_payment_page
node_app -->|"routes to"| node_orders_page
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_seller_products
node_app -->|"provides state"| node_auth_state
node_app -->|"provides state"| node_cart_state
node_product_detail -.->|"renders"| node_reviews_ui
node_reviews_ui -->|"requests reviews"| node_review_service
node_auth_state -->|"calls"| node_auth_service
node_cart_state -->|"calls"| node_cart_service
node_home -.->|"fetches products"| node_product_service
node_product_detail -.->|"fetches product"| node_product_service
node_seller_products -->|"manages listings"| node_product_service
node_buy_now -->|"submits order"| node_order_service
node_buy_now -->|"requests payment"| node_payment_service
node_api_client -.->|"sends requests"| node_express_app
node_auth_service -->|"uses"| node_api_client
node_product_service -->|"uses"| node_api_client
node_cart_service -->|"uses"| node_api_client
node_review_service -->|"uses"| node_api_client
node_express_app -->|"mounts"| node_auth_routes
node_express_app -->|"mounts"| node_product_routes
node_express_app -->|"mounts"| node_review_routes
node_express_app -->|"mounts"| node_cart_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_review_routes -->|"dispatches"| node_review_controller
node_product_routes -->|"dispatches"| node_product_controller
node_auth_controller -->|"creates tokens"| node_jwt

click node_app "https://github.com/hadhee17/e-commerce/blob/main/client/src/App.jsx"
click node_header "https://github.com/hadhee17/e-commerce/blob/main/client/src/components/Header.jsx"
click node_product_card "https://github.com/hadhee17/e-commerce/blob/main/client/src/components/ProductCard.jsx"
click node_home "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Home.jsx"
click node_product_detail "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/ProductDetail.jsx"
click node_reviews_ui "https://github.com/hadhee17/e-commerce/blob/main/client/src/components/ReviewSection.jsx"
click node_login "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Login.jsx"
click node_auth_state "https://github.com/hadhee17/e-commerce/blob/main/client/src/context/AuthContext.jsx"
click node_cart_state "https://github.com/hadhee17/e-commerce/blob/main/client/src/context/CartContext.jsx"
click node_cart_page "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Cart.jsx"
click node_buy_now "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/BuyNow.jsx"
click node_payment_page "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Payment.jsx"
click node_orders_page "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Orders.jsx"
click node_profile "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Profile.jsx"
click node_seller_products "https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/MyProducts.jsx"
click node_api_client "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/api.js"
click node_auth_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/authService.js"
click node_product_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/productService.js"
click node_cart_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/cartService.js"
click node_order_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/orderServices.js"
click node_payment_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/paymentService.js"
click node_review_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/reviewService.js"
click node_user_service "https://github.com/hadhee17/e-commerce/blob/main/client/src/services/userService.js"
click node_express_app "https://github.com/hadhee17/e-commerce/blob/main/server/app.js"
click node_auth_routes "https://github.com/hadhee17/e-commerce/blob/main/server/routes/user.js"
click node_auth_controller "https://github.com/hadhee17/e-commerce/blob/main/server/controller/authController.js"
click node_jwt "https://github.com/hadhee17/e-commerce/blob/main/server/middleware/jwt.js"
click node_product_routes "https://github.com/hadhee17/e-commerce/blob/main/server/routes/product.js"
click node_product_controller "https://github.com/hadhee17/e-commerce/blob/main/server/controller/productController.js"
click node_review_routes "https://github.com/hadhee17/e-commerce/blob/main/server/routes/review.js"
click node_review_controller "https://github.com/hadhee17/e-commerce/blob/main/server/controller/reviewController.js"
click node_cart_routes "https://github.com/hadhee17/e-commerce/blob/main/server/routes/cart.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_header,node_product_card,node_home,node_product_detail,node_reviews_ui,node_login,node_auth_state,node_cart_state,node_cart_page,node_buy_now,node_payment_page,node_orders_page,node_profile,node_seller_products,node_api_client,node_auth_service,node_product_service,node_cart_service,node_order_service,node_payment_service,node_review_service,node_user_service toneBlue
class node_express_app,node_auth_routes,node_auth_controller,node_jwt toneAmber
class node_product_routes,node_product_controller,node_review_routes,node_review_controller toneMint
class node_cart_routes toneRose
class node_shopper,node_seller toneIndigo
```

## Components

### Storefront client

- [Page router](https://github.com/hadhee17/e-commerce/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Store navigation](https://github.com/hadhee17/e-commerce/blob/main/client/src/components/Header.jsx): `client/src/components/Header.jsx`
- [Product card](https://github.com/hadhee17/e-commerce/blob/main/client/src/components/ProductCard.jsx): `client/src/components/ProductCard.jsx`
- [Product browsing](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Home.jsx): `client/src/pages/Home.jsx`
- [Product details](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/ProductDetail.jsx): `client/src/pages/ProductDetail.jsx`
- [Review section](https://github.com/hadhee17/e-commerce/blob/main/client/src/components/ReviewSection.jsx): `client/src/components/ReviewSection.jsx`
- [Sign-in and signup](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [Authentication state](https://github.com/hadhee17/e-commerce/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Cart state](https://github.com/hadhee17/e-commerce/blob/main/client/src/context/CartContext.jsx): `client/src/context/CartContext.jsx`
- [Cart page](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Cart.jsx): `client/src/pages/Cart.jsx`
- [Direct checkout](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/BuyNow.jsx): `client/src/pages/BuyNow.jsx`
- [Payment page](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Payment.jsx): `client/src/pages/Payment.jsx`
- [Order history](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Orders.jsx): `client/src/pages/Orders.jsx`
- [User profile](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/Profile.jsx): `client/src/pages/Profile.jsx`
- [Seller listings](https://github.com/hadhee17/e-commerce/blob/main/client/src/pages/MyProducts.jsx): `client/src/pages/MyProducts.jsx`
- [HTTP client](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Auth requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/authService.js): `client/src/services/authService.js`
- [Product requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/productService.js): `client/src/services/productService.js`
- [Cart requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/cartService.js): `client/src/services/cartService.js`
- [Order requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/orderServices.js): `client/src/services/orderServices.js`
- [Payment requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/paymentService.js): `client/src/services/paymentService.js`
- [Review requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/reviewService.js): `client/src/services/reviewService.js`
- [User requests](https://github.com/hadhee17/e-commerce/blob/main/client/src/services/userService.js): `client/src/services/userService.js`

### API and access

- [API router](https://github.com/hadhee17/e-commerce/blob/main/server/app.js): `server/app.js`
- [User routes](https://github.com/hadhee17/e-commerce/blob/main/server/routes/user.js): `server/routes/user.js`
- [Authentication logic](https://github.com/hadhee17/e-commerce/blob/main/server/controller/authController.js): `server/controller/authController.js`
- [Token middleware](https://github.com/hadhee17/e-commerce/blob/main/server/middleware/jwt.js): `server/middleware/jwt.js`

### Catalog and feedback

- [Product routes](https://github.com/hadhee17/e-commerce/blob/main/server/routes/product.js): `server/routes/product.js`
- [Product operations](https://github.com/hadhee17/e-commerce/blob/main/server/controller/productController.js): `server/controller/productController.js`
- [Review routes](https://github.com/hadhee17/e-commerce/blob/main/server/routes/review.js): `server/routes/review.js`
- [Review operations](https://github.com/hadhee17/e-commerce/blob/main/server/controller/reviewController.js): `server/controller/reviewController.js`

### Cart and transactions

- [Cart routes](https://github.com/hadhee17/e-commerce/blob/main/server/routes/cart.js): `server/routes/cart.js`

### Other components

- **Shopper**
- **Seller**

## Connections

- Shopper → Page router: uses storefront
- Seller → Page router: uses storefront
- Page router → Product browsing: routes to (evidence: `client/src/App.jsx`)
- Page router → Product details: routes to (evidence: `client/src/App.jsx`)
- Page router → Sign-in and signup: routes to (evidence: `client/src/App.jsx`)
- Page router → Cart page: routes to (evidence: `client/src/App.jsx`)
- Page router → Direct checkout: routes to (evidence: `client/src/App.jsx`)
- Page router → Payment page: routes to (evidence: `client/src/App.jsx`)
- Page router → Order history: routes to (evidence: `client/src/App.jsx`)
- Page router → User profile: routes to (evidence: `client/src/App.jsx`)
- Page router → Seller listings: routes to (evidence: `client/src/App.jsx`)
- Page router → Authentication state: provides state (evidence: `client/src/App.jsx`)
- Page router → Cart state: provides state (evidence: `client/src/App.jsx`)
- Product details → Review section: renders
- Review section → Review requests: requests reviews (evidence: `client/src/services/reviewService.js`)
- Authentication state → Auth requests: calls (evidence: `client/src/context/AuthContext.jsx`)
- Cart state → Cart requests: calls (evidence: `client/src/context/CartContext.jsx`)
- Product browsing → Product requests: fetches products
- Product details → Product requests: fetches product
- Seller listings → Product requests: manages listings (evidence: `client/src/pages/MyProducts.jsx`)
- Direct checkout → Order requests: submits order (evidence: `client/src/pages/BuyNow.jsx`)
- Direct checkout → Payment requests: requests payment (evidence: `client/src/pages/BuyNow.jsx`)
- HTTP client → API router: sends requests
- Auth requests → HTTP client: uses (evidence: `client/src/services/authService.js`)
- Product requests → HTTP client: uses (evidence: `client/src/services/productService.js`)
- Cart requests → HTTP client: uses (evidence: `client/src/services/cartService.js`)
- Review requests → HTTP client: uses (evidence: `client/src/services/reviewService.js`)
- API router → User routes: mounts (evidence: `server/app.js`)
- API router → Product routes: mounts (evidence: `server/app.js`)
- API router → Review routes: mounts (evidence: `server/app.js`)
- API router → Cart routes: mounts (evidence: `server/app.js`)
- User routes → Authentication logic: dispatches (evidence: `server/routes/user.js`)
- Review routes → Review operations: dispatches (evidence: `server/routes/review.js`)
- Product routes → Product operations: dispatches (evidence: `server/routes/product.js`)
- Authentication logic → Token middleware: creates tokens (evidence: `server/controller/authController.js`)
