# rmohitzz21/ux_shop_new architecture

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

- Interactive diagram: https://gitdiagram.com/rmohitzz21/ux_shop_new
- Repository: https://github.com/rmohitzz21/ux_shop_new

## Overview

1. **Project type and runtime**
   - This is a **server-rendered PHP e-commerce storefront** with a separate **admin console** and a versioned **JSON-style API layer** under `api/`.
   - The app appears to run on a **PHP + MySQL/MariaDB** stack, with database schema files in `marketplace_schema.sql` and `uxmerchandise.sql`.

2. **Presentation layer**
   - Public-facing pages live at the repo root: `index.php`, `shopAll.php`, `category.php`, `product.php`, `cart.php`, `checkout.php`, `wishlist.php`, `signin.php`, `signup.php`, `account.php`, `orders.php`, `order-confirmation.php`, etc.
   - Shared UI/layout code is centralized in `includes/header.php` and `includes/footer.php`, with global styling in `style.css` and client-side behavior in `script.js`.
   - This suggests a classic PHP page model where pages render server-side and then call APIs for interactive actions.

3. **API as the main application boundary**
   - Most business operations are exposed through `api/`, which is the main boundary between the browser and server logic.
   - The API is organized by domain: `auth`, `cart`, `wishlist`, `address`, `catalog`, `product`, `order`, `user`, `contact`, plus `admin/*`.
   - This separation indicates that pages likely consume these endpoints via fetch/AJAX rather than embedding all business logic directly in the page scripts.

4. **Authentication and session management**
   - Authentication flows are concentrated in `api/auth/*`, including login, signup, logout, session lookup, CSRF token issuance, and password reset flows.
   - The presence of `includes/auth-preload.php` implies a shared server-side guard or session bootstrap used by protected pages.
   - Admin authentication is distinct from customer authentication via `api/auth/admin-login.php` and admin-side utilities in `api/admin/_admin.php`.

5. **Customer commerce data flow**
   - Core shopping flows are: **browse catalog → view product detail → add to cart → checkout → create order**.
   - The catalog/product split is visible in `api/catalog/list.php`, `api/catalog/detail.php`, `api/product/get_details.php`, and `api/product/search.php`.
   - Cart operations are isolated in `api/cart/*`, while order creation and retrieval are in `api/order/*`.
   - User-specific state is managed separately for addresses and profiles via `api/address/*` and `api/user/update_profile.php`.

6. **Wishlist and account personalization**
   - Wishlist is a first-class subsystem under `api/wishlist/*`, with its own table helper in `api/wishlist/_table.php`.
   - Account data is also split into profile and address management, which suggests the app stores user identity, shipping info, and saved preferences separately from cart/order state.

7. **Checkout and payment integration**
   - Payment-related code is present in `includes/OrderPaymentService.php` and `includes/RazorpayClient.php`, indicating a payment gateway integration.
   - The older `apiold/payment/*` folder explicitly includes Razorpay create-order, verify, and webhook handlers, so payment processing has previously been webhook-driven and is likely still structurally similar.
   - The checkout path therefore spans frontend checkout UI, order creation APIs, payment gateway interaction, and post-payment verification/update logic.

8. **Admin subsystem**
   - Admin functionality is separated under `admin/` pages and `api/admin/*` endpoints.
   - Admin pages include dashboard, login, add/edit product, and a dashboard script, while admin APIs cover product CRUD, categories, bundles, orders, users, and statistics.
   - This is a distinct management plane: admins manage catalog content and operational data, while customers only interact with storefront APIs.

9. **Supporting services and cross-cutting concerns**
   - `includes/EmailService.php` and `includes/mail.php` indicate outbound email support, used by authentication and likely order/contact workflows.
   - `includes/Logger.php` and `logs/app_errors.log` show explicit application logging.
   - `includes/config.php`, `includes/env.php`, and `.env.example` suggest environment-based configuration for secrets, DB credentials, and service endpoints.
   - `includes/helpers.php` and `includes/marketplace.php` likely hold shared domain utilities and database access helpers.

