# thakur2sahil/e-commerce architecture

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

- Interactive diagram: https://gitdiagram.com/thakur2sahil/e-commerce
- Repository: https://github.com/thakur2sahil/e-commerce

## Overview

This repository is a Next.js storefront with customer shopping and account flows plus administrative product, category, order, and user management. The main customer journey is browsing products, adding items to a cart, maintaining addresses, and placing an order; administrative screens manage the catalog and fulfillment. The graph includes sampled API, cart, authentication, and database relationships, and preserves major unsampled route families from the tree. Some UI-to-API wiring and unsampled admin behavior are not evidenced in the excerpts, so those links are omitted.

Main entry points: [`src/_component/ProductCard.tsx`](https://github.com/thakur2sahil/e-commerce/blob/main/src/_component/ProductCard.tsx) (Product cards), [`src/_lib/prisma.ts`](https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/prisma.ts) (Application database), [`src/app/admin`](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin) (Admin workspace), [`src/app/api/cart`](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/cart) (Cart API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home and featured<br/>[page.tsx]"]
  node_shop["Product discovery<br/>[page.tsx]"]
  node_productcard["Product cards<br/>[ProductCard.tsx]"]
  node_productdetail["Product detail<br/>[page.tsx]"]
  node_catalogapi["Catalog API<br/>[route.ts]"]
  node_productapi["Product API<br/>[route.tsx]"]
end

subgraph group_customer["Customer account"]
  node_authui["Login and signup"]
  node_profile["Profile management"]
  node_addresses["Address management"]
  node_addressapi["Address API"]
end

subgraph group_commerce["Cart and orders"]
  node_cartui["Cart page<br/>[page.tsx]"]
  node_cartbutton["Cart indicator<br/>[CartButton.tsx]"]
  node_cartcontext["Cart state<br/>[CartContext.tsx]"]
  node_cartapi["Cart API"]
  node_cartdata["Cart calculations<br/>[getCartData.ts]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_paymentapi["Order placement<br/>[route.ts]"]
  node_orders["Customer orders<br/>[page.tsx]"]
end

subgraph group_admin["Administration"]
  node_adminui["Admin workspace"]
  node_adminproducts["Product management"]
  node_admincategories["Category management"]
  node_adminorders["Order management"]
  node_adminusers["User management"]
  node_adminapi["Admin APIs"]
end

subgraph group_platform["Shared services"]
  node_authlib["Session authentication<br/>[auth.ts]"]
  node_proxy["Route access checks<br/>[proxy.ts]"]
  node_db[("Application database<br/>[prisma.ts]")]
  node_fetch["HTTP client helper<br/>[fetchApi.ts]"]
  node_modal["Feedback modal<br/>[ModalContext.tsx]"]
  node_images["Image upload<br/>[uploadImage.ts]"]
end

node_shopper(("Shopper"))
node_cloudinary["Cloudinary"]

node_shopper -->|"visits"| node_home
node_shopper -->|"browses"| node_shop
node_home -->|"renders"| node_productcard
node_shop -->|"renders"| node_productcard
node_shop -->|"loads products"| node_catalogapi
node_shopper -->|"opens product"| node_productdetail
node_productdetail -->|"loads product"| node_productapi
node_productcard -->|"updates count"| node_cartcontext
node_productcard -->|"sends cart request"| node_fetch
node_productcard -->|"shows feedback"| node_modal
node_fetch -.->|"requests cart"| node_cartapi
node_shopper -->|"signs in"| node_authui
node_proxy -->|"checks session"| node_authlib
node_addressapi -->|"checks user"| node_authlib
node_addressapi -->|"reads and writes"| node_db
node_shopper -->|"reviews cart"| node_cartui
node_cartbutton -->|"reads count"| node_cartcontext
node_cartui -->|"requests data"| node_fetch
node_checkout -->|"requests data"| node_fetch
node_cartapi -->|"checks user"| node_authlib
node_cartapi -->|"loads cart"| node_cartdata
node_cartapi -->|"reads and writes"| node_db
node_cartdata -->|"reads cart"| node_db
node_paymentapi -->|"checks user"| node_authlib
node_paymentapi -->|"loads cart"| node_cartdata
node_paymentapi -->|"creates order"| node_db
node_adminapi -.->|"manages records"| node_db
node_adminproducts -.->|"uploads images"| node_images
node_images -.->|"stores images"| node_cloudinary
node_adminui -.->|"manages catalog"| node_adminproducts
node_adminui -.->|"manages categories"| node_admincategories
node_adminui -.->|"manages orders"| node_adminorders
node_adminui -.->|"manages users"| node_adminusers

click node_home "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/page.tsx"
click node_shop "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/shop/page.tsx"
click node_productcard "https://github.com/thakur2sahil/e-commerce/blob/main/src/_component/ProductCard.tsx"
click node_productdetail "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/products/%5Bid%5D/page.tsx"
click node_catalogapi "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/api/shop/route.ts"
click node_productapi "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/api/products/%5Bid%5D/route.tsx"
click node_authui "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/(auth)"
click node_authlib "https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/auth.ts"
click node_proxy "https://github.com/thakur2sahil/e-commerce/blob/main/src/proxy.ts"
click node_profile "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/(user)/(protected)/profile"
click node_addresses "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/(user)/(protected)/profile/addresses"
click node_addressapi "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/address"
click node_cartui "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/(protected)/cart/page.tsx"
click node_cartbutton "https://github.com/thakur2sahil/e-commerce/blob/main/src/_component/CartButton.tsx"
click node_cartcontext "https://github.com/thakur2sahil/e-commerce/blob/main/src/_context/CartContext.tsx"
click node_cartapi "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/cart"
click node_cartdata "https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/getCartData.ts"
click node_checkout "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/(protected)/checkout/page.tsx"
click node_paymentapi "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/api/payment/route.ts"
click node_orders "https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/(protected)/orders/page.tsx"
click node_adminui "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin"
click node_adminproducts "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/products"
click node_admincategories "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/categories"
click node_adminorders "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/orders"
click node_adminusers "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/users"
click node_adminapi "https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/admin"
click node_db "https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/prisma.ts"
click node_fetch "https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/fetchApi.ts"
click node_modal "https://github.com/thakur2sahil/e-commerce/blob/main/src/_context/ModalContext.tsx"
click node_images "https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/uploadImage.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_home,node_shop,node_productcard,node_productdetail,node_catalogapi,node_productapi toneBlue
class node_authui,node_profile,node_addresses,node_addressapi toneAmber
class node_cartui,node_cartbutton,node_cartcontext,node_cartapi,node_cartdata,node_checkout,node_paymentapi,node_orders toneMint
class node_adminui,node_adminproducts,node_admincategories,node_adminorders,node_adminusers,node_adminapi toneRose
class node_authlib,node_proxy,node_db,node_fetch,node_modal,node_images,node_shopper,node_cloudinary toneIndigo
```

## Components

### Storefront

- [Home and featured](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Product discovery](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/shop/page.tsx): `src/app/(user)/shop/page.tsx`
- [Product cards](https://github.com/thakur2sahil/e-commerce/blob/main/src/_component/ProductCard.tsx): `src/_component/ProductCard.tsx`
- [Product detail](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/products/%5Bid%5D/page.tsx): `src/app/(user)/products/[id]/page.tsx`
- [Catalog API](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/api/shop/route.ts): `src/app/api/shop/route.ts`
- [Product API](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/api/products/%5Bid%5D/route.tsx): `src/app/api/products/[id]/route.tsx`

### Customer account

- [Login and signup](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/(auth)): `src/app/(auth)`
- [Profile management](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/(user)/(protected)/profile): `src/app/(user)/(protected)/profile`
- [Address management](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/(user)/(protected)/profile/addresses): `src/app/(user)/(protected)/profile/addresses`
- [Address API](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/address): `src/app/api/address`

### Cart and orders

- [Cart page](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/(protected)/cart/page.tsx): `src/app/(user)/(protected)/cart/page.tsx`
- [Cart indicator](https://github.com/thakur2sahil/e-commerce/blob/main/src/_component/CartButton.tsx): `src/_component/CartButton.tsx`
- [Cart state](https://github.com/thakur2sahil/e-commerce/blob/main/src/_context/CartContext.tsx): `src/_context/CartContext.tsx`
- [Cart API](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/cart): `src/app/api/cart`
- [Cart calculations](https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/getCartData.ts): `src/_lib/getCartData.ts`
- [Checkout](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/(protected)/checkout/page.tsx): `src/app/(user)/(protected)/checkout/page.tsx`
- [Order placement](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/api/payment/route.ts): `src/app/api/payment/route.ts`
- [Customer orders](https://github.com/thakur2sahil/e-commerce/blob/main/src/app/(user)/(protected)/orders/page.tsx): `src/app/(user)/(protected)/orders/page.tsx`

### Administration

- [Admin workspace](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin): `src/app/admin`
- [Product management](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/products): `src/app/admin/products`
- [Category management](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/categories): `src/app/admin/categories`
- [Order management](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/orders): `src/app/admin/orders`
- [User management](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/admin/users): `src/app/admin/users`
- [Admin APIs](https://github.com/thakur2sahil/e-commerce/tree/main/src/app/api/admin): `src/app/api/admin`

### Shared services

- [Session authentication](https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/auth.ts): `src/_lib/auth.ts`
- [Route access checks](https://github.com/thakur2sahil/e-commerce/blob/main/src/proxy.ts): `src/proxy.ts`
- [Application database](https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/prisma.ts): `src/_lib/prisma.ts`
- [HTTP client helper](https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/fetchApi.ts): `src/_lib/fetchApi.ts`
- [Feedback modal](https://github.com/thakur2sahil/e-commerce/blob/main/src/_context/ModalContext.tsx): `src/_context/ModalContext.tsx`
- [Image upload](https://github.com/thakur2sahil/e-commerce/blob/main/src/_lib/uploadImage.ts): `src/_lib/uploadImage.ts`

### Other components

- **Shopper**
- **Cloudinary**

## Connections

- Shopper → Home and featured: visits (evidence: `src/app/page.tsx`)
- Shopper → Product discovery: browses (evidence: `src/app/(user)/shop/page.tsx`)
- Home and featured → Product cards: renders (evidence: `src/app/page.tsx`)
- Product discovery → Product cards: renders (evidence: `src/app/(user)/shop/page.tsx`)
- Product discovery → Catalog API: loads products (evidence: `src/app/api/shop/route.ts`)
- Shopper → Product detail: opens product
- Product detail → Product API: loads product (evidence: `src/app/api/products/[id]/route.tsx`)
- Product cards → Cart state: updates count (evidence: `src/_component/ProductCard.tsx`)
- Product cards → HTTP client helper: sends cart request (evidence: `src/_component/ProductCard.tsx`)
- Product cards → Feedback modal: shows feedback (evidence: `src/_component/ProductCard.tsx`)
- HTTP client helper → Cart API: requests cart
- Shopper → Login and signup: signs in
- Route access checks → Session authentication: checks session (evidence: `src/proxy.ts`)
- Address API → Session authentication: checks user (evidence: `src/app/api/address/[id]/route.ts`)
- Address API → Application database: reads and writes (evidence: `src/app/api/address/[id]/route.ts`)
- Shopper → Cart page: reviews cart (evidence: `src/app/(user)/(protected)/cart/page.tsx`)
- Cart indicator → Cart state: reads count (evidence: `src/_component/CartButton.tsx`)
- Cart page → HTTP client helper: requests data (evidence: `src/app/(user)/(protected)/cart/page.tsx`)
- Checkout → HTTP client helper: requests data (evidence: `src/app/(user)/(protected)/checkout/page.tsx`)
- Cart API → Session authentication: checks user (evidence: `src/app/api/cart/route.tsx`)
- Cart API → Cart calculations: loads cart (evidence: `src/app/api/cart/route.tsx`)
- Cart API → Application database: reads and writes (evidence: `src/app/api/cart/route.tsx`)
- Cart calculations → Application database: reads cart (evidence: `src/_lib/getCartData.ts`)
- Order placement → Session authentication: checks user (evidence: `src/app/api/payment/route.ts`)
- Order placement → Cart calculations: loads cart (evidence: `src/app/api/payment/route.ts`)
- Order placement → Application database: creates order (evidence: `src/app/api/payment/route.ts`)
- Admin APIs → Application database: manages records (evidence: `src/app/api/admin/orders/[id]/route.ts`)
- Product management → Image upload: uploads images
- Image upload → Cloudinary: stores images
- Admin workspace → Product management: manages catalog
- Admin workspace → Category management: manages categories
- Admin workspace → Order management: manages orders
- Admin workspace → User management: manages users
