# noorjsdivs/shopcartpro-yt architecture

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

- Interactive diagram: https://gitdiagram.com/noorjsdivs/shopcartpro-yt
- Repository: https://github.com/noorjsdivs/shopcartpro-yt

## Overview

ShopCart Pro is a Sanity-backed commerce application with Clerk authentication and Stripe/Clerk payment options. The main customer journey is browsing products, building a cart, placing an order, processing payment, and viewing order history; administrators also manage catalog, orders, accounts, reviews, subscriptions, and analytics. The graph preserves these documented capabilities and the sampled order, webhook, and Sanity layers. Many UI and admin route implementations were not sampled, so their documented connections are shown at capability level rather than as detailed call chains.

Main entry points: [`app/(admin)/admin/page.tsx`](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(admin)/admin/page.tsx) (Admin console), [`sanity/lib/backendClient.ts`](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/lib/backendClient.ts) (Sanity CMS), [`app/api/orders/route.ts`](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/orders/route.ts) (Order handling), [`app/api/webhook/route.ts`](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/webhook/route.ts) (Payment webhook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront &amp; discovery"]
  node_catalog["Product discovery<br/>[page.tsx]"]
  node_category["Category browsing"]
end

subgraph group_customer["Customer commerce"]
  node_cart["Persistent cart"]
  node_checkout["Checkout"]
  node_orderapi["Order handling<br/>[route.ts]"]
  node_payment["Payment processing<br/>[route.ts]"]
  node_ordersview["Order history"]
  node_wishlist["Wishlist<br/>[ServerWishlist.tsx]"]
  node_profile["Profile &amp; addresses<br/>[ProfileClient.tsx]"]
end

subgraph group_operations["Admin &amp; operations"]
  node_admin["Admin console<br/>[page.tsx]"]
  node_adminorders["Order operations<br/>[route.ts]"]
  node_accounts["Account requests"]
  node_analytics["Business analytics<br/>[route.ts]"]
  node_reviews["Review management<br/>[AdminReviews.tsx]"]
  node_subscriptions["Subscriptions<br/>[route.ts]"]
  node_employee["Employee portal<br/>[page.tsx]"]
end

subgraph group_services["Application services"]
  node_webhook["Payment webhook<br/>[route.ts]"]
  node_notify["Order notifications"]
  node_email["Email delivery<br/>[emailService.ts]"]
end

subgraph group_content["Content &amp; persistence"]
  node_productdata["Catalog queries<br/>[query.ts]"]
  node_sanity[("Sanity CMS<br/>[backendClient.ts]")]
  node_queryhelpers["Order query helpers<br/>[index.ts]"]
end

node_shopper(("Shopper"))
node_stripe{{"Stripe"}}
node_clerk{{"Clerk identity"}}

node_shopper -->|"browses"| node_catalog
node_catalog -->|"filters products"| node_category
node_category -->|"queries catalog"| node_productdata
node_shopper -->|"adds products"| node_cart
node_cart -->|"proceeds to"| node_checkout
node_checkout -->|"submits order"| node_orderapi
node_orderapi -->|"authenticates with"| node_clerk
node_orderapi -->|"creates order"| node_sanity
node_orderapi -->|"sends status"| node_notify
node_checkout -.->|"starts payment"| node_payment
node_payment -->|"charges via"| node_stripe
node_stripe -.->|"posts payment event"| node_webhook
node_webhook -->|"retrieves invoice"| node_stripe
node_webhook -->|"reads and updates"| node_sanity
node_webhook -->|"sends status"| node_notify
node_notify -->|"uses CMS client"| node_sanity
node_shopper -->|"tracks orders"| node_ordersview
node_ordersview -->|"loads order history"| node_queryhelpers
node_queryhelpers -->|"fetches orders"| node_sanity
node_shopper -->|"saves favorites"| node_wishlist
node_shopper -->|"manages account"| node_profile
node_profile -.->|"uses identity"| node_clerk
node_shopper -->|"administers store"| node_admin
node_admin -.->|"manages orders"| node_adminorders
node_admin -.->|"reviews applications"| node_accounts
node_admin -.->|"views insights"| node_analytics
node_admin -.->|"moderates reviews"| node_reviews
node_admin -.->|"manages campaigns"| node_subscriptions
node_admin -.->|"assigns staff"| node_employee
node_subscriptions -->|"sends email"| node_email
node_subscriptions -->|"uses CMS data"| node_sanity
node_analytics -->|"queries metrics"| node_sanity

click node_catalog "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(client)/page.tsx"
click node_category "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/CategoryPageClient.tsx"
click node_productdata "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/queries/query.ts"
click node_cart "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/cart/ServerCartContent.tsx"
click node_checkout "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/checkout/CheckoutContent.tsx"
click node_orderapi "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/orders/route.ts"
click node_payment "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/checkout/stripe/route.ts"
click node_ordersview "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/ResponsiveOrdersComponent.tsx"
click node_wishlist "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/wishlist/ServerWishlist.tsx"
click node_profile "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/profile/ProfileClient.tsx"
click node_admin "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(admin)/admin/page.tsx"
click node_adminorders "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/admin/orders/route.ts"
click node_accounts "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/admin/AccountRequestsClient.tsx"
click node_analytics "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/admin/analytics/route.ts"
click node_reviews "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/admin/AdminReviews.tsx"
click node_subscriptions "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/newsletter/subscribe/route.ts"
click node_employee "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(employee)/employee/page.tsx"
click node_webhook "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/webhook/route.ts"
click node_notify "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/lib/notificationService.ts"
click node_email "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/lib/emailService.ts"
click node_sanity "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/lib/backendClient.ts"
click node_queryhelpers "https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/helpers/index.ts"

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_catalog,node_category toneBlue
class node_cart,node_checkout,node_orderapi,node_payment,node_ordersview,node_wishlist,node_profile toneAmber
class node_admin,node_adminorders,node_accounts,node_analytics,node_reviews,node_subscriptions,node_employee toneMint
class node_webhook,node_notify,node_email toneRose
class node_productdata,node_sanity,node_queryhelpers,node_shopper,node_stripe,node_clerk toneIndigo
```

## Components

### Storefront & discovery

- [Product discovery](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(client)/page.tsx): `app/(client)/page.tsx`
- [Category browsing](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/CategoryPageClient.tsx): `components/CategoryPageClient.tsx`

### Customer commerce

- [Persistent cart](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/cart/ServerCartContent.tsx): `components/cart/ServerCartContent.tsx`
- [Checkout](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/checkout/CheckoutContent.tsx): `components/checkout/CheckoutContent.tsx`
- [Order handling](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/orders/route.ts): `app/api/orders/route.ts`
- [Payment processing](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/checkout/stripe/route.ts): `app/api/checkout/stripe/route.ts`
- [Order history](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/ResponsiveOrdersComponent.tsx): `components/ResponsiveOrdersComponent.tsx`
- [Wishlist](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/wishlist/ServerWishlist.tsx): `components/wishlist/ServerWishlist.tsx`
- [Profile & addresses](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/profile/ProfileClient.tsx): `components/profile/ProfileClient.tsx`

### Admin & operations

- [Admin console](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(admin)/admin/page.tsx): `app/(admin)/admin/page.tsx`
- [Order operations](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/admin/orders/route.ts): `app/api/admin/orders/route.ts`
- [Account requests](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/admin/AccountRequestsClient.tsx): `components/admin/AccountRequestsClient.tsx`
- [Business analytics](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/admin/analytics/route.ts): `app/api/admin/analytics/route.ts`
- [Review management](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/components/admin/AdminReviews.tsx): `components/admin/AdminReviews.tsx`
- [Subscriptions](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/newsletter/subscribe/route.ts): `app/api/newsletter/subscribe/route.ts`
- [Employee portal](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/(employee)/employee/page.tsx): `app/(employee)/employee/page.tsx`

### Application services

- [Payment webhook](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/app/api/webhook/route.ts): `app/api/webhook/route.ts`
- [Order notifications](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/lib/notificationService.ts): `lib/notificationService.ts`
- [Email delivery](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/lib/emailService.ts): `lib/emailService.ts`

### Content & persistence

- [Catalog queries](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/queries/query.ts): `sanity/queries/query.ts`
- [Sanity CMS](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/lib/backendClient.ts): `sanity/lib/backendClient.ts`
- [Order query helpers](https://github.com/noorjsdivs/shopcartpro-yt/blob/main/sanity/helpers/index.ts): `sanity/helpers/index.ts`

### Other components

- **Shopper**
- **Stripe**
- **Clerk identity**

## Connections

- Shopper → Product discovery: browses (evidence: `README.md`)
- Product discovery → Category browsing: filters products (evidence: `README.md`)
- Category browsing → Catalog queries: queries catalog (evidence: `sanity/queries/query.ts`)
- Shopper → Persistent cart: adds products (evidence: `README.md`)
- Persistent cart → Checkout: proceeds to (evidence: `README.md`)
- Checkout → Order handling: submits order (evidence: `README.md`)
- Order handling → Clerk identity: authenticates with (evidence: `app/api/orders/route.ts`)
- Order handling → Sanity CMS: creates order (evidence: `app/api/orders/route.ts`)
- Order handling → Order notifications: sends status (evidence: `app/api/orders/route.ts`)
- Checkout → Payment processing: starts payment (evidence: `README.md`)
- Payment processing → Stripe: charges via (evidence: `README.md`)
- Stripe → Payment webhook: posts payment event (evidence: `README.md`)
- Payment webhook → Stripe: retrieves invoice (evidence: `app/api/webhook/route.ts`)
- Payment webhook → Sanity CMS: reads and updates (evidence: `app/api/webhook/route.ts`)
- Payment webhook → Order notifications: sends status (evidence: `app/api/webhook/route.ts`)
- Order notifications → Sanity CMS: uses CMS client (evidence: `lib/notificationService.ts`)
- Shopper → Order history: tracks orders (evidence: `README.md`)
- Order history → Order query helpers: loads order history
- Order query helpers → Sanity CMS: fetches orders (evidence: `sanity/helpers/index.ts`)
- Shopper → Wishlist: saves favorites (evidence: `README.md`)
- Shopper → Profile & addresses: manages account (evidence: `README.md`)
- Profile & addresses → Clerk identity: uses identity (evidence: `README.md`)
- Shopper → Admin console: administers store (evidence: `README.md`)
- Admin console → Order operations: manages orders (evidence: `README.md`)
- Admin console → Account requests: reviews applications (evidence: `README.md`)
- Admin console → Business analytics: views insights (evidence: `README.md`)
- Admin console → Review management: moderates reviews (evidence: `README.md`)
- Admin console → Subscriptions: manages campaigns (evidence: `README.md`)
- Admin console → Employee portal: assigns staff (evidence: `README.md`)
- Subscriptions → Email delivery: sends email (evidence: `app/api/newsletter/subscribe/route.ts`)
- Subscriptions → Sanity CMS: uses CMS data
- Business analytics → Sanity CMS: queries metrics (evidence: `app/api/admin/analytics/route.ts`)
