# rohandevtech23/primenest-e-commerce architecture

> Architecture diagram of the GitHub repository rohandevtech23/primenest-e-commerce, 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/rohandevtech23/primenest-e-commerce
- Repository: https://github.com/rohandevtech23/primenest-e-commerce

## Overview

PrimeNest is a consumer storefront with product discovery, saved items, cart and checkout, customer accounts, reviews, AI shopping features, and an administration area. The principal customer journey moves from browsing a catalog to a product page, then cart and checkout; checkout submission is handled by the orders API, which verifies the customer session and persists the order while updating stock. Source excerpts establish several API-to-database and API-to-auth relationships, but do not show most page-to-API wiring, so those links are omitted.

Main entry points: [`app/product/[id]/page.js`](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/product/%5Bid%5D/page.js) (Product detail), [`lib/auth.js`](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/auth.js) (Session tokens), [`lib/db.js`](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/db.js) (PostgreSQL), [`app/page.tsx`](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/page.tsx) (Home & discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home &amp; discovery<br/>[page.tsx]"]
  node_catalog["Shop &amp; search<br/>[page.js]"]
  node_product["Product detail<br/>[page.js]"]
  node_navigation["Navigation<br/>[Navbar.jsx]"]
  node_cart["Cart state<br/>[CartContext.jsx]"]
  node_wishlist["Wishlist state"]
end

subgraph group_customer["Customer account"]
  node_addresses_api["Address API<br/>[route.js]"]
  node_profile["Customer profile<br/>[page.jsx]"]
  node_auth["Session tokens<br/>[auth.js]"]
end

subgraph group_commerce["Commerce services"]
  node_checkout["Checkout<br/>[page.jsx]"]
  node_orders["Order API<br/>[route.js]"]
  node_products_api["Product API<br/>[route.js]"]
  node_reviews_api["Reviews API<br/>[route.js]"]
  node_database[("PostgreSQL<br/>[db.js]")]
end

subgraph group_ai["AI features"]
  node_review_ai["Review insights"]
  node_assistant["Shopping assistant"]
  node_tryon["Virtual try-on"]
  node_ai_api["AI endpoints"]
  node_ai_library["AI services<br/>[ai.js]"]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin console"]
  node_admin_products["Admin product API<br/>[route.js]"]
  node_admin_stats["Admin analytics API<br/>[route.js]"]
end

node_shopper(("Shopper"))

node_shopper -->|"browses"| node_home
node_shopper -->|"browses"| node_catalog
node_shopper -->|"views"| node_product
node_home -->|"renders"| node_navigation
node_home -->|"showcases products"| node_catalog
node_product -->|"uses"| node_cart
node_product -->|"uses"| node_wishlist
node_product -->|"renders"| node_tryon
node_product -->|"renders"| node_review_ai
node_navigation -->|"reads count"| node_cart
node_navigation -->|"reads count"| node_wishlist
node_checkout -->|"uses cart"| node_cart
node_orders -->|"verifies session"| node_auth
node_orders -->|"reads and writes"| node_database
node_reviews_api -->|"verifies session"| node_auth
node_reviews_api -->|"reads and writes"| node_database
node_addresses_api -->|"verifies session"| node_auth
node_addresses_api -->|"reads and writes"| node_database
node_admin_products -->|"verifies session"| node_auth
node_admin_products -->|"reads and writes"| node_database
node_admin_stats -->|"verifies session"| node_auth
node_admin_stats -->|"queries metrics"| node_database

click node_home "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/page.tsx"
click node_catalog "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/shop/page.js"
click node_product "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/product/%5Bid%5D/page.js"
click node_navigation "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/Navbar.jsx"
click node_cart "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/context/CartContext.jsx"
click node_wishlist "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/context/WishlistContext.jsx"
click node_checkout "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/checkout/page.jsx"
click node_orders "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/orders/route.js"
click node_products_api "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/products/route.js"
click node_reviews_api "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/reviews/route.js"
click node_addresses_api "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/profile/addresses/route.js"
click node_profile "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/profile/page.jsx"
click node_auth "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/auth.js"
click node_database "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/db.js"
click node_review_ai "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/AIReviewSummarizer.jsx"
click node_assistant "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/AIShoppingAssistant.jsx"
click node_tryon "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/VirtualTryOnModal.jsx"
click node_ai_api "https://github.com/rohandevtech23/primenest-e-commerce/tree/main/app/api/ai"
click node_admin_ui "https://github.com/rohandevtech23/primenest-e-commerce/tree/main/app/admin"
click node_admin_products "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/admin/products/route.js"
click node_admin_stats "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/admin/stats/route.js"
click node_ai_library "https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/ai.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_home,node_catalog,node_product,node_navigation,node_cart,node_wishlist toneBlue
class node_addresses_api,node_profile,node_auth toneAmber
class node_checkout,node_orders,node_products_api,node_reviews_api,node_database toneMint
class node_review_ai,node_assistant,node_tryon,node_ai_api,node_ai_library toneRose
class node_admin_ui,node_admin_products,node_admin_stats,node_shopper toneIndigo
```

## Components

### Storefront

- [Home & discovery](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/page.tsx): `app/page.tsx`
- [Shop & search](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/shop/page.js): `app/shop/page.js`
- [Product detail](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/product/%5Bid%5D/page.js): `app/product/[id]/page.js`
- [Navigation](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/Navbar.jsx): `components/Navbar.jsx`
- [Cart state](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/context/CartContext.jsx): `context/CartContext.jsx`
- [Wishlist state](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/context/WishlistContext.jsx): `context/WishlistContext.jsx`

### Customer account

- [Address API](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/profile/addresses/route.js): `app/api/profile/addresses/route.js`
- [Customer profile](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/profile/page.jsx): `app/profile/page.jsx`
- [Session tokens](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/auth.js): `lib/auth.js`

### Commerce services

- [Checkout](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/checkout/page.jsx): `app/checkout/page.jsx`
- [Order API](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/orders/route.js): `app/api/orders/route.js`
- [Product API](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/products/route.js): `app/api/products/route.js`
- [Reviews API](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/reviews/route.js): `app/api/reviews/route.js`
- [PostgreSQL](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/db.js): `lib/db.js`

### AI features

- [Review insights](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/AIReviewSummarizer.jsx): `components/AIReviewSummarizer.jsx`
- [Shopping assistant](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/AIShoppingAssistant.jsx): `components/AIShoppingAssistant.jsx`
- [Virtual try-on](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/components/VirtualTryOnModal.jsx): `components/VirtualTryOnModal.jsx`
- [AI endpoints](https://github.com/rohandevtech23/primenest-e-commerce/tree/main/app/api/ai): `app/api/ai`
- [AI services](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/lib/ai.js): `lib/ai.js`

### Administration

- [Admin console](https://github.com/rohandevtech23/primenest-e-commerce/tree/main/app/admin): `app/admin`
- [Admin product API](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/admin/products/route.js): `app/api/admin/products/route.js`
- [Admin analytics API](https://github.com/rohandevtech23/primenest-e-commerce/blob/main/app/api/admin/stats/route.js): `app/api/admin/stats/route.js`

### Other components

- **Shopper**

## Connections

- Shopper → Home & discovery: browses (evidence: `app/page.tsx`)
- Shopper → Shop & search: browses (evidence: `app/shop/page.js`)
- Shopper → Product detail: views (evidence: `app/product/[id]/page.js`)
- Home & discovery → Navigation: renders (evidence: `app/page.tsx`)
- Home & discovery → Shop & search: showcases products (evidence: `app/page.tsx`)
- Product detail → Cart state: uses (evidence: `app/product/[id]/page.js`)
- Product detail → Wishlist state: uses (evidence: `app/product/[id]/page.js`)
- Product detail → Virtual try-on: renders (evidence: `app/product/[id]/page.js`)
- Product detail → Review insights: renders (evidence: `app/product/[id]/page.js`)
- Navigation → Cart state: reads count (evidence: `components/Navbar.jsx`)
- Navigation → Wishlist state: reads count (evidence: `components/Navbar.jsx`)
- Checkout → Cart state: uses cart (evidence: `app/checkout/page.jsx`)
- Order API → Session tokens: verifies session (evidence: `app/api/orders/route.js`)
- Order API → PostgreSQL: reads and writes (evidence: `app/api/orders/route.js`)
- Reviews API → Session tokens: verifies session (evidence: `app/api/reviews/route.js`)
- Reviews API → PostgreSQL: reads and writes (evidence: `app/api/reviews/route.js`)
- Address API → Session tokens: verifies session (evidence: `app/api/profile/addresses/route.js`)
- Address API → PostgreSQL: reads and writes (evidence: `app/api/profile/addresses/route.js`)
- Admin product API → Session tokens: verifies session (evidence: `app/api/admin/products/route.js`)
- Admin product API → PostgreSQL: reads and writes (evidence: `app/api/admin/products/route.js`)
- Admin analytics API → Session tokens: verifies session (evidence: `app/api/admin/stats/route.js`)
- Admin analytics API → PostgreSQL: queries metrics (evidence: `app/api/admin/stats/route.js`)
