# ahmedelaaser/phpcart architecture

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

- Interactive diagram: https://gitdiagram.com/ahmedelaaser/phpcart
- Repository: https://github.com/ahmedelaaser/phpcart

## Overview

phpcart is a PHP/MySQL storefront with customer accounts, a session-backed shopping cart, checkout, and an administrative back office. The main customer journey is browsing products, viewing a product, adding items to the cart, and checking out with a shipping choice; checkout records an order and its items and updates the customer balance. Separate capabilities include reviews, wishlists, order history, and catalog/customer/order administration. The excerpts show SQL access directly in page handlers; unsampled routes are included only where the README or source index establishes their role, so some links remain undocumented.

Main entry points: [`config/connect.php`](https://github.com/ahmedelaaser/phpcart/blob/master/config/connect.php) (MySQL connection), [`single.php`](https://github.com/ahmedelaaser/phpcart/blob/master/single.php) (Product details), [`checkout.php`](https://github.com/ahmedelaaser/phpcart/blob/master/checkout.php) (Checkout), [`index.php`](https://github.com/ahmedelaaser/phpcart/blob/master/index.php) (Product catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Storefront"]
  node_catalog["Product catalog<br/>[index.php]"]
  node_product["Product details<br/>[single.php]"]
  node_reviews["Ratings and reviews<br/>[single.php]"]
end

subgraph group_account["Customer account"]
  node_wishlist["Wishlist<br/>[wishlist.php]"]
  node_order_history["Order history<br/>[my-account.php]"]
  node_order_detail["Order details<br/>[view-order.php]"]
  node_profile["Profile and address<br/>[profile.php]"]
  node_customer_auth["Customer authentication<br/>[loginprocess.php]"]
end

subgraph group_orders["Cart and orders"]
  node_cart["Shopping cart<br/>[cart.php]"]
  node_cart_ops["Cart updates<br/>[addtocart.php]"]
  node_checkout["Checkout<br/>[checkout.php]"]
end

subgraph group_admin["Administration"]
  node_admin_auth["Admin sign-in<br/>[login.php]"]
  node_admin_catalog["Catalog management<br/>[addproduct.php]"]
  node_admin_orders["Order management<br/>[order-process.php]"]
  node_admin_customers["Customer management<br/>[editcustomer.php]"]
  node_admin_reviews["Review moderation<br/>[reviews.php]"]
  node_admin_shell["Admin navigation<br/>[nav.php]"]
end

subgraph group_data["Persistence"]
  node_db_config["MySQL connection<br/>[connect.php]"]
  node_mysql[("MySQL database")]
end

node_customer(("Shopper"))
node_admin_actor(("Administrator"))

node_customer -->|"browses"| node_catalog
node_catalog -->|"opens"| node_product
node_customer -->|"adds items"| node_cart_ops
node_product -->|"submits quantity"| node_cart_ops
node_customer -->|"views cart"| node_cart
node_customer -->|"checks out"| node_checkout
node_checkout -->|"writes orders"| node_mysql
node_checkout -->|"updates balance"| node_mysql
node_customer -->|"rates product"| node_reviews
node_product -->|"shows reviews"| node_reviews
node_customer -.->|"manages wishlist"| node_wishlist
node_customer -.->|"signs in"| node_customer_auth
node_customer -.->|"updates details"| node_profile
node_customer -.->|"views orders"| node_order_history
node_order_history -.->|"opens order"| node_order_detail
node_admin_actor -->|"signs in"| node_admin_auth
node_admin_actor -->|"manages catalog"| node_admin_catalog
node_admin_actor -->|"manages orders"| node_admin_orders
node_admin_actor -->|"manages customers"| node_admin_customers
node_admin_actor -->|"views reviews"| node_admin_reviews
node_admin_catalog -->|"includes navigation"| node_admin_shell
node_admin_catalog -->|"queries through"| node_db_config
node_admin_orders -->|"queries through"| node_db_config
node_admin_customers -->|"queries through"| node_db_config
node_admin_reviews -->|"queries through"| node_db_config
node_catalog -->|"queries through"| node_db_config
node_product -->|"queries through"| node_db_config
node_checkout -->|"queries through"| node_db_config
node_db_config -->|"connects"| node_mysql

click node_catalog "https://github.com/ahmedelaaser/phpcart/blob/master/index.php"
click node_product "https://github.com/ahmedelaaser/phpcart/blob/master/single.php"
click node_reviews "https://github.com/ahmedelaaser/phpcart/blob/master/single.php"
click node_cart "https://github.com/ahmedelaaser/phpcart/blob/master/cart.php"
click node_cart_ops "https://github.com/ahmedelaaser/phpcart/blob/master/addtocart.php"
click node_wishlist "https://github.com/ahmedelaaser/phpcart/blob/master/wishlist.php"
click node_checkout "https://github.com/ahmedelaaser/phpcart/blob/master/checkout.php"
click node_order_history "https://github.com/ahmedelaaser/phpcart/blob/master/my-account.php"
click node_order_detail "https://github.com/ahmedelaaser/phpcart/blob/master/view-order.php"
click node_profile "https://github.com/ahmedelaaser/phpcart/blob/master/profile.php"
click node_customer_auth "https://github.com/ahmedelaaser/phpcart/blob/master/loginprocess.php"
click node_admin_auth "https://github.com/ahmedelaaser/phpcart/blob/master/admin/login.php"
click node_admin_catalog "https://github.com/ahmedelaaser/phpcart/blob/master/admin/addproduct.php"
click node_admin_orders "https://github.com/ahmedelaaser/phpcart/blob/master/admin/order-process.php"
click node_admin_customers "https://github.com/ahmedelaaser/phpcart/blob/master/admin/editcustomer.php"
click node_admin_reviews "https://github.com/ahmedelaaser/phpcart/blob/master/admin/reviews.php"
click node_admin_shell "https://github.com/ahmedelaaser/phpcart/blob/master/admin/inc/nav.php"
click node_db_config "https://github.com/ahmedelaaser/phpcart/blob/master/config/connect.php"

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,node_product,node_reviews toneBlue
class node_wishlist,node_order_history,node_order_detail,node_profile,node_customer_auth toneAmber
class node_cart,node_cart_ops,node_checkout toneMint
class node_admin_auth,node_admin_catalog,node_admin_orders,node_admin_customers,node_admin_reviews,node_admin_shell toneRose
class node_db_config,node_mysql,node_customer,node_admin_actor toneIndigo
```

## Components

### Storefront

- [Product catalog](https://github.com/ahmedelaaser/phpcart/blob/master/index.php): `index.php`
- [Product details](https://github.com/ahmedelaaser/phpcart/blob/master/single.php): `single.php`
- [Ratings and reviews](https://github.com/ahmedelaaser/phpcart/blob/master/single.php): `single.php`

### Customer account

- [Wishlist](https://github.com/ahmedelaaser/phpcart/blob/master/wishlist.php): `wishlist.php`
- [Order history](https://github.com/ahmedelaaser/phpcart/blob/master/my-account.php): `my-account.php`
- [Order details](https://github.com/ahmedelaaser/phpcart/blob/master/view-order.php): `view-order.php`
- [Profile and address](https://github.com/ahmedelaaser/phpcart/blob/master/profile.php): `profile.php`
- [Customer authentication](https://github.com/ahmedelaaser/phpcart/blob/master/loginprocess.php): `loginprocess.php`

### Cart and orders

- [Shopping cart](https://github.com/ahmedelaaser/phpcart/blob/master/cart.php): `cart.php`
- [Cart updates](https://github.com/ahmedelaaser/phpcart/blob/master/addtocart.php): `addtocart.php`
- [Checkout](https://github.com/ahmedelaaser/phpcart/blob/master/checkout.php): `checkout.php`

### Administration

- [Admin sign-in](https://github.com/ahmedelaaser/phpcart/blob/master/admin/login.php): `admin/login.php`
- [Catalog management](https://github.com/ahmedelaaser/phpcart/blob/master/admin/addproduct.php): `admin/addproduct.php`
- [Order management](https://github.com/ahmedelaaser/phpcart/blob/master/admin/order-process.php): `admin/order-process.php`
- [Customer management](https://github.com/ahmedelaaser/phpcart/blob/master/admin/editcustomer.php): `admin/editcustomer.php`
- [Review moderation](https://github.com/ahmedelaaser/phpcart/blob/master/admin/reviews.php): `admin/reviews.php`
- [Admin navigation](https://github.com/ahmedelaaser/phpcart/blob/master/admin/inc/nav.php): `admin/inc/nav.php`

### Persistence

- [MySQL connection](https://github.com/ahmedelaaser/phpcart/blob/master/config/connect.php): `config/connect.php`
- **MySQL database**

### Other components

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

## Connections

- Shopper → Product catalog: browses
- Product catalog → Product details: opens (evidence: `index.php`)
- Shopper → Cart updates: adds items
- Product details → Cart updates: submits quantity (evidence: `single.php`)
- Shopper → Shopping cart: views cart
- Shopper → Checkout: checks out
- Checkout → MySQL database: writes orders (evidence: `checkout.php`)
- Checkout → MySQL database: updates balance (evidence: `checkout.php`)
- Shopper → Ratings and reviews: rates product
- Product details → Ratings and reviews: shows reviews (evidence: `single.php`)
- Shopper → Wishlist: manages wishlist
- Shopper → Customer authentication: signs in
- Shopper → Profile and address: updates details
- Shopper → Order history: views orders
- Order history → Order details: opens order
- Administrator → Admin sign-in: signs in
- Administrator → Catalog management: manages catalog
- Administrator → Order management: manages orders
- Administrator → Customer management: manages customers
- Administrator → Review moderation: views reviews
- Catalog management → Admin navigation: includes navigation (evidence: `admin/addproduct.php`)
- Catalog management → MySQL connection: queries through (evidence: `admin/addproduct.php`)
- Order management → MySQL connection: queries through (evidence: `admin/order-process.php`)
- Customer management → MySQL connection: queries through (evidence: `admin/editcustomer.php`)
- Review moderation → MySQL connection: queries through (evidence: `admin/reviews.php`)
- Product catalog → MySQL connection: queries through (evidence: `index.php`)
- Product details → MySQL connection: queries through (evidence: `single.php`)
- Checkout → MySQL connection: queries through (evidence: `checkout.php`)
- MySQL connection → MySQL database: connects (evidence: `config/connect.php`)
