# soumardev/e-commerce-react architecture

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

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

## Overview

Kamera Shop is a learning-project storefront for browsing sample camera products, managing a browser-persisted cart, and registering or logging in; purchases and newsletter signup are not implemented. The main flow is shopper → routed React pages → PHP product API → MySQL catalogue, with product detail actions updating the cart. Separate account and optional product-aware chat branches are included. Edges reflect sampled calls or README-documented relationships; unsampled endpoint details are not inferred.

Main entry points: [`src/main.jsx`](https://github.com/soumardev/e-commerce-react/blob/main/src/main.jsx) (Page Router), [`src/api/products.js`](https://github.com/soumardev/e-commerce-react/blob/main/src/api/products.js) (Product API Client), [`src/pages/CartPage.jsx`](https://github.com/soumardev/e-commerce-react/blob/main/src/pages/CartPage.jsx) (Cart Page), [`api/db.php`](https://github.com/soumardev/e-commerce-react/blob/main/api/db.php) (Database Access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_router["Page Router<br/>[main.jsx]"]
  node_home["Home Page<br/>[HomePage.jsx]"]
  node_category["Category Page<br/>[CategoryPage.jsx]"]
  node_product["Product Page<br/>[ProductPage.jsx]"]
  node_notfound["Not Found<br/>[NotFound.jsx]"]
  node_header["Shop Header<br/>[Header.jsx]"]
  node_categories["Category Labels<br/>[categories.js]"]
  node_newsletter["Newsletter UI<br/>[Newsletter.jsx]"]
end

subgraph group_catalogue["Product Catalogue"]
  node_productapi["Product API Client<br/>[products.js]"]
  node_phpcatalogue["PHP Catalogue API<br/>[products.php]"]
  node_productendpoint["Product Endpoint<br/>[product.php]"]
  node_categoryendpoint["Category Endpoint<br/>[category.php]"]
  node_db["Database Access<br/>[db.php]"]
  node_mysql[("Product Database")]
end

subgraph group_cart["Cart"]
  node_cartstate["Cart State<br/>[CartContext.jsx]"]
  node_cartpage["Cart Page<br/>[CartPage.jsx]"]
  node_cartitem["Cart Item<br/>[CartItem.jsx]"]
  node_cartsummary["Cart Summary<br/>[CartSummary.jsx]"]
end

subgraph group_accounts["Accounts"]
  node_authprovider["Auth Provider<br/>[AuthProvider.jsx]"]
  node_authclient["Auth API Client<br/>[auth.js]"]
  node_authendpoints["PHP Auth Endpoints<br/>[login.php]"]
end

subgraph group_chat["Product Chat"]
  node_chatwidget["Chat Widget<br/>[ChatWidget.jsx]"]
  node_chatclient["Chat API Client<br/>[chat.js]"]
  node_chatendpoint["Chat Endpoint<br/>[chat.php]"]
end

node_shopper(("Shopper"))
node_claude{{"Anthropic Claude"}}

node_shopper -->|"visits pages"| node_router
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_category
node_router -->|"routes to"| node_product
node_router -->|"routes to"| node_cartpage
node_router -->|"routes to"| node_notfound
node_home -->|"labels categories"| node_categories
node_category -->|"labels categories"| node_categories
node_home -.->|"loads products"| node_productapi
node_category -->|"loads category"| node_productapi
node_product -->|"loads product"| node_productapi
node_productapi -->|"fetches product"| node_productendpoint
node_productapi -->|"fetches category"| node_categoryendpoint
node_productapi -->|"fetches all"| node_phpcatalogue
node_productendpoint -.->|"queries data"| node_db
node_categoryendpoint -.->|"queries data"| node_db
node_phpcatalogue -.->|"queries data"| node_db
node_db -.->|"reads catalogue"| node_mysql
node_product -->|"adds item"| node_cartstate
node_cartstate -.->|"provides cart"| node_cartpage
node_cartpage -->|"renders items"| node_cartitem
node_cartpage -->|"renders summary"| node_cartsummary
node_cartpage -->|"loads product data"| node_productapi
node_shopper -.->|"uses navigation"| node_header
node_header -->|"reads cart"| node_cartstate
node_header -.->|"uses auth"| node_authprovider
node_router -->|"wraps routes"| node_authprovider
node_authprovider -->|"calls auth API"| node_authclient
node_authclient -.->|"sends requests"| node_authendpoints
node_shopper -.->|"asks questions"| node_chatwidget
node_chatwidget -->|"sends conversation"| node_chatclient
node_chatclient -.->|"posts messages"| node_chatendpoint
node_chatendpoint -->|"loads product context"| node_db
node_chatendpoint -->|"requests answer"| node_claude
node_chatendpoint -.->|"returns answer"| node_shopper
node_category -->|"shows for invalid"| node_notfound
node_product -->|"shows for missing"| node_notfound
node_router -.->|"pages render"| node_newsletter

click node_router "https://github.com/soumardev/e-commerce-react/blob/main/src/main.jsx"
click node_home "https://github.com/soumardev/e-commerce-react/blob/main/src/pages/HomePage.jsx"
click node_category "https://github.com/soumardev/e-commerce-react/blob/main/src/pages/CategoryPage.jsx"
click node_product "https://github.com/soumardev/e-commerce-react/blob/main/src/pages/ProductPage.jsx"
click node_notfound "https://github.com/soumardev/e-commerce-react/blob/main/src/pages/NotFound.jsx"
click node_header "https://github.com/soumardev/e-commerce-react/blob/main/src/components/Header.jsx"
click node_categories "https://github.com/soumardev/e-commerce-react/blob/main/src/data/categories.js"
click node_productapi "https://github.com/soumardev/e-commerce-react/blob/main/src/api/products.js"
click node_phpcatalogue "https://github.com/soumardev/e-commerce-react/blob/main/api/products.php"
click node_productendpoint "https://github.com/soumardev/e-commerce-react/blob/main/api/product.php"
click node_categoryendpoint "https://github.com/soumardev/e-commerce-react/blob/main/api/category.php"
click node_db "https://github.com/soumardev/e-commerce-react/blob/main/api/db.php"
click node_cartstate "https://github.com/soumardev/e-commerce-react/blob/main/src/context/CartContext.jsx"
click node_cartpage "https://github.com/soumardev/e-commerce-react/blob/main/src/pages/CartPage.jsx"
click node_cartitem "https://github.com/soumardev/e-commerce-react/blob/main/src/components/cart/CartItem.jsx"
click node_cartsummary "https://github.com/soumardev/e-commerce-react/blob/main/src/components/cart/CartSummary.jsx"
click node_authprovider "https://github.com/soumardev/e-commerce-react/blob/main/src/context/AuthProvider.jsx"
click node_authclient "https://github.com/soumardev/e-commerce-react/blob/main/src/api/auth.js"
click node_authendpoints "https://github.com/soumardev/e-commerce-react/blob/main/api/login.php"
click node_chatwidget "https://github.com/soumardev/e-commerce-react/blob/main/src/components/chat/ChatWidget.jsx"
click node_chatclient "https://github.com/soumardev/e-commerce-react/blob/main/src/api/chat.js"
click node_chatendpoint "https://github.com/soumardev/e-commerce-react/blob/main/api/chat.php"
click node_newsletter "https://github.com/soumardev/e-commerce-react/blob/main/src/components/home/Newsletter.jsx"

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_router,node_home,node_category,node_product,node_notfound,node_header,node_categories,node_newsletter toneBlue
class node_productapi,node_phpcatalogue,node_productendpoint,node_categoryendpoint,node_db,node_mysql toneAmber
class node_cartstate,node_cartpage,node_cartitem,node_cartsummary toneMint
class node_authprovider,node_authclient,node_authendpoints toneRose
class node_chatwidget,node_chatclient,node_chatendpoint,node_shopper,node_claude toneIndigo
```

## Components

### Storefront

- [Page Router](https://github.com/soumardev/e-commerce-react/blob/main/src/main.jsx): `src/main.jsx`
- [Home Page](https://github.com/soumardev/e-commerce-react/blob/main/src/pages/HomePage.jsx): `src/pages/HomePage.jsx`
- [Category Page](https://github.com/soumardev/e-commerce-react/blob/main/src/pages/CategoryPage.jsx): `src/pages/CategoryPage.jsx`
- [Product Page](https://github.com/soumardev/e-commerce-react/blob/main/src/pages/ProductPage.jsx): `src/pages/ProductPage.jsx`
- [Not Found](https://github.com/soumardev/e-commerce-react/blob/main/src/pages/NotFound.jsx): `src/pages/NotFound.jsx`
- [Shop Header](https://github.com/soumardev/e-commerce-react/blob/main/src/components/Header.jsx): `src/components/Header.jsx`
- [Category Labels](https://github.com/soumardev/e-commerce-react/blob/main/src/data/categories.js): `src/data/categories.js`
- [Newsletter UI](https://github.com/soumardev/e-commerce-react/blob/main/src/components/home/Newsletter.jsx): `src/components/home/Newsletter.jsx`

### Product Catalogue

- [Product API Client](https://github.com/soumardev/e-commerce-react/blob/main/src/api/products.js): `src/api/products.js`
- [PHP Catalogue API](https://github.com/soumardev/e-commerce-react/blob/main/api/products.php): `api/products.php`
- [Product Endpoint](https://github.com/soumardev/e-commerce-react/blob/main/api/product.php): `api/product.php`
- [Category Endpoint](https://github.com/soumardev/e-commerce-react/blob/main/api/category.php): `api/category.php`
- [Database Access](https://github.com/soumardev/e-commerce-react/blob/main/api/db.php): `api/db.php`
- **Product Database**

### Cart

- [Cart State](https://github.com/soumardev/e-commerce-react/blob/main/src/context/CartContext.jsx): `src/context/CartContext.jsx`
- [Cart Page](https://github.com/soumardev/e-commerce-react/blob/main/src/pages/CartPage.jsx): `src/pages/CartPage.jsx`
- [Cart Item](https://github.com/soumardev/e-commerce-react/blob/main/src/components/cart/CartItem.jsx): `src/components/cart/CartItem.jsx`
- [Cart Summary](https://github.com/soumardev/e-commerce-react/blob/main/src/components/cart/CartSummary.jsx): `src/components/cart/CartSummary.jsx`

### Accounts

- [Auth Provider](https://github.com/soumardev/e-commerce-react/blob/main/src/context/AuthProvider.jsx): `src/context/AuthProvider.jsx`
- [Auth API Client](https://github.com/soumardev/e-commerce-react/blob/main/src/api/auth.js): `src/api/auth.js`
- [PHP Auth Endpoints](https://github.com/soumardev/e-commerce-react/blob/main/api/login.php): `api/login.php`

### Product Chat

- [Chat Widget](https://github.com/soumardev/e-commerce-react/blob/main/src/components/chat/ChatWidget.jsx): `src/components/chat/ChatWidget.jsx`
- [Chat API Client](https://github.com/soumardev/e-commerce-react/blob/main/src/api/chat.js): `src/api/chat.js`
- [Chat Endpoint](https://github.com/soumardev/e-commerce-react/blob/main/api/chat.php): `api/chat.php`

### Other components

- **Shopper**
- **Anthropic Claude**

## Connections

- Shopper → Page Router: visits pages (evidence: `src/main.jsx`)
- Page Router → Home Page: routes to (evidence: `src/main.jsx`)
- Page Router → Category Page: routes to (evidence: `src/main.jsx`)
- Page Router → Product Page: routes to (evidence: `src/main.jsx`)
- Page Router → Cart Page: routes to (evidence: `src/main.jsx`)
- Page Router → Not Found: routes to (evidence: `src/main.jsx`)
- Home Page → Category Labels: labels categories (evidence: `src/pages/HomePage.jsx`)
- Category Page → Category Labels: labels categories (evidence: `src/pages/CategoryPage.jsx`)
- Home Page → Product API Client: loads products
- Category Page → Product API Client: loads category (evidence: `src/pages/CategoryPage.jsx`)
- Product Page → Product API Client: loads product (evidence: `src/pages/ProductPage.jsx`)
- Product API Client → Product Endpoint: fetches product (evidence: `src/api/products.js`)
- Product API Client → Category Endpoint: fetches category (evidence: `src/api/products.js`)
- Product API Client → PHP Catalogue API: fetches all (evidence: `src/api/products.js`)
- Product Endpoint → Database Access: queries data
- Category Endpoint → Database Access: queries data
- PHP Catalogue API → Database Access: queries data
- Database Access → Product Database: reads catalogue
- Product Page → Cart State: adds item (evidence: `src/pages/ProductPage.jsx`)
- Cart State → Cart Page: provides cart (evidence: `src/pages/CartPage.jsx`)
- Cart Page → Cart Item: renders items (evidence: `src/pages/CartPage.jsx`)
- Cart Page → Cart Summary: renders summary (evidence: `src/pages/CartPage.jsx`)
- Cart Page → Product API Client: loads product data (evidence: `src/pages/CartPage.jsx`)
- Shopper → Shop Header: uses navigation
- Shop Header → Cart State: reads cart (evidence: `src/components/Header.jsx`)
- Shop Header → Auth Provider: uses auth
- Page Router → Auth Provider: wraps routes (evidence: `src/main.jsx`)
- Auth Provider → Auth API Client: calls auth API (evidence: `src/context/AuthProvider.jsx`)
- Auth API Client → PHP Auth Endpoints: sends requests
- Shopper → Chat Widget: asks questions
- Chat Widget → Chat API Client: sends conversation (evidence: `src/components/chat/ChatWidget.jsx`)
- Chat API Client → Chat Endpoint: posts messages
- Chat Endpoint → Database Access: loads product context (evidence: `api/chat.php`)
- Chat Endpoint → Anthropic Claude: requests answer (evidence: `api/chat.php`)
- Chat Endpoint → Shopper: returns answer
- Category Page → Not Found: shows for invalid (evidence: `src/pages/CategoryPage.jsx`)
- Product Page → Not Found: shows for missing (evidence: `src/pages/ProductPage.jsx`)
- Page Router → Newsletter UI: pages render