10. **Legacy boundary**
   - The `apiold/` tree is a parallel legacy API implementation covering auth, cart, order, product, user, admin, email, and payment.
   - Its presence suggests an ongoing migration or compatibility layer; for architecture diagrams, it should be shown as **deprecated/legacy** and separated from the active `api/` namespace.

11. **Static assets and generated content**
   - Product and screenshot images live under `img/`, including `img/products` and `img/ss/*`, implying server-hosted media assets for catalog content and documentation/UI assets.
   - Root `404.php` and `500.php` provide custom error pages, reinforcing that this is a traditional web app served directly by PHP.

12. **Overall architecture shape**
   - The system is best modeled as: **browser/UI pages** at the top, **domain APIs** in the middle, **shared PHP services** in `includes/`, and **MySQL database + external services** at the bottom.
   - External dependencies that materially affect architecture are **email delivery** and **Razorpay payment processing**.
   - The clearest subsystem boundaries are: storefront pages, customer API, admin API, auth/session, order/payment, and legacy `apiold/`.

Main entry points: [`marketplace_schema.sql`](https://github.com/rmohitzz21/ux_shop_new/blob/main/marketplace_schema.sql) (MySQL schema), [`api/auth/login.php`](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/auth/login.php) (Customer auth), [`api/catalog/list.php`](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/catalog/list.php) (Catalog API), [`includes/mail.php`](https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/mail.php) (Email service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront UI"]
  node_n1["Storefront pages<br/>php pages<br/>[index.php]"]
  node_n2["Auth pages<br/>php auth<br/>[signin.php]"]
  node_n3["Catalog pages<br/>php catalog<br/>[shopAll.php]"]
  node_n4["Checkout flow<br/>php checkout<br/>[cart.php]"]
end

subgraph group_customer_api["Customer API"]
  node_n10["Customer auth<br/>api auth<br/>[login.php]"]
  node_n11["Catalog API<br/>api catalog<br/>[list.php]"]
  node_n12["Commerce API<br/>api commerce<br/>[add.php]"]
  node_n13["Customer profile<br/>api user<br/>[update_profile.php]"]
end

subgraph group_admin_plane["Admin Plane"]
  node_n5["Admin pages<br/>php admin"]
  node_n14["Admin APIs<br/>api admin<br/>[list.php]"]
end

subgraph group_shared["Shared PHP"]
  node_n6["Store bootstrap<br/>[_bootstrap.php]"]
  node_n7["Layout shell<br/>ui shared<br/>[header.php]"]
  node_n8["Config & env<br/>[config.php]"]
  node_n9["Core services"]
end

subgraph group_legacy["Legacy API"]
  node_n15["Legacy auth<br/>legacy api<br/>[login.php]"]
  node_n16["Legacy commerce<br/>legacy api<br/>[add.php]"]
end

subgraph group_data["Data & Integrations"]
  node_n17[("MySQL schema<br/>database")]
  node_n18["Media assets<br/>static assets"]
  node_n19["Email service<br/>external service<br/>[mail.php]"]
  node_n20["Razorpay<br/>payment gateway<br/>[RazorpayClient.php]"]
end

node_n1 -->|"bootstraps"| node_n6
node_n1 -->|"renders"| node_n7
node_n2 -->|"uses"| node_n10
node_n3 -->|"loads catalog"| node_n11
node_n4 -->|"orders"| node_n12
node_n4 -->|"pays via"| node_n20
node_n5 -->|"administers"| node_n14
node_n5 -.->|"shares ui"| node_n7
node_n10 -->|"configured by"| node_n8
node_n11 -->|"reads schema"| node_n17
node_n12 -->|"reads/writes"| node_n17
node_n13 -->|"stores profile"| node_n17
node_n14 -->|"manages data"| node_n17
node_n9 -->|"sends mail"| node_n19
node_n9 -->|"processes payment"| node_n20
node_n10 -.->|"notifies"| node_n19
node_n16 -.->|"legacy payments"| node_n20
node_n16 -.->|"legacy email"| node_n19
node_n18 -.->|"illustrates"| node_n11

click node_n1 "https://github.com/rmohitzz21/ux_shop_new/blob/main/index.php"
click node_n2 "https://github.com/rmohitzz21/ux_shop_new/blob/main/signin.php"
click node_n3 "https://github.com/rmohitzz21/ux_shop_new/blob/main/shopAll.php"
click node_n4 "https://github.com/rmohitzz21/ux_shop_new/blob/main/cart.php"
click node_n5 "https://github.com/rmohitzz21/ux_shop_new/blob/main/admin/admin-dashboard.php"
click node_n6 "https://github.com/rmohitzz21/ux_shop_new/blob/main/api/_bootstrap.php"
click node_n7 "https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/header.php"
click node_n8 "https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/config.php"
click node_n9 "https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/OrderPaymentService.php"
click node_n10 "https://github.com/rmohitzz21/ux_shop_new/blob/main/api/auth/login.php"
click node_n11 "https://github.com/rmohitzz21/ux_shop_new/blob/main/api/catalog/list.php"
click node_n12 "https://github.com/rmohitzz21/ux_shop_new/blob/main/api/cart/add.php"
click node_n13 "https://github.com/rmohitzz21/ux_shop_new/blob/main/api/user/update_profile.php"
click node_n14 "https://github.com/rmohitzz21/ux_shop_new/blob/main/api/admin/product/list.php"
click node_n15 "https://github.com/rmohitzz21/ux_shop_new/blob/main/apiold/auth/login.php"
click node_n16 "https://github.com/rmohitzz21/ux_shop_new/blob/main/apiold/cart/add.php"
click node_n17 "https://github.com/rmohitzz21/ux_shop_new/blob/main/marketplace_schema.sql"
click node_n18 "https://github.com/rmohitzz21/ux_shop_new/tree/main/img/products"
click node_n19 "https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/mail.php"
click node_n20 "https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/RazorpayClient.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_n1,node_n2,node_n3,node_n4 toneBlue
class node_n10,node_n11,node_n12,node_n13 toneAmber
class node_n5,node_n14 toneMint
class node_n6,node_n7,node_n8,node_n9 toneRose
class node_n15,node_n16 toneIndigo
class node_n17,node_n18,node_n19,node_n20 toneTeal
```

## Components

### Storefront UI

Public PHP pages rendered server-side for shopping and account flows

- [Storefront pages](https://github.com/rmohitzz21/ux_shop_new/blob/main/index.php): php pages · Public browsing, account, cart, and checkout entry pages · `index.php`
- [Auth pages](https://github.com/rmohitzz21/ux_shop_new/blob/main/signin.php): php auth · Signin, signup, password reset, and account access pages · `signin.php`
- [Catalog pages](https://github.com/rmohitzz21/ux_shop_new/blob/main/shopAll.php): php catalog · Category, product, search, bundles, and shop listing pages · `shopAll.php`
- [Checkout flow](https://github.com/rmohitzz21/ux_shop_new/blob/main/cart.php): php checkout · Cart, checkout, order confirmation, and order history pages · `cart.php`

### Customer API

Active JSON-style endpoints used by the storefront

- [Customer auth](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/auth/login.php): api auth · Login, signup, session, CSRF, and password reset endpoints · `api/auth/login.php`
- [Catalog API](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/catalog/list.php): api catalog · Browse and product detail/search endpoints for storefront pages · `api/catalog/list.php`
- [Commerce API](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/cart/add.php): api commerce · Cart, order, address, wishlist, profile, and contact endpoints · `api/cart/add.php`
- [Customer profile](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/user/update_profile.php): api user · Profile updates and user-scoped account data · `api/user/update_profile.php`

### Admin Plane

Back-office pages and admin endpoints for catalog and operations

- [Admin pages](https://github.com/rmohitzz21/ux_shop_new/blob/main/admin/admin-dashboard.php): php admin · Admin dashboard and product management screens · `admin/admin-dashboard.php`
- [Admin APIs](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/admin/product/list.php): api admin · Admin authentication plus product, category, bundle, order, user, and stats endpoints · `api/admin/product/list.php`

### Shared PHP

Reusable bootstrap, services, and cross-cutting utilities

- [Store bootstrap](https://github.com/rmohitzz21/ux_shop_new/blob/main/api/_bootstrap.php): bootstrap · Shared request bootstrap and auth preloading for protected pages · `api/_bootstrap.php`
- [Layout shell](https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/header.php): ui shared · Shared header, footer, and client-side app script · `includes/header.php`
- [Config & env](https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/config.php): config · Environment loading and application configuration · `includes/config.php`
- [Core services](https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/OrderPaymentService.php): services · Mail, logging, marketplace helpers, and payment gateway adapters · `includes/OrderPaymentService.php`

### Legacy API

Deprecated parallel API tree kept for compatibility or migration

- [Legacy auth](https://github.com/rmohitzz21/ux_shop_new/blob/main/apiold/auth/login.php): legacy api · Deprecated auth and session endpoints from the old API tree · `apiold/auth/login.php`
- [Legacy commerce](https://github.com/rmohitzz21/ux_shop_new/blob/main/apiold/cart/add.php): legacy api · Deprecated cart, order, product, user, contact, email, and payment endpoints · `apiold/cart/add.php`

### Data & Integrations

Persistent storage and external services that shape the application

- [MySQL schema](https://github.com/rmohitzz21/ux_shop_new/blob/main/marketplace_schema.sql): database · Application schema and data model definitions · `marketplace_schema.sql`
- [Media assets](https://github.com/rmohitzz21/ux_shop_new/tree/main/img/products): static assets · Product images and screenshot assets served by the app · `img/products`
- [Email service](https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/mail.php): external service · Outbound email delivery used by auth and transactional flows · `includes/mail.php`
- [Razorpay](https://github.com/rmohitzz21/ux_shop_new/blob/main/includes/RazorpayClient.php): payment gateway · Payment gateway integration for checkout and verification · `includes/RazorpayClient.php`

## Connections

- Storefront pages → Store bootstrap: bootstraps · Public pages initialize through shared server bootstrap
- Storefront pages → Layout shell: renders · Storefront pages reuse common header and footer shell
- Auth pages → Customer auth: uses · Authentication pages drive customer auth endpoints
- Catalog pages → Catalog API: loads catalog · Listing and product pages fetch catalog data
- Checkout flow → Commerce API: orders · Cart and checkout pages call commerce endpoints
- Checkout flow → Razorpay: pays via · Checkout integrates with payment gateway flows
- Admin pages → Admin APIs: administers · Admin screens are backed by admin APIs
- Admin pages → Layout shell: shares ui · Admin pages also rely on the shared UI shell
- Customer auth → Config & env: configured by · Auth endpoints depend on environment and config loading
- Catalog API → MySQL schema: reads schema · Catalog queries are backed by the application database
- Commerce API → MySQL schema: reads/writes · Commerce state is persisted in the core database
- Customer profile → MySQL schema: stores profile · User profile updates persist to the database
- Admin APIs → MySQL schema: manages data · Admin operations manage product, order, and user records
- Core services → Email service: sends mail · Shared services handle outgoing email notifications
- Core services → Razorpay: processes payment · Shared services wrap Razorpay checkout and verification
- Customer auth → Email service: notifies · Password reset and signup flows can trigger email delivery
- Legacy commerce → Razorpay: legacy payments · Legacy API contains older Razorpay order and webhook handling
- Legacy commerce → Email service: legacy email · Legacy tree also includes email-related behavior
- Media assets → Catalog API: illustrates · Catalog pages are backed by hosted product media
