# mavs07082022/ecommerce-core architecture

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

- Interactive diagram: https://gitdiagram.com/mavs07082022/ecommerce-core
- Repository: https://github.com/mavs07082022/ecommerce-core

## Overview

This repository is a PHP e-commerce application with customer shopping, ordering and delivery, staff operations, and AI-assisted product discovery. The primary customer flow is browsing products, managing a cart, checking out and paying, then tracking delivery and optionally reviewing or returning an order. Staff manage catalog, orders, riders, returns, chat and reporting; customers also register and verify accounts. The map includes documented subsystems from the tree, but only sampled source establishes the specific checkout, AI, and reporting links shown; other unsampled wiring is omitted.

Main entry points: [`config/db.php`](https://github.com/mavs07082022/ecommerce-core/blob/main/config/db.php) (Application database), [`auth/register.php`](https://github.com/mavs07082022/ecommerce-core/blob/main/auth/register.php) (Register & OTP), [`api/ai_query.php`](https://github.com/mavs07082022/ecommerce-core/blob/main/api/ai_query.php) (Recommendations), [`api/ai_semantic_search.php`](https://github.com/mavs07082022/ecommerce-core/blob/main/api/ai_semantic_search.php) (Semantic search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_register["Register &amp; OTP<br/>[register.php]"]
  node_verify["Verify OTP<br/>[verify_otp.php]"]
  node_login["Staff login<br/>[login.php]"]
  node_auth["Session &amp; roles<br/>[auth.php]"]
end

subgraph group_commerce["Shopping &amp; Orders"]
  node_shop["Shop &amp; products<br/>[shop.php]"]
  node_detail["Product details<br/>[product_detail.php]"]
  node_cart["Cart endpoints<br/>[cart_add.php]"]
  node_checkout["Checkout<br/>[checkout.php]"]
  node_payment["Payment verification<br/>[verify_payment.php]"]
  node_orders["Order history<br/>[my_orders.php]"]
  node_reviews["Order reviews<br/>[order_review.php]"]
end

subgraph group_fulfillment["Fulfillment &amp; Support"]
  node_tracking["Order tracking<br/>[track_order.php]"]
  node_delivery["Delivery operations<br/>[deliveries.php]"]
  node_riderapp["Rider delivery<br/>[rider_delivery.php]"]
  node_chat["Customer chat<br/>[chat.php]"]
  node_chatapi["Chat endpoints<br/>[chat_send.php]"]
  node_returns["Returns<br/>[returns.php]"]
end

subgraph group_operations["Staff Operations"]
  node_staffops["Catalog &amp; orders<br/>[products.php]"]
  node_reports["Reports<br/>[reports.php]"]
  node_reportapi["Report data<br/>[reports_data.php]"]
end

subgraph group_discovery["AI Discovery"]
  node_aiquery["Recommendations<br/>[ai_query.php]"]
  node_semantic["Semantic search"]
  node_cohere["AI service<br/>[cohere_service.php]"]
end

node_customer(("Customer"))
node_staff(("Admin / staff"))
node_rider(("Rider"))
node_productsdb[("Application database<br/>[db.php]")]
node_cohereservice{{"Cohere API"}}
node_mail{{"Mail provider<br/>[mailer.php]"}}

node_customer -->|"registers"| node_register
node_register -->|"stores account / OTP"| node_productsdb
node_customer -->|"submits code"| node_verify
node_verify -->|"checks OTP"| node_productsdb
node_register -.->|"sends verification"| node_mail
node_staff -->|"signs in"| node_login
node_login -->|"checks role"| node_auth
node_customer -->|"browses"| node_shop
node_shop -->|"reads catalog"| node_productsdb
node_customer -->|"opens product"| node_detail
node_customer -->|"updates cart"| node_cart
node_cart -->|"updates cart state"| node_productsdb
node_customer -->|"places order"| node_checkout
node_checkout -->|"creates order"| node_productsdb
node_customer -->|"confirms payment"| node_payment
node_payment -->|"updates payment"| node_productsdb
node_customer -->|"views orders"| node_orders
node_orders -->|"reads orders"| node_productsdb
node_customer -->|"tracks shipment"| node_tracking
node_tracking -->|"reads status"| node_productsdb
node_staff -->|"manages catalog / orders"| node_staffops
node_staffops -->|"updates records"| node_productsdb
node_staff -->|"manages deliveries"| node_delivery
node_delivery -->|"updates delivery"| node_productsdb
node_rider -->|"updates delivery"| node_riderapp
node_riderapp -->|"stores progress"| node_productsdb
node_customer -->|"requests support"| node_chat
node_chat -->|"sends messages"| node_chatapi
node_chatapi -->|"stores messages"| node_productsdb
node_customer -->|"requests return"| node_returns
node_staff -->|"handles return"| node_returns
node_staff -->|"views analytics"| node_reports
node_reports -->|"fetches metrics"| node_reportapi
node_reportapi -->|"queries data"| node_productsdb
node_customer -->|"asks for recommendations"| node_aiquery
node_aiquery -->|"loads products"| node_productsdb
node_aiquery -.->|"requests chat"| node_cohere
node_customer -->|"searches by meaning"| node_semantic
node_semantic -.->|"requests ranking"| node_cohere
node_semantic -->|"searches products"| node_productsdb

click node_register "https://github.com/mavs07082022/ecommerce-core/blob/main/auth/register.php"
click node_verify "https://github.com/mavs07082022/ecommerce-core/blob/main/auth/verify_otp.php"
click node_login "https://github.com/mavs07082022/ecommerce-core/blob/main/admin/login.php"
click node_auth "https://github.com/mavs07082022/ecommerce-core/blob/main/includes/auth.php"
click node_shop "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/shop.php"
click node_detail "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/product_detail.php"
click node_cart "https://github.com/mavs07082022/ecommerce-core/blob/main/api/cart_add.php"
click node_checkout "https://github.com/mavs07082022/ecommerce-core/blob/main/api/checkout.php"
click node_payment "https://github.com/mavs07082022/ecommerce-core/blob/main/api/verify_payment.php"
click node_orders "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/my_orders.php"
click node_reviews "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/order_review.php"
click node_tracking "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/track_order.php"
click node_delivery "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/deliveries.php"
click node_riderapp "https://github.com/mavs07082022/ecommerce-core/blob/main/rider_delivery.php"
click node_chat "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/chat.php"
click node_chatapi "https://github.com/mavs07082022/ecommerce-core/blob/main/api/chat_send.php"
click node_returns "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/returns.php"
click node_staffops "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/products.php"
click node_reports "https://github.com/mavs07082022/ecommerce-core/blob/main/modules/reports.php"
click node_reportapi "https://github.com/mavs07082022/ecommerce-core/blob/main/api/reports_data.php"
click node_aiquery "https://github.com/mavs07082022/ecommerce-core/blob/main/api/ai_query.php"
click node_semantic "https://github.com/mavs07082022/ecommerce-core/blob/main/api/ai_semantic_search.php"
click node_cohere "https://github.com/mavs07082022/ecommerce-core/blob/main/ai/cohere_service.php"
click node_productsdb "https://github.com/mavs07082022/ecommerce-core/blob/main/config/db.php"
click node_mail "https://github.com/mavs07082022/ecommerce-core/blob/main/config/mailer.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_register,node_verify,node_login,node_auth toneBlue
class node_shop,node_detail,node_cart,node_checkout,node_payment,node_orders,node_reviews,node_productsdb toneAmber
class node_tracking,node_delivery,node_riderapp,node_chat,node_chatapi,node_returns,node_cohereservice toneMint
class node_staffops,node_reports,node_reportapi toneRose
class node_aiquery,node_semantic,node_cohere,node_customer,node_staff,node_rider,node_mail toneIndigo
```

## Components

### Identity

- [Register & OTP](https://github.com/mavs07082022/ecommerce-core/blob/main/auth/register.php): `auth/register.php`
- [Verify OTP](https://github.com/mavs07082022/ecommerce-core/blob/main/auth/verify_otp.php): `auth/verify_otp.php`
- [Staff login](https://github.com/mavs07082022/ecommerce-core/blob/main/admin/login.php): `admin/login.php`
- [Session & roles](https://github.com/mavs07082022/ecommerce-core/blob/main/includes/auth.php): `includes/auth.php`

### Shopping & Orders

- [Shop & products](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/shop.php): `modules/shop.php`
- [Product details](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/product_detail.php): `modules/product_detail.php`
- [Cart endpoints](https://github.com/mavs07082022/ecommerce-core/blob/main/api/cart_add.php): `api/cart_add.php`
- [Checkout](https://github.com/mavs07082022/ecommerce-core/blob/main/api/checkout.php): `api/checkout.php`
- [Payment verification](https://github.com/mavs07082022/ecommerce-core/blob/main/api/verify_payment.php): `api/verify_payment.php`
- [Order history](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/my_orders.php): `modules/my_orders.php`
- [Order reviews](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/order_review.php): `modules/order_review.php`

### Fulfillment & Support

- [Order tracking](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/track_order.php): `modules/track_order.php`
- [Delivery operations](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/deliveries.php): `modules/deliveries.php`
- [Rider delivery](https://github.com/mavs07082022/ecommerce-core/blob/main/rider_delivery.php): `rider_delivery.php`
- [Customer chat](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/chat.php): `modules/chat.php`
- [Chat endpoints](https://github.com/mavs07082022/ecommerce-core/blob/main/api/chat_send.php): `api/chat_send.php`
- [Returns](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/returns.php): `modules/returns.php`

### Staff Operations

- [Catalog & orders](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/products.php): `modules/products.php`
- [Reports](https://github.com/mavs07082022/ecommerce-core/blob/main/modules/reports.php): `modules/reports.php`
- [Report data](https://github.com/mavs07082022/ecommerce-core/blob/main/api/reports_data.php): `api/reports_data.php`

### AI Discovery

- [Recommendations](https://github.com/mavs07082022/ecommerce-core/blob/main/api/ai_query.php): `api/ai_query.php`
- [Semantic search](https://github.com/mavs07082022/ecommerce-core/blob/main/api/ai_semantic_search.php): `api/ai_semantic_search.php`
- [AI service](https://github.com/mavs07082022/ecommerce-core/blob/main/ai/cohere_service.php): `ai/cohere_service.php`

### Other components

- **Customer**
- **Admin / staff**
- **Rider**
- [Application database](https://github.com/mavs07082022/ecommerce-core/blob/main/config/db.php): `config/db.php`
- **Cohere API**
- [Mail provider](https://github.com/mavs07082022/ecommerce-core/blob/main/config/mailer.php): `config/mailer.php`

## Connections

- Customer → Register & OTP: registers
- Register & OTP → Application database: stores account / OTP
- Customer → Verify OTP: submits code
- Verify OTP → Application database: checks OTP
- Register & OTP → Mail provider: sends verification
- Admin / staff → Staff login: signs in
- Staff login → Session & roles: checks role
- Customer → Shop & products: browses
- Shop & products → Application database: reads catalog
- Customer → Product details: opens product
- Customer → Cart endpoints: updates cart
- Cart endpoints → Application database: updates cart state
- Customer → Checkout: places order
- Checkout → Application database: creates order
- Customer → Payment verification: confirms payment
- Payment verification → Application database: updates payment
- Customer → Order history: views orders
- Order history → Application database: reads orders
- Customer → Order tracking: tracks shipment
- Order tracking → Application database: reads status
- Admin / staff → Catalog & orders: manages catalog / orders
- Catalog & orders → Application database: updates records
- Admin / staff → Delivery operations: manages deliveries
- Delivery operations → Application database: updates delivery
- Rider → Rider delivery: updates delivery
- Rider delivery → Application database: stores progress
- Customer → Customer chat: requests support
- Customer chat → Chat endpoints: sends messages
- Chat endpoints → Application database: stores messages
- Customer → Returns: requests return
- Admin / staff → Returns: handles return
- Admin / staff → Reports: views analytics
- Reports → Report data: fetches metrics
- Report data → Application database: queries data
- Customer → Recommendations: asks for recommendations
- Recommendations → Application database: loads products
- Recommendations → AI service: requests chat
- Customer → Semantic search: searches by meaning
- Semantic search → AI service: requests ranking
- Semantic search → Application database: searches products
