# thrinay296/cartify-ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/thrinay296/cartify-ecommerce
- Repository: https://github.com/thrinay296/cartify-ecommerce

## Overview

Cartify is a full-stack storefront: shoppers browse products, manage a persistent cart, check out, and track orders or returns; administrators manage catalog, orders, and returns. The browser is a plain multi-page frontend, while an Express API routes requests to domain controllers backed by MongoDB models. The README documents the main user-facing capabilities; source excerpts and the SOURCE INDEX establish backend routing and controller-to-model dependencies. Frontend-to-endpoint calls are not shown in the excerpts, so that connection is documented at the API level rather than expanded into speculative page-specific calls.

Main entry points: [`backend/server.js`](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/server.js) (Express API), [`backend/models/Product.js`](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Product.js) (Product records), [`backend/controllers/orderController.js`](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/orderController.js) (Order processing), [`backend/controllers/cartController.js`](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/cartController.js) (Cart logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_storefront["Storefront pages<br/>[index.html]"]
  node_catalog["Catalog browsing<br/>[home.js]"]
  node_productview["Product details<br/>[product.js]"]
  node_cart["Persistent cart<br/>[cart.js]"]
  node_checkout["Checkout<br/>[checkout.js]"]
end

subgraph group_admin["Admin workspace"]
  node_adminpages["Admin pages<br/>[dashboard.html]"]
  node_adminproducts["Catalog management<br/>[products.js]"]
  node_adminorders["Order management<br/>[orders.js]"]
  node_adminreturns["Return management<br/>[returns.js]"]
end

subgraph group_api["API and domain logic"]
  node_api["Express API<br/>[server.js]"]
  node_authlogic["Authentication<br/>[authController.js]"]
  node_productlogic["Product catalog"]
  node_categorylogic["Category logic"]
  node_cartlogic["Cart logic<br/>[cartController.js]"]
  node_couponlogic["Coupon logic"]
  node_orderlogic["Order processing<br/>[orderController.js]"]
  node_returnlogic["Return requests"]
  node_reviewlogic["Reviews and ratings"]
  node_authguard["JWT protection<br/>[auth.js]"]
  node_adminguard["Admin authorization<br/>[admin.js]"]
end

subgraph group_data["MongoDB models"]
  node_products[("Product records<br/>[Product.js]")]
  node_categories[("Category records<br/>[Category.js]")]
  node_carts[("Cart records<br/>[Cart.js]")]
  node_coupons[("Coupon records<br/>[Coupon.js]")]
  node_orders[("Order records<br/>[Order.js]")]
  node_returns[("Return records<br/>[Return.js]")]
  node_reviews[("Review records<br/>[Review.js]")]
  node_users[("User records<br/>[User.js]")]
end

node_shopper(("Shopper"))
node_adminuser(("Administrator"))
node_mongodb[("MongoDB")]

node_shopper -->|"browses"| node_storefront
node_shopper -->|"searches and filters"| node_catalog
node_shopper -->|"views details"| node_productview
node_shopper -->|"adds items"| node_cart
node_shopper -->|"places order"| node_checkout
node_adminuser -->|"manages store"| node_adminpages
node_adminuser -->|"manages products"| node_adminproducts
node_adminuser -->|"updates orders"| node_adminorders
node_adminuser -->|"reviews returns"| node_adminreturns
node_storefront -.->|"uses REST API"| node_api
node_adminpages -.->|"uses REST API"| node_api
node_api -->|"routes auth"| node_authlogic
node_api -->|"routes products"| node_productlogic
node_api -->|"routes categories"| node_categorylogic
node_api -->|"routes carts"| node_cartlogic
node_api -->|"routes coupons"| node_couponlogic
node_api -->|"routes orders"| node_orderlogic
node_api -->|"routes returns"| node_returnlogic
node_api -->|"routes reviews"| node_reviewlogic
node_authlogic -->|"reads and writes"| node_users
node_authguard -->|"loads user"| node_users
node_productlogic -->|"reads and writes"| node_products
node_categorylogic -->|"reads and writes"| node_categories
node_cartlogic -->|"reads and writes"| node_carts
node_cartlogic -->|"reads products"| node_products
node_couponlogic -->|"reads and writes"| node_coupons
node_orderlogic -->|"reads and writes"| node_orders
node_orderlogic -->|"checks and updates stock"| node_products
node_orderlogic -->|"validates coupon"| node_coupons
node_returnlogic -->|"reads and writes"| node_returns
node_returnlogic -->|"checks order"| node_orders
node_reviewlogic -->|"reads and writes"| node_reviews
node_reviewlogic -->|"recalculates rating"| node_products
node_mongodb -.->|"stores records"| node_products

click node_storefront "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/index.html"
click node_catalog "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/home.js"
click node_productview "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/product.js"
click node_cart "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/cart.js"
click node_checkout "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/checkout.js"
click node_adminpages "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/admin/dashboard.html"
click node_adminproducts "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/admin/products.js"
click node_adminorders "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/admin/orders.js"
click node_adminreturns "https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/admin/returns.js"
click node_api "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/server.js"
click node_authlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/authController.js"
click node_productlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/productController.js"
click node_categorylogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/categoryController.js"
click node_cartlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/cartController.js"
click node_couponlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/couponController.js"
click node_orderlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/orderController.js"
click node_returnlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/returnController.js"
click node_reviewlogic "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/reviewController.js"
click node_authguard "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/middleware/auth.js"
click node_adminguard "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/middleware/admin.js"
click node_products "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Product.js"
click node_categories "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Category.js"
click node_carts "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Cart.js"
click node_coupons "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Coupon.js"
click node_orders "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Order.js"
click node_returns "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Return.js"
click node_reviews "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Review.js"
click node_users "https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/User.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_storefront,node_catalog,node_productview,node_cart,node_checkout toneBlue
class node_adminpages,node_adminproducts,node_adminorders,node_adminreturns,node_mongodb toneAmber
class node_api,node_authlogic,node_productlogic,node_categorylogic,node_cartlogic,node_couponlogic,node_orderlogic,node_returnlogic,node_reviewlogic,node_authguard,node_adminguard toneMint
class node_products,node_categories,node_carts,node_coupons,node_orders,node_returns,node_reviews,node_users toneRose
class node_shopper,node_adminuser toneIndigo
```

## Components

### Customer storefront

- [Storefront pages](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/index.html): `frontend/index.html`
- [Catalog browsing](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/home.js): `frontend/assets/js/home.js`
- [Product details](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/product.js): `frontend/assets/js/product.js`
- [Persistent cart](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/cart.js): `frontend/assets/js/cart.js`
- [Checkout](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/checkout.js): `frontend/assets/js/checkout.js`

### Admin workspace

- [Admin pages](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/admin/dashboard.html): `frontend/admin/dashboard.html`
- [Catalog management](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/admin/products.js): `frontend/assets/js/admin/products.js`
- [Order management](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/admin/orders.js): `frontend/assets/js/admin/orders.js`
- [Return management](https://github.com/thrinay296/cartify-ecommerce/blob/main/frontend/assets/js/admin/returns.js): `frontend/assets/js/admin/returns.js`

### API and domain logic

- [Express API](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Product catalog](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Category logic](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/categoryController.js): `backend/controllers/categoryController.js`
- [Cart logic](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/cartController.js): `backend/controllers/cartController.js`
- [Coupon logic](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/couponController.js): `backend/controllers/couponController.js`
- [Order processing](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`
- [Return requests](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/returnController.js): `backend/controllers/returnController.js`
- [Reviews and ratings](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/controllers/reviewController.js): `backend/controllers/reviewController.js`
- [JWT protection](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Admin authorization](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/middleware/admin.js): `backend/middleware/admin.js`

### MongoDB models

- [Product records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Product.js): `backend/models/Product.js`
- [Category records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Category.js): `backend/models/Category.js`
- [Cart records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Cart.js): `backend/models/Cart.js`
- [Coupon records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Coupon.js): `backend/models/Coupon.js`
- [Order records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Order.js): `backend/models/Order.js`
- [Return records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Return.js): `backend/models/Return.js`
- [Review records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/Review.js): `backend/models/Review.js`
- [User records](https://github.com/thrinay296/cartify-ecommerce/blob/main/backend/models/User.js): `backend/models/User.js`

### Other components

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

## Connections

- Shopper → Storefront pages: browses (evidence: `README.md`)
- Shopper → Catalog browsing: searches and filters (evidence: `README.md`)
- Shopper → Product details: views details (evidence: `README.md`)
- Shopper → Persistent cart: adds items (evidence: `README.md`)
- Shopper → Checkout: places order (evidence: `README.md`)
- Administrator → Admin pages: manages store (evidence: `README.md`)
- Administrator → Catalog management: manages products (evidence: `README.md`)
- Administrator → Order management: updates orders (evidence: `README.md`)
- Administrator → Return management: reviews returns (evidence: `README.md`)
- Storefront pages → Express API: uses REST API (evidence: `README.md`)
- Admin pages → Express API: uses REST API (evidence: `README.md`)
- Express API → Authentication: routes auth (evidence: `backend/server.js`)
- Express API → Product catalog: routes products (evidence: `backend/server.js`)
- Express API → Category logic: routes categories (evidence: `backend/server.js`)
- Express API → Cart logic: routes carts (evidence: `backend/server.js`)
- Express API → Coupon logic: routes coupons (evidence: `backend/server.js`)
- Express API → Order processing: routes orders (evidence: `backend/server.js`)
- Express API → Return requests: routes returns (evidence: `backend/server.js`)
- Express API → Reviews and ratings: routes reviews (evidence: `backend/server.js`)
- Authentication → User records: reads and writes (evidence: `backend/controllers/authController.js`)
- JWT protection → User records: loads user (evidence: `backend/middleware/auth.js`)
- Product catalog → Product records: reads and writes (evidence: `backend/controllers/productController.js`)
- Category logic → Category records: reads and writes (evidence: `backend/controllers/categoryController.js`)
- Cart logic → Cart records: reads and writes (evidence: `backend/controllers/cartController.js`)
- Cart logic → Product records: reads products (evidence: `backend/controllers/cartController.js`)
- Coupon logic → Coupon records: reads and writes (evidence: `backend/controllers/couponController.js`)
- Order processing → Order records: reads and writes (evidence: `backend/controllers/orderController.js`)
- Order processing → Product records: checks and updates stock (evidence: `backend/controllers/orderController.js`)
- Order processing → Coupon records: validates coupon (evidence: `backend/controllers/orderController.js`)
- Return requests → Return records: reads and writes (evidence: `backend/controllers/returnController.js`)
- Return requests → Order records: checks order (evidence: `backend/controllers/returnController.js`)
- Reviews and ratings → Review records: reads and writes (evidence: `backend/controllers/reviewController.js`)
- Reviews and ratings → Product records: recalculates rating (evidence: `backend/controllers/reviewController.js`)
- MongoDB → Product records: stores records (evidence: `README.md`)
