# yashh-ops/offduty architecture

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

- Interactive diagram: https://gitdiagram.com/yashh-ops/offduty
- Repository: https://github.com/yashh-ops/offduty

## Overview

OFFDUTY is a three-application commerce product: a customer storefront, a separate admin console, and an Express/Mongoose API. Customers browse and filter clothing, manage carts and wishlists, authenticate, and proceed through checkout; staff manage catalog, orders, and other store operations. The README identifies campaign merchandising, clothing metadata, and gender/fit filtering, while noting that variant-level checkout and live integrations are not verified. Some backend route and page implementations were not sampled, so the graph omits uncertain links rather than inferring them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/yashh-ops/offduty/blob/main/frontend/src/App.jsx) (Storefront app), [`backend/server.js`](https://github.com/yashh-ops/offduty/blob/main/backend/server.js) (REST API server), [`backend/src/controllers/productController.js`](https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/productController.js) (Catalog and filtering), [`backend/src/controllers/orderController.js`](https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/orderController.js) (Orders and checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_storefront_app["Storefront app<br/>[App.jsx]"]
  node_discovery["Browse catalog<br/>[Shop.jsx]"]
  node_product_view["Product detail<br/>[Product.jsx]"]
  node_cart_state["Cart state<br/>[CartContext.jsx]"]
  node_checkout["Cart and checkout<br/>[Cart.jsx]"]
  node_customer_auth["Customer account<br/>[AuthContext.jsx]"]
  node_wishlist["Wishlist"]
  node_product_client["Product API client<br/>[productService.js]"]
  node_order_client["Order API client<br/>[orderService.js]"]
end

subgraph group_admin["Store administration"]
  node_admin_app["Admin console<br/>[App.jsx]"]
  node_admin_auth["Staff authentication<br/>[AuthContext.jsx]"]
  node_catalog_admin["Catalog management<br/>[ProductForm.jsx]"]
  node_admin_api_client["Admin API client<br/>[api.js]"]
end

subgraph group_api["Commerce API"]
  node_commerce_api["REST API server<br/>[server.js]"]
  node_product_routes["Product routes<br/>[productRoutes.js]"]
  node_product_logic["Catalog and filtering"]
  node_order_logic["Orders and checkout<br/>[orderController.js]"]
  node_user_logic["User operations<br/>[userController.js]"]
  node_wishlist_routes["Wishlist operations<br/>[wishlistRoutes.js]"]
end

subgraph group_data["Persistence and media"]
  node_product_model[("Product records<br/>[Product.js]")]
  node_order_model[("Order records<br/>[Order.js]")]
  node_user_model[("User records<br/>[User.js]")]
  node_collection_model[("Collections<br/>[Collection.js]")]
  node_image_store["Image upload helper<br/>[uploadImage.js]"]
  node_mongodb[("MongoDB")]
end

subgraph group_integrations["External services"]
  node_shiprocket["Shiprocket"]
  node_razorpay["Razorpay"]
end

node_customer(("Shopper"))
node_admin_user(("Store staff"))

node_customer -->|"uses"| node_storefront_app
node_storefront_app -->|"routes to"| node_discovery
node_storefront_app -->|"routes to"| node_product_view
node_storefront_app -->|"routes to"| node_checkout
node_storefront_app -->|"provides"| node_customer_auth
node_storefront_app -->|"provides"| node_cart_state
node_storefront_app -->|"provides"| node_wishlist
node_discovery -->|"fetches products"| node_product_client
node_product_view -->|"fetches products"| node_product_client
node_checkout -->|"uses cart"| node_cart_state
node_checkout -->|"submits orders"| node_order_client
node_admin_user -->|"uses"| node_admin_app
node_admin_app -->|"provides"| node_admin_auth
node_admin_app -->|"routes to"| node_catalog_admin
node_admin_auth -->|"calls"| node_admin_api_client
node_catalog_admin -->|"calls"| node_admin_api_client
node_commerce_api -->|"mounts routes"| node_product_routes
node_product_routes -->|"routes requests"| node_product_logic
node_product_logic -->|"queries"| node_product_model
node_product_logic -->|"queries"| node_collection_model
node_product_logic -->|"uploads images"| node_image_store
node_order_logic -->|"checks inventory"| node_product_model
node_order_logic -->|"creates orders"| node_order_model
node_order_logic -->|"fulfills shipments"| node_shiprocket
node_wishlist_routes -->|"updates wishlist"| node_user_model
node_wishlist_routes -->|"checks products"| node_product_model
node_user_logic -->|"queries users"| node_user_model
node_commerce_api -.->|"connects database"| node_mongodb
node_commerce_api -.->|"handles payments"| node_razorpay
node_product_client -.->|"calls API"| node_commerce_api
node_order_client -.->|"calls API"| node_commerce_api
node_admin_api_client -.->|"calls API"| node_commerce_api

click node_storefront_app "https://github.com/yashh-ops/offduty/blob/main/frontend/src/App.jsx"
click node_discovery "https://github.com/yashh-ops/offduty/blob/main/frontend/src/pages/Shop.jsx"
click node_product_view "https://github.com/yashh-ops/offduty/blob/main/frontend/src/pages/Product.jsx"
click node_cart_state "https://github.com/yashh-ops/offduty/blob/main/frontend/src/context/CartContext.jsx"
click node_checkout "https://github.com/yashh-ops/offduty/blob/main/frontend/src/pages/Cart.jsx"
click node_customer_auth "https://github.com/yashh-ops/offduty/blob/main/frontend/src/context/AuthContext.jsx"
click node_wishlist "https://github.com/yashh-ops/offduty/blob/main/frontend/src/context/WishlistContext.jsx"
click node_product_client "https://github.com/yashh-ops/offduty/blob/main/frontend/src/services/productService.js"
click node_order_client "https://github.com/yashh-ops/offduty/blob/main/frontend/src/services/orderService.js"
click node_admin_app "https://github.com/yashh-ops/offduty/blob/main/admin/src/App.jsx"
click node_admin_auth "https://github.com/yashh-ops/offduty/blob/main/admin/src/context/AuthContext.jsx"
click node_catalog_admin "https://github.com/yashh-ops/offduty/blob/main/admin/src/pages/ProductForm.jsx"
click node_admin_api_client "https://github.com/yashh-ops/offduty/blob/main/admin/src/lib/api.js"
click node_commerce_api "https://github.com/yashh-ops/offduty/blob/main/backend/server.js"
click node_product_routes "https://github.com/yashh-ops/offduty/blob/main/backend/src/routes/productRoutes.js"
click node_product_logic "https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/productController.js"
click node_order_logic "https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/orderController.js"
click node_user_logic "https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/userController.js"
click node_wishlist_routes "https://github.com/yashh-ops/offduty/blob/main/backend/src/routes/wishlistRoutes.js"
click node_product_model "https://github.com/yashh-ops/offduty/blob/main/backend/src/models/Product.js"
click node_order_model "https://github.com/yashh-ops/offduty/blob/main/backend/src/models/Order.js"
click node_user_model "https://github.com/yashh-ops/offduty/blob/main/backend/src/models/User.js"
click node_collection_model "https://github.com/yashh-ops/offduty/blob/main/backend/src/models/Collection.js"
click node_image_store "https://github.com/yashh-ops/offduty/blob/main/backend/src/utils/uploadImage.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_app,node_discovery,node_product_view,node_cart_state,node_checkout,node_customer_auth,node_wishlist,node_product_client,node_order_client toneBlue
class node_admin_app,node_admin_auth,node_catalog_admin,node_admin_api_client toneAmber
class node_commerce_api,node_product_routes,node_product_logic,node_order_logic,node_user_logic,node_wishlist_routes toneMint
class node_product_model,node_order_model,node_user_model,node_collection_model,node_image_store,node_mongodb toneRose
class node_shiprocket,node_razorpay,node_customer,node_admin_user toneIndigo
```

## Components

### Customer storefront

- [Storefront app](https://github.com/yashh-ops/offduty/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Browse catalog](https://github.com/yashh-ops/offduty/blob/main/frontend/src/pages/Shop.jsx): `frontend/src/pages/Shop.jsx`
- [Product detail](https://github.com/yashh-ops/offduty/blob/main/frontend/src/pages/Product.jsx): `frontend/src/pages/Product.jsx`
- [Cart state](https://github.com/yashh-ops/offduty/blob/main/frontend/src/context/CartContext.jsx): `frontend/src/context/CartContext.jsx`
- [Cart and checkout](https://github.com/yashh-ops/offduty/blob/main/frontend/src/pages/Cart.jsx): `frontend/src/pages/Cart.jsx`
- [Customer account](https://github.com/yashh-ops/offduty/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Wishlist](https://github.com/yashh-ops/offduty/blob/main/frontend/src/context/WishlistContext.jsx): `frontend/src/context/WishlistContext.jsx`
- [Product API client](https://github.com/yashh-ops/offduty/blob/main/frontend/src/services/productService.js): `frontend/src/services/productService.js`
- [Order API client](https://github.com/yashh-ops/offduty/blob/main/frontend/src/services/orderService.js): `frontend/src/services/orderService.js`

### Store administration

- [Admin console](https://github.com/yashh-ops/offduty/blob/main/admin/src/App.jsx): `admin/src/App.jsx`
- [Staff authentication](https://github.com/yashh-ops/offduty/blob/main/admin/src/context/AuthContext.jsx): `admin/src/context/AuthContext.jsx`
- [Catalog management](https://github.com/yashh-ops/offduty/blob/main/admin/src/pages/ProductForm.jsx): `admin/src/pages/ProductForm.jsx`
- [Admin API client](https://github.com/yashh-ops/offduty/blob/main/admin/src/lib/api.js): `admin/src/lib/api.js`

### Commerce API

- [REST API server](https://github.com/yashh-ops/offduty/blob/main/backend/server.js): `backend/server.js`
- [Product routes](https://github.com/yashh-ops/offduty/blob/main/backend/src/routes/productRoutes.js): `backend/src/routes/productRoutes.js`
- [Catalog and filtering](https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/productController.js): `backend/src/controllers/productController.js`
- [Orders and checkout](https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/orderController.js): `backend/src/controllers/orderController.js`
- [User operations](https://github.com/yashh-ops/offduty/blob/main/backend/src/controllers/userController.js): `backend/src/controllers/userController.js`
- [Wishlist operations](https://github.com/yashh-ops/offduty/blob/main/backend/src/routes/wishlistRoutes.js): `backend/src/routes/wishlistRoutes.js`

### Persistence and media

- [Product records](https://github.com/yashh-ops/offduty/blob/main/backend/src/models/Product.js): `backend/src/models/Product.js`
- [Order records](https://github.com/yashh-ops/offduty/blob/main/backend/src/models/Order.js): `backend/src/models/Order.js`
- [User records](https://github.com/yashh-ops/offduty/blob/main/backend/src/models/User.js): `backend/src/models/User.js`
- [Collections](https://github.com/yashh-ops/offduty/blob/main/backend/src/models/Collection.js): `backend/src/models/Collection.js`
- [Image upload helper](https://github.com/yashh-ops/offduty/blob/main/backend/src/utils/uploadImage.js): `backend/src/utils/uploadImage.js`
- **MongoDB**

### External services

- **Shiprocket**
- **Razorpay**

### Other components

- **Shopper**
- **Store staff**

## Connections

- Shopper → Storefront app: uses (evidence: `frontend/src/App.jsx`)
- Storefront app → Browse catalog: routes to (evidence: `frontend/src/App.jsx`)
- Storefront app → Product detail: routes to (evidence: `frontend/src/App.jsx`)
- Storefront app → Cart and checkout: routes to (evidence: `frontend/src/App.jsx`)
- Storefront app → Customer account: provides (evidence: `frontend/src/App.jsx`)
- Storefront app → Cart state: provides (evidence: `frontend/src/App.jsx`)
- Storefront app → Wishlist: provides (evidence: `frontend/src/App.jsx`)
- Browse catalog → Product API client: fetches products (evidence: `frontend/src/services/productService.js`)
- Product detail → Product API client: fetches products (evidence: `frontend/src/services/productService.js`)
- Cart and checkout → Cart state: uses cart (evidence: `frontend/src/App.jsx`)
- Cart and checkout → Order API client: submits orders (evidence: `frontend/src/services/orderService.js`)
- Store staff → Admin console: uses (evidence: `admin/src/App.jsx`)
- Admin console → Staff authentication: provides (evidence: `admin/src/App.jsx`)
- Admin console → Catalog management: routes to (evidence: `admin/src/App.jsx`)
- Staff authentication → Admin API client: calls (evidence: `admin/src/context/AuthContext.jsx`)
- Catalog management → Admin API client: calls (evidence: `admin/src/pages/ProductForm.jsx`)
- REST API server → Product routes: mounts routes (evidence: `backend/server.js`)
- Product routes → Catalog and filtering: routes requests (evidence: `backend/src/routes/productRoutes.js`)
- Catalog and filtering → Product records: queries (evidence: `backend/src/controllers/productController.js`)
- Catalog and filtering → Collections: queries (evidence: `backend/src/controllers/productController.js`)
- Catalog and filtering → Image upload helper: uploads images (evidence: `backend/src/controllers/productController.js`)
- Orders and checkout → Product records: checks inventory (evidence: `backend/src/controllers/orderController.js`)
- Orders and checkout → Order records: creates orders (evidence: `backend/src/controllers/orderController.js`)
- Orders and checkout → Shiprocket: fulfills shipments (evidence: `backend/src/controllers/orderController.js`)
- Wishlist operations → User records: updates wishlist (evidence: `backend/src/routes/wishlistRoutes.js`)
- Wishlist operations → Product records: checks products (evidence: `backend/src/routes/wishlistRoutes.js`)
- User operations → User records: queries users (evidence: `backend/src/controllers/userController.js`)
- REST API server → MongoDB: connects database (evidence: `README.md`)
- REST API server → Razorpay: handles payments (evidence: `README.md`)
- Product API client → REST API server: calls API (evidence: `README.md`)
- Order API client → REST API server: calls API (evidence: `README.md`)
- Admin API client → REST API server: calls API (evidence: `README.md`)
