# dhyaa-km/ecommerce-website architecture

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

- Interactive diagram: https://gitdiagram.com/dhyaa-km/ecommerce-website
- Repository: https://github.com/dhyaa-km/ecommerce-website

## Overview

ShopNest is a full-stack storefront and admin platform. Customers browse and filter products, manage a cart, check out, and manage accounts and orders; administrators manage catalog data, users, and order status. The backend exposes feature-based API modules, with services using Prisma for persistence. The graph preserves documented capabilities, but some page-to-API and service-to-database links are not shown in the excerpts or reference index, so those connections are left out or marked unverified.

Main entry points: [`client/src/api/client.ts`](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/api/client.ts) (HTTP Client), [`server/src/app.ts`](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/app.ts) (API Application), [`client/src/router/index.tsx`](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/router/index.tsx) (Page Router), [`client/src/App.tsx`](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/App.tsx) (Client App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer and Admin UI"]
  node_app["Client App<br/>[App.tsx]"]
  node_router["Page Router<br/>[index.tsx]"]
  node_storefront["Storefront Pages<br/>[ProductsPage.tsx]"]
  node_cartcheckout["Cart and Checkout<br/>[CartPage.tsx]"]
  node_accountorders["Account and Orders<br/>[ProfilePage.tsx]"]
  node_adminui["Admin Pages"]
  node_authcontext["Auth State<br/>[AuthContext.tsx]"]
  node_cartcontext["Cart State<br/>[CartContext.tsx]"]
  node_apiclient["HTTP Client<br/>[client.ts]"]
end

subgraph group_api["Backend API"]
  node_appserver["API Application<br/>[app.ts]"]
  node_authmodule["Authentication<br/>[auth.service.ts]"]
  node_productmodule["Product Catalog<br/>[product.service.ts]"]
  node_categorymodule["Categories"]
  node_cartmodule["Cart Management<br/>[cart.service.ts]"]
  node_ordermodule["Order Management<br/>[order.service.ts]"]
  node_usermodule["User Management<br/>[user.service.ts]"]
end

subgraph group_security["Request Security"]
  node_authn["Authentication Middleware<br/>[auth.middleware.ts]"]
  node_authorization["Role Authorization<br/>[role.middleware.ts]"]
  node_validation["Request Validation<br/>[validate.ts]"]
end

subgraph group_data["Persistence"]
  node_database[("PostgreSQL via Prisma<br/>[prisma.ts]")]
end

node_shopper(("Shopper"))
node_administrator(("Administrator"))

node_shopper -->|"uses"| node_app
node_administrator -->|"uses"| node_app
node_app -->|"renders"| node_router
node_router -->|"routes to"| node_storefront
node_router -->|"routes to"| node_cartcheckout
node_router -->|"routes to"| node_accountorders
node_router -->|"routes to"| node_adminui
node_app -->|"provides"| node_authcontext
node_app -->|"provides"| node_cartcontext
node_authcontext -->|"informs"| node_cartcontext
node_authcontext -->|"uses"| node_apiclient
node_cartcontext -->|"uses"| node_apiclient
node_apiclient -.->|"sends bearer token"| node_authn
node_appserver -->|"mounts routes"| node_authmodule
node_appserver -->|"mounts routes"| node_productmodule
node_appserver -->|"mounts routes"| node_categorymodule
node_appserver -->|"mounts routes"| node_cartmodule
node_appserver -->|"mounts routes"| node_ordermodule
node_appserver -->|"mounts routes"| node_usermodule
node_authmodule -->|"persists sessions"| node_database
node_productmodule -->|"uses Prisma"| node_database
node_cartmodule -->|"uses Prisma"| node_database
node_ordermodule -->|"uses Prisma"| node_database
node_usermodule -->|"uses Prisma"| node_database
node_authn -->|"sets identity"| node_authorization
node_storefront -.->|"requests catalog"| node_apiclient
node_cartcheckout -.->|"requests cart and orders"| node_apiclient
node_accountorders -.->|"requests account data"| node_apiclient
node_adminui -.->|"requests admin actions"| node_apiclient

click node_app "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/App.tsx"
click node_router "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/router/index.tsx"
click node_storefront "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/ProductsPage.tsx"
click node_cartcheckout "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/CartPage.tsx"
click node_accountorders "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/ProfilePage.tsx"
click node_adminui "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/admin/AdminProductsPage.tsx"
click node_authcontext "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/context/AuthContext.tsx"
click node_cartcontext "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/context/CartContext.tsx"
click node_apiclient "https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/api/client.ts"
click node_appserver "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/app.ts"
click node_authmodule "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/auth/auth.service.ts"
click node_productmodule "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/products/product.service.ts"
click node_categorymodule "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/categories/category.service.ts"
click node_cartmodule "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/cart/cart.service.ts"
click node_ordermodule "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/orders/order.service.ts"
click node_usermodule "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/users/user.service.ts"
click node_authn "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/middleware/auth.middleware.ts"
click node_authorization "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/middleware/role.middleware.ts"
click node_validation "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/middleware/validate.ts"
click node_database "https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/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_app,node_router,node_storefront,node_cartcheckout,node_accountorders,node_adminui,node_authcontext,node_cartcontext,node_apiclient toneBlue
class node_appserver,node_authmodule,node_productmodule,node_categorymodule,node_cartmodule,node_ordermodule,node_usermodule toneAmber
class node_authn,node_authorization,node_validation toneMint
class node_database toneRose
class node_shopper,node_administrator toneIndigo
```

## Components

### Customer and Admin UI

- [Client App](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Page Router](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/router/index.tsx): `client/src/router/index.tsx`
- [Storefront Pages](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/ProductsPage.tsx): `client/src/pages/ProductsPage.tsx`
- [Cart and Checkout](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/CartPage.tsx): `client/src/pages/CartPage.tsx`
- [Account and Orders](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/ProfilePage.tsx): `client/src/pages/ProfilePage.tsx`
- [Admin Pages](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/pages/admin/AdminProductsPage.tsx): `client/src/pages/admin/AdminProductsPage.tsx`
- [Auth State](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/context/AuthContext.tsx): `client/src/context/AuthContext.tsx`
- [Cart State](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/context/CartContext.tsx): `client/src/context/CartContext.tsx`
- [HTTP Client](https://github.com/dhyaa-km/ecommerce-website/blob/main/client/src/api/client.ts): `client/src/api/client.ts`

### Backend API

- [API Application](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/auth/auth.service.ts): `server/src/modules/auth/auth.service.ts`
- [Product Catalog](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/products/product.service.ts): `server/src/modules/products/product.service.ts`
- [Categories](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/categories/category.service.ts): `server/src/modules/categories/category.service.ts`
- [Cart Management](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/cart/cart.service.ts): `server/src/modules/cart/cart.service.ts`
- [Order Management](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/orders/order.service.ts): `server/src/modules/orders/order.service.ts`
- [User Management](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/modules/users/user.service.ts): `server/src/modules/users/user.service.ts`

### Request Security

- [Authentication Middleware](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/middleware/auth.middleware.ts): `server/src/middleware/auth.middleware.ts`
- [Role Authorization](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/middleware/role.middleware.ts): `server/src/middleware/role.middleware.ts`
- [Request Validation](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/middleware/validate.ts): `server/src/middleware/validate.ts`

### Persistence

- [PostgreSQL via Prisma](https://github.com/dhyaa-km/ecommerce-website/blob/main/server/src/lib/prisma.ts): `server/src/lib/prisma.ts`

### Other components

- **Shopper**
- **Administrator**

## Connections

- Shopper → Client App: uses
- Administrator → Client App: uses
- Client App → Page Router: renders (evidence: `client/src/App.tsx`)
- Page Router → Storefront Pages: routes to (evidence: `client/src/router/index.tsx`)
- Page Router → Cart and Checkout: routes to (evidence: `client/src/router/index.tsx`)
- Page Router → Account and Orders: routes to (evidence: `client/src/router/index.tsx`)
- Page Router → Admin Pages: routes to (evidence: `client/src/router/index.tsx`)
- Client App → Auth State: provides (evidence: `client/src/App.tsx`)
- Client App → Cart State: provides (evidence: `client/src/App.tsx`)
- Auth State → Cart State: informs (evidence: `client/src/context/CartContext.tsx`)
- Auth State → HTTP Client: uses (evidence: `client/src/context/AuthContext.tsx`)
- Cart State → HTTP Client: uses (evidence: `client/src/context/CartContext.tsx`)
- HTTP Client → Authentication Middleware: sends bearer token
- API Application → Authentication: mounts routes (evidence: `server/src/app.ts`)
- API Application → Product Catalog: mounts routes (evidence: `server/src/app.ts`)
- API Application → Categories: mounts routes (evidence: `server/src/app.ts`)
- API Application → Cart Management: mounts routes (evidence: `server/src/app.ts`)
- API Application → Order Management: mounts routes (evidence: `server/src/app.ts`)
- API Application → User Management: mounts routes (evidence: `server/src/app.ts`)
- Authentication → PostgreSQL via Prisma: persists sessions (evidence: `server/src/modules/auth/auth.service.ts`)
- Product Catalog → PostgreSQL via Prisma: uses Prisma (evidence: `server/src/modules/products/product.service.ts`)
- Cart Management → PostgreSQL via Prisma: uses Prisma (evidence: `server/src/modules/cart/cart.service.ts`)
- Order Management → PostgreSQL via Prisma: uses Prisma (evidence: `server/src/modules/orders/order.service.ts`)
- User Management → PostgreSQL via Prisma: uses Prisma (evidence: `server/src/modules/users/user.service.ts`)
- Authentication Middleware → Role Authorization: sets identity (evidence: `server/src/middleware/role.middleware.ts`)
- Storefront Pages → HTTP Client: requests catalog
- Cart and Checkout → HTTP Client: requests cart and orders
- Account and Orders → HTTP Client: requests account data
- Admin Pages → HTTP Client: requests admin actions
