# satvikpraveen/nextjs-ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/satvikpraveen/nextjs-ecommerce
- Repository: https://github.com/satvikpraveen/nextjs-ecommerce

## Overview

This is a Next.js storefront and admin application. Customers discover and filter products, add items to a persistent cart, check out through Stripe, and view their orders; administrators manage products, inventory, and orders. The internal server layer separates product/order queries from cart, checkout, and order actions, with Prisma as the database access point. The graph uses README capabilities and the supplied source index; unsampled routes and integrations are included only where documented or their references are indexed.

Main entry points: [`server/actions/checkout.ts`](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/actions/checkout.ts) (Checkout actions), [`server/queries/products.ts`](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/queries/products.ts) (Product queries), [`server/queries/orders.ts`](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/queries/orders.ts) (Order history), [`lib/prisma.ts`](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/lib/prisma.ts) (PostgreSQL via Prisma)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home page<br/>[page.tsx]"]
  node_catalog["Catalog and search<br/>[page.tsx]"]
  node_product_detail["Product detail<br/>[page.tsx]"]
  node_product_ui["Product cards and grid<br/>[product-grid.tsx]"]
  node_cart_ui["Cart experience<br/>[page.tsx]"]
  node_order_pages["Account orders<br/>[page.tsx]"]
  node_newsletter["Newsletter subscription<br/>[route.ts]"]
end

subgraph group_commerce["Commerce"]
  node_product_queries["Product queries<br/>[products.ts]"]
  node_cart_actions["Cart actions<br/>[cart.ts]"]
  node_checkout["Checkout<br/>[checkout-form.tsx]"]
  node_checkout_actions["Checkout actions<br/>[checkout.ts]"]
  node_stripe_api["Stripe routes<br/>[route.ts]"]
  node_orders["Order history<br/>[orders.ts]"]
  node_database[("PostgreSQL via Prisma<br/>[prisma.ts]")]
end

