# segjay/urbancartmern architecture

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

- Interactive diagram: https://gitdiagram.com/segjay/urbancartmern
- Repository: https://github.com/segjay/urbancartmern

## Overview

Urbancart is a MERN storefront with customer browsing, accounts, cart and checkout, order history, and admin product/user screens. The main flow runs from the React routes through page-level API calls to Express routes, controllers, and MongoDB models; cart and login state are managed in frontend contexts. The README only names the product, so capabilities and connections are grounded in the source index and shown excerpts. Some admin and order internals were not excerpted; their links are limited to documented references or left unasserted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/segjay/urbancartmern/blob/main/frontend/src/App.jsx) (Route shell), [`frontend/src/services/api.js`](https://github.com/segjay/urbancartmern/blob/main/frontend/src/services/api.js) (API client), [`frontend/src/pages/Checkout.jsx`](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Checkout.jsx) (Checkout), [`backend/server.js`](https://github.com/segjay/urbancartmern/blob/main/backend/server.js) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Storefront"]
  node_app["Route shell<br/>[App.jsx]"]
  node_home["Storefront<br/>[Home.jsx]"]
  node_detail["Product detail<br/>[ProductDetail.jsx]"]
  node_cart["Shopping cart<br/>[Cart.jsx]"]
  node_checkout["Checkout<br/>[Checkout.jsx]"]
  node_orderspage["Order history<br/>[MyOrders.jsx]"]
  node_productcard["Product card<br/>[ProductCard.jsx]"]
end

subgraph group_identity["Accounts"]
  node_authcontext["Login state<br/>[AuthContext.jsx]"]
  node_login["Sign in<br/>[Login.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_adminusers["User admin<br/>[AdminUsers.jsx]"]
  node_userroutes["User routes<br/>[userRoutes.js]"]
  node_userctrl["User handlers<br/>[userController.js]"]
  node_usermodel[("User records<br/>[User.js]")]
end

subgraph group_catalog["Catalog"]
  node_adminproducts["Product admin<br/>[AdminProducts.jsx]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_productctrl["Product handlers"]
  node_productmodel[("Product records<br/>[product.js]")]
end

subgraph group_commerce["Orders"]
  node_cartcontext["Cart state<br/>[CartContext.jsx]"]
  node_orderroutes["Order routes<br/>[orderRoutes.js]"]
  node_orderctrl["Order handlers<br/>[orderController.js]"]
  node_ordermodel[("Order records<br/>[Order.js]")]
end

subgraph group_backend["API and data"]
  node_api["API client<br/>[api.js]"]
  node_server["Express server<br/>[server.js]"]
end

node_customer(("Shopper"))

node_customer -->|"visits"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_orderspage
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_adminproducts
node_app -->|"routes to"| node_adminusers
node_home -->|"fetches products"| node_api
node_home -->|"renders"| node_productcard
node_detail -->|"fetches product"| node_api
node_detail -->|"adds item"| node_cartcontext
node_cart -->|"reads and updates"| node_cartcontext
node_checkout -->|"reads cart"| node_cartcontext
node_checkout -->|"reads account"| node_authcontext
node_checkout -->|"submits order"| node_api
node_orderspage -->|"fetches orders"| node_api
node_login -->|"sets login"| node_authcontext
node_login -->|"authenticates"| node_api
node_register -->|"registers"| node_api
node_productcard -->|"adds item"| node_cartcontext
node_adminusers -->|"reads account"| node_authcontext
node_api -->|"HTTP requests"| node_server
node_server -->|"mounts"| node_productroutes
node_server -->|"mounts"| node_userroutes
node_server -->|"mounts"| node_orderroutes
node_productroutes -->|"dispatches"| node_productctrl
node_productctrl -->|"queries and saves"| node_productmodel
node_userroutes -->|"dispatches"| node_userctrl
node_userctrl -->|"queries and saves"| node_usermodel
node_orderroutes -->|"dispatches"| node_orderctrl
node_orderctrl -->|"queries and saves"| node_ordermodel

click node_app "https://github.com/segjay/urbancartmern/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Home.jsx"
click node_detail "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/ProductDetail.jsx"
click node_cart "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Cart.jsx"
click node_checkout "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Checkout.jsx"
click node_orderspage "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/MyOrders.jsx"
click node_productcard "https://github.com/segjay/urbancartmern/blob/main/frontend/src/components/ProductCard.jsx"
click node_authcontext "https://github.com/segjay/urbancartmern/blob/main/frontend/src/context/AuthContext.jsx"
click node_login "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Register.jsx"
click node_cartcontext "https://github.com/segjay/urbancartmern/blob/main/frontend/src/context/CartContext.jsx"
click node_adminproducts "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/admin/AdminProducts.jsx"
click node_adminusers "https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/admin/AdminUsers.jsx"
click node_api "https://github.com/segjay/urbancartmern/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/segjay/urbancartmern/blob/main/backend/server.js"
click node_productroutes "https://github.com/segjay/urbancartmern/blob/main/backend/routes/productRoutes.js"
click node_productctrl "https://github.com/segjay/urbancartmern/blob/main/backend/controllers/productController.js"
click node_productmodel "https://github.com/segjay/urbancartmern/blob/main/backend/models/product.js"
click node_userroutes "https://github.com/segjay/urbancartmern/blob/main/backend/routes/userRoutes.js"
click node_userctrl "https://github.com/segjay/urbancartmern/blob/main/backend/controllers/userController.js"
click node_usermodel "https://github.com/segjay/urbancartmern/blob/main/backend/models/User.js"
click node_orderroutes "https://github.com/segjay/urbancartmern/blob/main/backend/routes/orderRoutes.js"
click node_orderctrl "https://github.com/segjay/urbancartmern/blob/main/backend/controllers/orderController.js"
click node_ordermodel "https://github.com/segjay/urbancartmern/blob/main/backend/models/Order.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_home,node_detail,node_cart,node_checkout,node_orderspage,node_productcard toneBlue
class node_authcontext,node_login,node_register,node_adminusers,node_userroutes,node_userctrl,node_usermodel toneAmber
class node_adminproducts,node_productroutes,node_productctrl,node_productmodel toneMint
class node_cartcontext,node_orderroutes,node_orderctrl,node_ordermodel toneRose
class node_api,node_server,node_customer toneIndigo
```

## Components

### Storefront

- [Route shell](https://github.com/segjay/urbancartmern/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Storefront](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Product detail](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/ProductDetail.jsx): `frontend/src/pages/ProductDetail.jsx`
- [Shopping cart](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Cart.jsx): `frontend/src/pages/Cart.jsx`
- [Checkout](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Checkout.jsx): `frontend/src/pages/Checkout.jsx`
- [Order history](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/MyOrders.jsx): `frontend/src/pages/MyOrders.jsx`
- [Product card](https://github.com/segjay/urbancartmern/blob/main/frontend/src/components/ProductCard.jsx): `frontend/src/components/ProductCard.jsx`

### Accounts

- [Login state](https://github.com/segjay/urbancartmern/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Sign in](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [User admin](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/admin/AdminUsers.jsx): `frontend/src/pages/admin/AdminUsers.jsx`
- [User routes](https://github.com/segjay/urbancartmern/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [User handlers](https://github.com/segjay/urbancartmern/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [User records](https://github.com/segjay/urbancartmern/blob/main/backend/models/User.js): `backend/models/User.js`

### Catalog

- [Product admin](https://github.com/segjay/urbancartmern/blob/main/frontend/src/pages/admin/AdminProducts.jsx): `frontend/src/pages/admin/AdminProducts.jsx`
- [Product routes](https://github.com/segjay/urbancartmern/blob/main/backend/routes/productRoutes.js): `backend/routes/productRoutes.js`
- [Product handlers](https://github.com/segjay/urbancartmern/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Product records](https://github.com/segjay/urbancartmern/blob/main/backend/models/product.js): `backend/models/product.js`

### Orders

- [Cart state](https://github.com/segjay/urbancartmern/blob/main/frontend/src/context/CartContext.jsx): `frontend/src/context/CartContext.jsx`
- [Order routes](https://github.com/segjay/urbancartmern/blob/main/backend/routes/orderRoutes.js): `backend/routes/orderRoutes.js`
- [Order handlers](https://github.com/segjay/urbancartmern/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`
- [Order records](https://github.com/segjay/urbancartmern/blob/main/backend/models/Order.js): `backend/models/Order.js`

### API and data

- [API client](https://github.com/segjay/urbancartmern/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Express server](https://github.com/segjay/urbancartmern/blob/main/backend/server.js): `backend/server.js`

### Other components

- **Shopper**

## Connections

- Shopper → Route shell: visits (evidence: `frontend/src/App.jsx`)
- Route shell → Storefront: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Product detail: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Shopping cart: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Checkout: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Order history: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Sign in: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Registration: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Product admin: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → User admin: routes to (evidence: `frontend/src/App.jsx`)
- Storefront → API client: fetches products (evidence: `frontend/src/pages/Home.jsx`)
- Storefront → Product card: renders (evidence: `frontend/src/pages/Home.jsx`)
- Product detail → API client: fetches product (evidence: `frontend/src/pages/ProductDetail.jsx`)
- Product detail → Cart state: adds item (evidence: `frontend/src/pages/ProductDetail.jsx`)
- Shopping cart → Cart state: reads and updates (evidence: `frontend/src/pages/Cart.jsx`)
- Checkout → Cart state: reads cart (evidence: `frontend/src/pages/Checkout.jsx`)
- Checkout → Login state: reads account (evidence: `frontend/src/pages/Checkout.jsx`)
- Checkout → API client: submits order (evidence: `frontend/src/pages/Checkout.jsx`)
- Order history → API client: fetches orders (evidence: `frontend/src/pages/MyOrders.jsx`)
- Sign in → Login state: sets login (evidence: `frontend/src/pages/Login.jsx`)
- Sign in → API client: authenticates (evidence: `frontend/src/pages/Login.jsx`)
- Registration → API client: registers (evidence: `frontend/src/pages/Register.jsx`)
- Product card → Cart state: adds item (evidence: `frontend/src/components/ProductCard.jsx`)
- User admin → Login state: reads account (evidence: `frontend/src/pages/admin/AdminUsers.jsx`)
- API client → Express server: HTTP requests (evidence: `frontend/src/services/api.js`)
- Express server → Product routes: mounts (evidence: `backend/server.js`)
- Express server → User routes: mounts (evidence: `backend/server.js`)
- Express server → Order routes: mounts (evidence: `backend/server.js`)
- Product routes → Product handlers: dispatches (evidence: `backend/routes/productRoutes.js`)
- Product handlers → Product records: queries and saves (evidence: `backend/controllers/productController.js`)
- User routes → User handlers: dispatches (evidence: `backend/routes/userRoutes.js`)
- User handlers → User records: queries and saves (evidence: `backend/controllers/userController.js`)
- Order routes → Order handlers: dispatches (evidence: `backend/routes/orderRoutes.js`)
- Order handlers → Order records: queries and saves (evidence: `backend/controllers/orderController.js`)
