# caoh29/petshop architecture

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

- Interactive diagram: https://gitdiagram.com/caoh29/petshop
- Repository: https://github.com/caoh29/petshop

## Overview

PetShop is a Next.js ecommerce application for pet supplies. Shoppers browse and search products, manage a cart, provide delivery and payment details, and view orders; administrators manage products, orders, and users. The code map also includes authentication, reviews, Stripe payment callbacks, and scheduled order/stock maintenance. The index documents the action-module exports and sampled pages identify some component calls. Most action implementations and route pages were not sampled, so their internal calls and storage behavior are not asserted.

Main entry points: [`src/app/api/actions/index.ts`](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/index.ts) (Action Exports), [`prisma/db.ts`](https://github.com/caoh29/petshop/blob/main/prisma/db.ts) (Prisma Client), [`src/app/(shop)/[category]/page.tsx`](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/%5Bcategory%5D/page.tsx) (Catalog Pages), [`src/app/(shop)/search/page.tsx`](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/search/page.tsx) (Search Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Storefront"]
  node_catalog_pages["Catalog Pages<br/>[page.tsx]"]
  node_search_page["Search Page<br/>[page.tsx]"]
  node_home_page["Home Page<br/>[page.tsx]"]
  node_product_card["Product Card<br/>[ProductCard.tsx]"]
  node_product_grid["Product Grid<br/>[GridSection.tsx]"]
  node_product_filters["Product Filters<br/>[ProductFilters.tsx]"]
  node_product_sort["Product Sorting<br/>[SortDropdown.tsx]"]
  node_pagination["Pagination<br/>[Pagination.tsx]"]
  node_featured["Featured Products"]
  node_button["Button UI<br/>[button.tsx]"]
  node_checkbox["Checkbox UI<br/>[checkbox.tsx]"]
end

subgraph group_commerce["Cart &amp; Orders"]
  node_cart_page["Cart Page<br/>[page.tsx]"]
  node_checkout_page["Checkout Page<br/>[page.tsx]"]
  node_checkout_section["Checkout Form"]
  node_orders_pages["Order Pages<br/>[page.tsx]"]
  node_review_ui["Product Reviews<br/>[Reviews.tsx]"]
end

subgraph group_identity["Identity &amp; Admin"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_admin_pages["Admin Pages<br/>[page.tsx]"]
end

subgraph group_backend["Application Services"]
  node_action_hub["Action Exports<br/>[index.ts]"]
  node_product_actions["Product Actions<br/>[index.ts]"]
  node_cart_actions["Cart Actions<br/>[index.ts]"]
  node_checkout_actions["Checkout Actions<br/>[index.ts]"]
  node_order_actions["Order Actions<br/>[index.ts]"]
  node_admin_actions["Admin Actions<br/>[index.ts]"]
  node_review_actions["Review Actions<br/>[index.ts]"]
  node_payment_webhook["Payment Webhook<br/>[route.ts]"]
  node_order_cron["Order Maintenance<br/>[route.ts]"]
  node_reserve_cron["Stock Reserve Release<br/>[route.ts]"]
end

subgraph group_state["State &amp; Persistence"]
  node_redux_store["Redux Store<br/>[store.ts]"]
  node_cart_slice["Cart State<br/>[index.ts]"]
  node_db_client["Prisma Client<br/>[db.ts]"]
  node_database[("PostgreSQL")]
end

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

node_shopper -->|"browses"| node_home_page
node_catalog_pages -->|"renders"| node_product_filters
node_catalog_pages -->|"renders"| node_product_sort
node_catalog_pages -->|"renders"| node_product_grid
node_catalog_pages -->|"renders"| node_pagination
node_search_page -->|"renders"| node_product_filters
node_search_page -->|"renders"| node_product_sort
node_search_page -->|"renders"| node_product_grid
node_search_page -->|"renders"| node_pagination
node_product_grid -->|"renders"| node_product_card
node_home_page -->|"renders"| node_featured
node_featured -->|"renders"| node_product_card
node_checkout_page -->|"renders"| node_checkout_section
node_checkout_page -->|"loads user data"| node_action_hub
node_orders_pages -->|"renders"| node_pagination
node_auth -->|"uses"| node_db_client
node_auth -->|"accesses"| node_database
node_action_hub -->|"exports"| node_product_actions
node_action_hub -->|"exports"| node_cart_actions
node_action_hub -->|"exports"| node_checkout_actions
node_action_hub -->|"exports"| node_order_actions
node_action_hub -->|"exports"| node_admin_actions
node_action_hub -->|"exports"| node_review_actions
node_redux_store -->|"registers"| node_cart_slice
node_checkout_section -->|"uses state"| node_redux_store
node_checkout_page -.->|"invokes via exports"| node_cart_actions
node_checkout_page -.->|"invokes via exports"| node_checkout_actions
node_payment_webhook -->|"uses"| node_db_client
node_order_cron -->|"uses"| node_db_client
node_reserve_cron -->|"uses"| node_db_client
node_db_client -.->|"connects"| node_database
node_payment_webhook -.->|"handles payment events"| node_stripe
node_checkout_section -.->|"processes payment"| node_stripe
node_product_filters -->|"uses"| node_checkbox
node_product_sort -->|"uses"| node_button

click node_catalog_pages "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/%5Bcategory%5D/page.tsx"
click node_search_page "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/search/page.tsx"
click node_home_page "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/page.tsx"
click node_product_card "https://github.com/caoh29/petshop/blob/main/src/app/components/ProductCard.tsx"
click node_product_grid "https://github.com/caoh29/petshop/blob/main/src/app/components/GridSection.tsx"
click node_product_filters "https://github.com/caoh29/petshop/blob/main/src/app/components/ProductFilters.tsx"
click node_product_sort "https://github.com/caoh29/petshop/blob/main/src/app/components/SortDropdown.tsx"
click node_pagination "https://github.com/caoh29/petshop/blob/main/src/app/components/Pagination.tsx"
click node_featured "https://github.com/caoh29/petshop/blob/main/src/app/components/FeaturedProductsSection.tsx"
click node_cart_page "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/cart/page.tsx"
click node_checkout_page "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/checkout/page.tsx"
click node_checkout_section "https://github.com/caoh29/petshop/blob/main/src/app/components/CheckoutSection.tsx"
click node_orders_pages "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/orders/page.tsx"
click node_review_ui "https://github.com/caoh29/petshop/blob/main/src/app/components/Reviews.tsx"
click node_auth "https://github.com/caoh29/petshop/blob/main/src/auth.ts"
click node_admin_pages "https://github.com/caoh29/petshop/blob/main/src/app/(shop)/admin/page.tsx"
click node_action_hub "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/index.ts"
click node_product_actions "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/products/index.ts"
click node_cart_actions "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/cart/index.ts"
click node_checkout_actions "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/checkout/index.ts"
click node_order_actions "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/orders/index.ts"
click node_admin_actions "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/admin/index.ts"
click node_review_actions "https://github.com/caoh29/petshop/blob/main/src/app/api/actions/reviews/index.ts"
click node_payment_webhook "https://github.com/caoh29/petshop/blob/main/src/app/api/webhooks/payments/route.ts"
click node_order_cron "https://github.com/caoh29/petshop/blob/main/src/app/api/cron/cancel-pending-orders/route.ts"
click node_reserve_cron "https://github.com/caoh29/petshop/blob/main/src/app/api/cron/release-reserves/route.ts"
click node_redux_store "https://github.com/caoh29/petshop/blob/main/src/store/store.ts"
click node_cart_slice "https://github.com/caoh29/petshop/blob/main/src/store/slices/cart/index.ts"
click node_db_client "https://github.com/caoh29/petshop/blob/main/prisma/db.ts"
click node_button "https://github.com/caoh29/petshop/blob/main/src/app/components/ui/button.tsx"
click node_checkbox "https://github.com/caoh29/petshop/blob/main/src/app/components/ui/checkbox.tsx"

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_pages,node_search_page,node_home_page,node_product_card,node_product_grid,node_product_filters,node_product_sort,node_pagination,node_featured,node_button,node_checkbox toneBlue
class node_cart_page,node_checkout_page,node_checkout_section,node_orders_pages,node_review_ui toneAmber
class node_auth,node_admin_pages toneMint
class node_action_hub,node_product_actions,node_cart_actions,node_checkout_actions,node_order_actions,node_admin_actions,node_review_actions,node_payment_webhook,node_order_cron,node_reserve_cron toneRose
class node_redux_store,node_cart_slice,node_db_client,node_database,node_shopper,node_stripe toneIndigo
```

## Components

### Storefront

- [Catalog Pages](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/%5Bcategory%5D/page.tsx): `src/app/(shop)/[category]/page.tsx`
- [Search Page](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/search/page.tsx): `src/app/(shop)/search/page.tsx`
- [Home Page](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/page.tsx): `src/app/(shop)/page.tsx`
- [Product Card](https://github.com/caoh29/petshop/blob/main/src/app/components/ProductCard.tsx): `src/app/components/ProductCard.tsx`
- [Product Grid](https://github.com/caoh29/petshop/blob/main/src/app/components/GridSection.tsx): `src/app/components/GridSection.tsx`
- [Product Filters](https://github.com/caoh29/petshop/blob/main/src/app/components/ProductFilters.tsx): `src/app/components/ProductFilters.tsx`
- [Product Sorting](https://github.com/caoh29/petshop/blob/main/src/app/components/SortDropdown.tsx): `src/app/components/SortDropdown.tsx`
- [Pagination](https://github.com/caoh29/petshop/blob/main/src/app/components/Pagination.tsx): `src/app/components/Pagination.tsx`
- [Featured Products](https://github.com/caoh29/petshop/blob/main/src/app/components/FeaturedProductsSection.tsx): `src/app/components/FeaturedProductsSection.tsx`
- [Button UI](https://github.com/caoh29/petshop/blob/main/src/app/components/ui/button.tsx): `src/app/components/ui/button.tsx`
- [Checkbox UI](https://github.com/caoh29/petshop/blob/main/src/app/components/ui/checkbox.tsx): `src/app/components/ui/checkbox.tsx`

### Cart & Orders

- [Cart Page](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/cart/page.tsx): `src/app/(shop)/cart/page.tsx`
- [Checkout Page](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/checkout/page.tsx): `src/app/(shop)/checkout/page.tsx`
- [Checkout Form](https://github.com/caoh29/petshop/blob/main/src/app/components/CheckoutSection.tsx): `src/app/components/CheckoutSection.tsx`
- [Order Pages](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/orders/page.tsx): `src/app/(shop)/orders/page.tsx`
- [Product Reviews](https://github.com/caoh29/petshop/blob/main/src/app/components/Reviews.tsx): `src/app/components/Reviews.tsx`

### Identity & Admin

- [Authentication](https://github.com/caoh29/petshop/blob/main/src/auth.ts): `src/auth.ts`
- [Admin Pages](https://github.com/caoh29/petshop/blob/main/src/app/(shop)/admin/page.tsx): `src/app/(shop)/admin/page.tsx`

### Application Services

- [Action Exports](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/index.ts): `src/app/api/actions/index.ts`
- [Product Actions](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/products/index.ts): `src/app/api/actions/products/index.ts`
- [Cart Actions](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/cart/index.ts): `src/app/api/actions/cart/index.ts`
- [Checkout Actions](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/checkout/index.ts): `src/app/api/actions/checkout/index.ts`
- [Order Actions](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/orders/index.ts): `src/app/api/actions/orders/index.ts`
- [Admin Actions](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/admin/index.ts): `src/app/api/actions/admin/index.ts`
- [Review Actions](https://github.com/caoh29/petshop/blob/main/src/app/api/actions/reviews/index.ts): `src/app/api/actions/reviews/index.ts`
- [Payment Webhook](https://github.com/caoh29/petshop/blob/main/src/app/api/webhooks/payments/route.ts): `src/app/api/webhooks/payments/route.ts`
- [Order Maintenance](https://github.com/caoh29/petshop/blob/main/src/app/api/cron/cancel-pending-orders/route.ts): `src/app/api/cron/cancel-pending-orders/route.ts`
- [Stock Reserve Release](https://github.com/caoh29/petshop/blob/main/src/app/api/cron/release-reserves/route.ts): `src/app/api/cron/release-reserves/route.ts`

### State & Persistence

- [Redux Store](https://github.com/caoh29/petshop/blob/main/src/store/store.ts): `src/store/store.ts`
- [Cart State](https://github.com/caoh29/petshop/blob/main/src/store/slices/cart/index.ts): `src/store/slices/cart/index.ts`
- [Prisma Client](https://github.com/caoh29/petshop/blob/main/prisma/db.ts): `prisma/db.ts`
- **PostgreSQL**

### Other components

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

## Connections

- Shopper → Home Page: browses (evidence: `README.md`)
- Catalog Pages → Product Filters: renders (evidence: `src/app/(shop)/[category]/page.tsx`)
- Catalog Pages → Product Sorting: renders (evidence: `src/app/(shop)/[category]/page.tsx`)
- Catalog Pages → Product Grid: renders (evidence: `src/app/(shop)/[category]/page.tsx`)
- Catalog Pages → Pagination: renders (evidence: `src/app/(shop)/[category]/page.tsx`)
- Search Page → Product Filters: renders (evidence: `src/app/(shop)/search/page.tsx`)
- Search Page → Product Sorting: renders (evidence: `src/app/(shop)/search/page.tsx`)
- Search Page → Product Grid: renders (evidence: `src/app/(shop)/search/page.tsx`)
- Search Page → Pagination: renders (evidence: `src/app/(shop)/search/page.tsx`)
- Product Grid → Product Card: renders (evidence: `src/app/components/GridSection.tsx`)
- Home Page → Featured Products: renders (evidence: `src/app/(shop)/page.tsx`)
- Featured Products → Product Card: renders (evidence: `src/app/components/FeaturedProductsSection.tsx`)
- Checkout Page → Checkout Form: renders (evidence: `src/app/(shop)/checkout/page.tsx`)
- Checkout Page → Action Exports: loads user data (evidence: `src/app/(shop)/checkout/page.tsx`)
- Order Pages → Pagination: renders (evidence: `src/app/(shop)/orders/page.tsx`)
- Authentication → Prisma Client: uses (evidence: `src/auth.ts`)
- Authentication → PostgreSQL: accesses (evidence: `README.md`)
- Action Exports → Product Actions: exports (evidence: `src/app/api/actions/index.ts`)
- Action Exports → Cart Actions: exports (evidence: `src/app/api/actions/index.ts`)
- Action Exports → Checkout Actions: exports (evidence: `src/app/api/actions/index.ts`)
- Action Exports → Order Actions: exports (evidence: `src/app/api/actions/index.ts`)
- Action Exports → Admin Actions: exports (evidence: `src/app/api/actions/index.ts`)
- Action Exports → Review Actions: exports (evidence: `src/app/api/actions/index.ts`)
- Redux Store → Cart State: registers (evidence: `src/store/store.ts`)
- Checkout Form → Redux Store: uses state (evidence: `src/app/components/CheckoutSection.tsx`)
- Checkout Page → Cart Actions: invokes via exports
- Checkout Page → Checkout Actions: invokes via exports
- Payment Webhook → Prisma Client: uses (evidence: `src/app/api/webhooks/payments/route.ts`)
- Order Maintenance → Prisma Client: uses (evidence: `src/app/api/cron/cancel-pending-orders/route.ts`)
- Stock Reserve Release → Prisma Client: uses (evidence: `src/app/api/cron/release-reserves/route.ts`)
- Prisma Client → PostgreSQL: connects
- Payment Webhook → Stripe: handles payment events
- Checkout Form → Stripe: processes payment (evidence: `README.md`)
- Product Filters → Checkbox UI: uses (evidence: `src/app/components/ProductFilters.tsx`)
- Product Sorting → Button UI: uses (evidence: `src/app/components/SortDropdown.tsx`)