subgraph group_identity["Identity"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_auth_routes["Auth routes<br/>[route.ts]"]
end

subgraph group_operations["Admin operations"]
  node_admin["Admin dashboard<br/>[page.tsx]"]
  node_inventory["Inventory management<br/>[page.tsx]"]
  node_admin_orders["Order management<br/>[page.tsx]"]
end

node_shopper(("Shopper"))
node_stripe["Stripe"]

node_shopper -->|"browses"| node_home
node_home -->|"loads featured items"| node_product_queries
node_home -->|"renders products"| node_product_ui
node_catalog -->|"queries catalog"| node_product_queries
node_catalog -->|"renders results"| node_product_ui
node_product_detail -->|"loads product"| node_product_queries
node_product_ui -.->|"adds products"| node_cart_ui
node_shopper -->|"manages cart"| node_cart_ui
node_cart_ui -->|"updates cart"| node_cart_actions
node_shopper -->|"checks out"| node_checkout
node_checkout -.->|"submits checkout"| node_checkout_actions
node_checkout_actions -->|"creates payment session"| node_stripe
node_stripe_api -->|"dispatches checkout"| node_checkout_actions
node_checkout_actions -->|"uses cart actions"| node_cart_actions
node_checkout_actions -.->|"fulfills purchase"| node_orders
node_order_pages -->|"loads order history"| node_orders
node_auth_routes -.->|"configures authentication"| node_auth
node_auth -->|"reads and writes users"| node_database
node_admin -->|"loads products"| node_product_queries
node_inventory -->|"loads inventory"| node_inventory
node_admin_orders -->|"loads orders"| node_orders
node_shopper -->|"subscribes"| node_newsletter
node_product_queries -->|"queries products"| node_database
node_orders -->|"queries orders"| node_database
node_newsletter -->|"persists subscription"| node_database

click node_home "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/page.tsx"
click node_catalog "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(store)/products/page.tsx"
click node_product_detail "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(store)/products/%5Bslug%5D/page.tsx"
click node_product_ui "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/components/product-grid.tsx"
click node_product_queries "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/queries/products.ts"
click node_cart_ui "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(store)/cart/page.tsx"
click node_cart_actions "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/actions/cart.ts"
click node_checkout "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/components/checkout/checkout-form.tsx"
click node_checkout_actions "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/actions/checkout.ts"
click node_stripe_api "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/api/stripe/create-checkout/route.ts"
click node_orders "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/queries/orders.ts"
click node_order_pages "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(account)/orders/page.tsx"
click node_auth "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/lib/auth.ts"
click node_auth_routes "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/api/auth/%5B...nextauth%5D/route.ts"
click node_admin "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/admin/products/page.tsx"
click node_inventory "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/admin/inventory/page.tsx"
click node_admin_orders "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/admin/orders/page.tsx"
click node_newsletter "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/api/newsletter/route.ts"
click node_database "https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/lib/prisma.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_catalog,node_product_detail,node_product_ui,node_cart_ui,node_order_pages,node_newsletter toneBlue
class node_product_queries,node_cart_actions,node_checkout,node_checkout_actions,node_stripe_api,node_orders,node_database toneAmber
class node_auth,node_auth_routes toneMint
class node_admin,node_inventory,node_admin_orders toneRose
class node_shopper,node_stripe toneIndigo
```

## Components

### Storefront

- [Home page](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/page.tsx): `app/page.tsx`
- [Catalog and search](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(store)/products/page.tsx): `app/(store)/products/page.tsx`
- [Product detail](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(store)/products/%5Bslug%5D/page.tsx): `app/(store)/products/[slug]/page.tsx`
- [Product cards and grid](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/components/product-grid.tsx): `components/product-grid.tsx`
- [Cart experience](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(store)/cart/page.tsx): `app/(store)/cart/page.tsx`
- [Account orders](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/(account)/orders/page.tsx): `app/(account)/orders/page.tsx`
- [Newsletter subscription](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/api/newsletter/route.ts): `app/api/newsletter/route.ts`

### Commerce

- [Product queries](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/queries/products.ts): `server/queries/products.ts`
- [Cart actions](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/actions/cart.ts): `server/actions/cart.ts`
- [Checkout](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/components/checkout/checkout-form.tsx): `components/checkout/checkout-form.tsx`
- [Checkout actions](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/actions/checkout.ts): `server/actions/checkout.ts`
- [Stripe routes](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/api/stripe/create-checkout/route.ts): `app/api/stripe/create-checkout/route.ts`
- [Order history](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/server/queries/orders.ts): `server/queries/orders.ts`
- [PostgreSQL via Prisma](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/lib/prisma.ts): `lib/prisma.ts`

### Identity

- [Authentication](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/lib/auth.ts): `lib/auth.ts`
- [Auth routes](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/api/auth/%5B...nextauth%5D/route.ts): `app/api/auth/[...nextauth]/route.ts`

### Admin operations

- [Admin dashboard](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/admin/products/page.tsx): `app/admin/products/page.tsx`
- [Inventory management](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/admin/inventory/page.tsx): `app/admin/inventory/page.tsx`
- [Order management](https://github.com/satvikpraveen/nextjs-ecommerce/blob/main/app/admin/orders/page.tsx): `app/admin/orders/page.tsx`

### Other components

- **Shopper**
- **Stripe**

## Connections

- Shopper → Home page: browses
- Home page → Product queries: loads featured items (evidence: `app/page.tsx`)
- Home page → Product cards and grid: renders products (evidence: `app/page.tsx`)
- Catalog and search → Product queries: queries catalog (evidence: `app/(store)/products/page.tsx`)
- Catalog and search → Product cards and grid: renders results (evidence: `app/(store)/products/page.tsx`)
- Product detail → Product queries: loads product (evidence: `app/(store)/products/[slug]/page.tsx`)
- Product cards and grid → Cart experience: adds products
- Shopper → Cart experience: manages cart
- Cart experience → Cart actions: updates cart (evidence: `app/(store)/cart/page.tsx`)
- Shopper → Checkout: checks out
- Checkout → Checkout actions: submits checkout
- Checkout actions → Stripe: creates payment session (evidence: `server/actions/checkout.ts`)
- Stripe routes → Checkout actions: dispatches checkout (evidence: `app/api/stripe/create-checkout/route.ts`)
- Checkout actions → Cart actions: uses cart actions (evidence: `server/actions/checkout.ts`)
- Checkout actions → Order history: fulfills purchase
- Account orders → Order history: loads order history (evidence: `app/(account)/orders/page.tsx`)
- Auth routes → Authentication: configures authentication
- Authentication → PostgreSQL via Prisma: reads and writes users (evidence: `lib/auth.ts`)
- Admin dashboard → Product queries: loads products (evidence: `app/admin/products/page.tsx`)
- Inventory management → Inventory management: loads inventory (evidence: `app/admin/inventory/page.tsx`)
- Order management → Order history: loads orders (evidence: `app/admin/orders/page.tsx`)
- Shopper → Newsletter subscription: subscribes
- Product queries → PostgreSQL via Prisma: queries products (evidence: `server/queries/products.ts`)
- Order history → PostgreSQL via Prisma: queries orders (evidence: `server/queries/orders.ts`)
- Newsletter subscription → PostgreSQL via Prisma: persists subscription (evidence: `app/api/newsletter/route.ts`)
