# amitnverma/giftdekedekho architecture

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

- Interactive diagram: https://gitdiagram.com/amitnverma/giftdekedekho
- Repository: https://github.com/amitnverma/giftdekedekho

## Overview

1. **Overall shape**
   GiftDekeDekho is a single PHP 8+ monolith using a hand-rolled MVC pattern. `index.php` is the main front controller for the storefront, while `app/controllers/AdminRouter.php` handles the admin area. Most behavior is split across controllers, PDO-backed models, service classes, and PHP view templates.

2. **Request routing and web boundary**
   Apache rewrites clean URLs through `index.php` via `.htaccess`. Public web assets live in `public/`, and uploaded media is also web-accessible under `public/uploads/`. Sensitive code and configuration are kept outside direct browser access by `.htaccess` rules.

3. **Storefront subsystem**
   Customer-facing pages are implemented in `app/controllers/*Controller.php` and `app/views/store/*`. This includes home, category browsing, product detail, cart, checkout, account pages, order history, wishlist, and the custom `watch/{token}` page for QR-based video/photo gifts. `HomeController`, `ProductController`, `CartController`, `CheckoutController`, `AccountController`, and `WatchController` are the primary entry points.

4. **Admin subsystem**
   The admin panel is a separate UI and routing path under `app/controllers/Admin*`. It covers authentication, dashboard, catalog management, customers, orders, coupons, reviews, shipping rules, site design, and settings. Views under `app/views/admin/` mirror those domains, including login, order detail, invoices, and configuration pages.

5. **Domain/data model layer**
   Models in `app/models/` map the platform’s core entities: users, products, categories, carts, orders, addresses, reviews, coupons, shipping, settings, wishlists, and the order-linked video/photo asset. `BaseModel` is the shared persistence layer, and the rest are thin domain-specific data access classes over MySQL.

6. **Settings as a control plane**
   A key architectural feature is that operational configuration is stored in the database, not hardcoded. The admin Settings pages drive payments, notifications, shipping, branding, and site content. This means runtime behavior changes through the `settings` table and `site_sections` data rather than code deployment.

7. **Checkout and payment flow**
   Checkout is orchestrated by `CheckoutController` and `app/services/PaymentService.php`. The platform supports Razorpay, Stripe, PayPal, and Cash on Delivery. Payment provider keys are loaded from settings, and the checkout views include provider-specific flows such as `checkout_razorpay.php` and `checkout_stripe.php`.

8. **Shipping and fulfillment**
   Shipping logic is centralized in `app/services/ShiprocketService.php` plus shipping-related models and admin pages. The app supports serviceable pincode validation, flat/free shipping rules, and Shiprocket integration for fulfillment and tracking. Pincode checks also appear as a dedicated API endpoint.

9. **Notifications and customer communication**
   `app/services/NotificationService.php` handles transactional email and SMS delivery. The system is configured from admin settings using SMTP and MSG91 credentials, with template-driven messages for order lifecycle events. PHPMailer is bundled as an optional dependency for SMTP, with mail() fallback behavior described in the README.

10. **Video & Photo QR gifting feature**
    This is a distinct product capability built around `WatchController`, `QrCodeService`, and the `OrderVideoPhoto` model. After shipping, admins upload personalized media for an order; the system generates an unguessable token and a QR code linking to a public watch page. The QR artifact is stored under `public/uploads/qrcodes/`, and the recipient view is isolated from the admin workflow.

11. **Public API endpoints**
    The `api/` folder contains small AJAX-style endpoints for cross-page interactions: coupon validation, pincode checks, and wishlist toggling. These endpoints are lightweight integration points that expose targeted business rules without going through the full page rendering flow.

12. **Assets, media, and document generation**
    User-uploaded images, branding files, banners, product media, section graphics, QR codes, and videos are stored in structured subfolders under `public/uploads/`. The app also bundles optional libraries for FPDF, phpqrcode, and PHPMailer, which support invoice PDFs, QR generation, and email delivery. Invoice rendering has both PDF and HTML view support.

13. **Database and deployment boundary**
    `database.sql` seeds the initial schema, default settings, categories, and an admin account. A migration file adds newer customization sub-option support, indicating the schema evolves incrementally. The repository also includes a GitHub Actions deploy workflow, suggesting a basic CI/CD path for pushing the PHP app to hosting.

14. **Operational and security posture**
    The architecture relies on prepared statements, password hashing, CSRF protection, admin login throttling, optional IP allowlisting, and session timeouts. The platform is designed for shared-hosting-style Apache deployments, with `mod_rewrite`, `mod_headers`, and writable upload directories as key runtime assumptions.

Main entry points: [`index.php`](https://github.com/amitnverma/giftdekedekho/blob/main/index.php) (Front controller), [`app/controllers/CheckoutController.php`](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/CheckoutController.php) (Checkout flow), [`app/views/store/home.php`](https://github.com/amitnverma/giftdekedekho/blob/main/app/views/store/home.php) (Store views), [`app/controllers/AdminDashboardController.php`](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AdminDashboardController.php) (Admin ops)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web boundary"]
  node_index["Front controller<br/>php entrypoint<br/>[index.php]"]
  node_htaccess["Rewrite rules<br/>apache config<br/>[.htaccess]"]
  node_public[("Public assets<br/>asset root")]
end

subgraph group_store["Storefront"]
  node_store_home["Storefront pages<br/>store controllers<br/>[HomeController.php]"]
  node_store_catalog["Catalog flow<br/>store controllers"]
  node_store_checkout["Checkout flow<br/>store controller"]
  node_store_account["Account area<br/>store controller"]
  node_watch["Watch page<br/>store controller"]
end

subgraph group_admin["Admin area"]
  node_admin_router["Admin router<br/>admin entrypoint<br/>[AdminRouter.php]"]
  node_admin_core["Admin ops<br/>admin controllers"]
end

subgraph group_domain["Domain layer"]
  node_base_model["Base model<br/>persistence base<br/>[BaseModel.php]"]
  node_catalog_models["Catalog models<br/>domain models<br/>[Product.php]"]
  node_order_models["Order models<br/>domain models<br/>[Order.php]"]
  node_settings_model["Settings model<br/>domain model<br/>[Settings.php]"]
  node_media_model["Gift media model<br/>domain model"]
end

subgraph group_svc["Services"]
  node_payments["Payments<br/>[PaymentService.php]"]
  node_shipping["Shipping"]
  node_notify["Notifications"]
  node_qrcode["QR codes<br/>[QrCodeService.php]"]
end

subgraph group_api["API endpoints"]
  node_api_endpoints["Public API<br/>ajax endpoints"]
end

subgraph group_views["Views"]
  node_store_views["Store views<br/>templates<br/>[home.php]"]
  node_admin_views["Admin views<br/>templates<br/>[dashboard.php]"]
end

subgraph group_infra["Infrastructure"]
  node_config["Config<br/>[config.php]"]
  node_database_sql["Schema seed<br/>sql bootstrap<br/>[database.sql]"]
  node_libs[("Bundled libs<br/>vendor libs")]
  node_deploy["Deploy workflow<br/>ci/cd<br/>[deploy.yml]"]
end

node_htaccess -->|"rewrites to"| node_index
node_index -->|"dispatches"| node_store_home
node_index -->|"dispatches"| node_store_catalog
node_index -->|"dispatches"| node_store_checkout
node_index -->|"dispatches"| node_store_account
node_index -->|"dispatches"| node_watch
node_admin_router -->|"routes to"| node_admin_core
node_store_home -->|"renders"| node_store_views
node_store_catalog -->|"renders"| node_store_views
node_store_checkout -->|"renders"| node_store_views
node_store_account -->|"renders"| node_store_views
node_watch -->|"renders"| node_store_views
node_admin_core -->|"renders"| node_admin_views
node_store_home -->|"reads"| node_catalog_models
node_store_catalog -->|"reads"| node_catalog_models
node_store_checkout -->|"writes"| node_order_models
node_store_account -->|"reads"| node_order_models
node_admin_core -->|"manages"| node_order_models
node_admin_core -->|"manages"| node_catalog_models
node_admin_core -->|"updates"| node_settings_model
node_store_checkout -->|"uses"| node_payments
node_store_checkout -->|"uses"| node_shipping
node_store_checkout -->|"triggers"| node_notify
node_watch -->|"reads"| node_media_model
node_watch -->|"depends on"| node_qrcode
node_api_endpoints -->|"uses"| node_catalog_models
node_api_endpoints -->|"uses"| node_order_models
node_catalog_models -->|"extends"| node_base_model
node_order_models -->|"extends"| node_base_model
node_settings_model -->|"extends"| node_base_model
node_media_model -->|"extends"| node_base_model
node_payments -->|"reads config"| node_settings_model
node_shipping -->|"reads config"| node_settings_model
node_notify -->|"reads config"| node_settings_model
node_qrcode -->|"writes"| node_public
node_store_views -->|"loads assets"| node_public
node_admin_views -->|"loads assets"| node_public
node_config -->|"bootstraps"| node_database_sql
node_deploy -->|"deploys"| node_index
node_libs -->|"supports"| node_payments
node_libs -->|"supports"| node_qrcode
node_libs -->|"supports"| node_notify

click node_index "https://github.com/amitnverma/giftdekedekho/blob/main/index.php"
click node_htaccess "https://github.com/amitnverma/giftdekedekho/blob/main/.htaccess"
click node_public "https://github.com/amitnverma/giftdekedekho/tree/main/public"
click node_store_home "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/HomeController.php"
click node_store_catalog "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/CategoryController.php"
click node_store_checkout "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/CheckoutController.php"
click node_store_account "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AccountController.php"
click node_watch "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/WatchController.php"
click node_admin_router "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AdminRouter.php"
click node_admin_core "https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AdminDashboardController.php"
click node_base_model "https://github.com/amitnverma/giftdekedekho/blob/main/app/models/BaseModel.php"
click node_catalog_models "https://github.com/amitnverma/giftdekedekho/blob/main/app/models/Product.php"
click node_order_models "https://github.com/amitnverma/giftdekedekho/blob/main/app/models/Order.php"
click node_settings_model "https://github.com/amitnverma/giftdekedekho/blob/main/app/models/Settings.php"
click node_media_model "https://github.com/amitnverma/giftdekedekho/blob/main/app/models/OrderVideoPhoto.php"
click node_payments "https://github.com/amitnverma/giftdekedekho/blob/main/app/services/PaymentService.php"
click node_shipping "https://github.com/amitnverma/giftdekedekho/blob/main/app/services/ShiprocketService.php"
click node_notify "https://github.com/amitnverma/giftdekedekho/blob/main/app/services/NotificationService.php"
click node_qrcode "https://github.com/amitnverma/giftdekedekho/blob/main/app/services/QrCodeService.php"
click node_api_endpoints "https://github.com/amitnverma/giftdekedekho/blob/main/api/validate-coupon.php"
click node_store_views "https://github.com/amitnverma/giftdekedekho/blob/main/app/views/store/home.php"
click node_admin_views "https://github.com/amitnverma/giftdekedekho/blob/main/app/views/admin/dashboard.php"
click node_config "https://github.com/amitnverma/giftdekedekho/blob/main/config/config.php"
click node_database_sql "https://github.com/amitnverma/giftdekedekho/blob/main/database.sql"
click node_libs "https://github.com/amitnverma/giftdekedekho/tree/main/libs/fpdf"
click node_deploy "https://github.com/amitnverma/giftdekedekho/blob/main/.github/workflows/deploy.yml"

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_index,node_htaccess,node_public,node_store_views,node_admin_views toneBlue
class node_store_home,node_store_catalog,node_store_checkout,node_store_account,node_watch,node_config,node_database_sql,node_libs,node_deploy toneAmber
class node_admin_router,node_admin_core toneMint
class node_base_model,node_catalog_models,node_order_models,node_settings_model,node_media_model toneRose
class node_payments,node_shipping,node_notify,node_qrcode toneIndigo
class node_api_endpoints toneTeal
```

## Components

### Web boundary

Front controller, rewrite rules, and public assets exposed to the browser.

- [Front controller](https://github.com/amitnverma/giftdekedekho/blob/main/index.php): php entrypoint · Main storefront request entry that routes public pages. · `index.php`
- [Rewrite rules](https://github.com/amitnverma/giftdekedekho/blob/main/.htaccess): apache config · URL rewriting and access control boundary for the app. · `.htaccess`
- [Public assets](https://github.com/amitnverma/giftdekedekho/tree/main/public): asset root · Browser-served CSS, JS, and uploaded media. · `public`

### Storefront

Customer-facing pages and flows.

- [Storefront pages](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/HomeController.php): store controllers · Primary customer-facing controllers for browsing and account flows. · `app/controllers/HomeController.php`
- [Catalog flow](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/CategoryController.php): store controllers · Category, product, and cart interaction controllers. · `app/controllers/CategoryController.php`
- [Checkout flow](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/CheckoutController.php): store controller · Checkout orchestration and order placement. · `app/controllers/CheckoutController.php`
- [Account area](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AccountController.php): store controller · Customer profile, orders, addresses, and wishlist pages. · `app/controllers/AccountController.php`
- [Watch page](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/WatchController.php): store controller · Tokenized public view for gift media delivery. · `app/controllers/WatchController.php`

### Admin area

Back-office routing, pages, and management screens.

- [Admin router](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AdminRouter.php): admin entrypoint · Separate routing entry for the admin application. · `app/controllers/AdminRouter.php`
- [Admin ops](https://github.com/amitnverma/giftdekedekho/blob/main/app/controllers/AdminDashboardController.php): admin controllers · Authentication, dashboard, catalog, customers, orders, reviews, coupons, design, shipping, and settings. · `app/controllers/AdminDashboardController.php`

### Domain layer

Core models representing store entities and persistence boundaries.

- [Base model](https://github.com/amitnverma/giftdekedekho/blob/main/app/models/BaseModel.php): persistence base · Shared PDO-backed model foundation. · `app/models/BaseModel.php`
- [Catalog models](https://github.com/amitnverma/giftdekedekho/blob/main/app/models/Product.php): domain models · Products, categories, carts, wishlists, reviews, and coupons. · `app/models/Product.php`
- [Order models](https://github.com/amitnverma/giftdekedekho/blob/main/app/models/Order.php): domain models · Orders, addresses, shipping, and user records. · `app/models/Order.php`
- [Settings model](https://github.com/amitnverma/giftdekedekho/blob/main/app/models/Settings.php): domain model · Database-backed runtime settings and site configuration. · `app/models/Settings.php`
- [Gift media model](https://github.com/amitnverma/giftdekedekho/blob/main/app/models/OrderVideoPhoto.php): domain model · Order-linked personalized video/photo assets. · `app/models/OrderVideoPhoto.php`

### Services

Cross-cutting business services for payments, shipping, media, and notifications.

- [Payments](https://github.com/amitnverma/giftdekedekho/blob/main/app/services/PaymentService.php): service · Gateway orchestration for checkout providers. · `app/services/PaymentService.php`
- [Shipping](https://github.com/amitnverma/giftdekedekho/blob/main/app/services/ShiprocketService.php): service · Shiprocket integration and shipping-rule logic. · `app/services/ShiprocketService.php`
- [Notifications](https://github.com/amitnverma/giftdekedekho/blob/main/app/services/NotificationService.php): service · Transactional email and SMS delivery service. · `app/services/NotificationService.php`
- [QR codes](https://github.com/amitnverma/giftdekedekho/blob/main/app/services/QrCodeService.php): service · QR generation for watch links and delivery artifacts. · `app/services/QrCodeService.php`

### API endpoints

Lightweight AJAX-style endpoints for targeted interactions.

- [Public API](https://github.com/amitnverma/giftdekedekho/blob/main/api/validate-coupon.php): ajax endpoints · Coupon validation, pincode checks, and wishlist toggling. · `api/validate-coupon.php`

### Views

Template layer for storefront and admin rendering.

- [Store views](https://github.com/amitnverma/giftdekedekho/blob/main/app/views/store/home.php): templates · Customer-facing page templates and shared sections. · `app/views/store/home.php`
- [Admin views](https://github.com/amitnverma/giftdekedekho/blob/main/app/views/admin/dashboard.php): templates · Back-office templates for management and reporting. · `app/views/admin/dashboard.php`

### Infrastructure

Configuration, database, libraries, and deployment assets.

- [Config](https://github.com/amitnverma/giftdekedekho/blob/main/config/config.php): env/config · Application and database configuration files. · `config/config.php`
- [Schema seed](https://github.com/amitnverma/giftdekedekho/blob/main/database.sql): sql bootstrap · Initial schema, seed data, and default settings. · `database.sql`
- [Bundled libs](https://github.com/amitnverma/giftdekedekho/tree/main/libs/fpdf): vendor libs · Bundled PDF, QR, and mail libraries. · `libs/fpdf`
- [Deploy workflow](https://github.com/amitnverma/giftdekedekho/blob/main/.github/workflows/deploy.yml): ci/cd · GitHub Actions deployment pipeline. · `.github/workflows/deploy.yml`

## Connections

- Rewrite rules → Front controller: rewrites to · Clean public URLs route through the storefront front controller.
- Front controller → Storefront pages: dispatches · Main entry dispatches storefront requests to controllers.
- Front controller → Catalog flow: dispatches · Routes catalog and product browsing requests.
- Front controller → Checkout flow: dispatches · Routes checkout requests.
- Front controller → Account area: dispatches · Routes account pages and user state.
- Front controller → Watch page: dispatches · Routes public watch-token pages.
- Admin router → Admin ops: routes to · Admin entrypoint fans out to the management controllers.
- Storefront pages → Store views: renders · Storefront controllers render page templates.
- Catalog flow → Store views: renders · Catalog controllers render product and category views.
- Checkout flow → Store views: renders · Checkout controller renders payment-specific templates.
- Account area → Store views: renders · Account controller renders profile and order views.
- Watch page → Store views: renders · Watch controller renders valid/invalid player views.
- Admin ops → Admin views: renders · Admin controllers render management screens.
- Storefront pages → Catalog models: reads · Home and browsing flows load catalog data.
- Catalog flow → Catalog models: reads · Product, category, cart, wishlist, and review data access.
- Checkout flow → Order models: writes · Checkout creates and updates orders and addresses.
- Account area → Order models: reads · Account pages read orders, addresses, and user records.
- Admin ops → Order models: manages · Admin workflows manage orders and customer records.
- Admin ops → Catalog models: manages · Admin workflows manage catalog entities.
- Admin ops → Settings model: updates · Admin settings pages persist runtime configuration.
- Checkout flow → Payments: uses · Checkout delegates provider logic to the payment service.
- Checkout flow → Shipping: uses · Checkout consults shipping rules and fulfillment integration.
- Checkout flow → Notifications: triggers · Order placement triggers customer communication.
- Watch page → Gift media model: reads · Watch page resolves the order-linked media asset.
- Watch page → QR codes: depends on · Watch token flow is paired with QR generation artifacts.
- Public API → Catalog models: uses · Endpoints validate coupons, pincode, and wishlist rules.
- Public API → Order models: uses · Endpoints consult shipping and order-related data.
- Catalog models → Base model: extends · Domain models share the base persistence layer.
- Order models → Base model: extends · Order-related models share the base persistence layer.
- Settings model → Base model: extends · Settings access uses the shared persistence layer.
- Gift media model → Base model: extends · Gift media records use the shared persistence layer.
- Payments → Settings model: reads config · Gateway keys and provider selection come from stored settings.
- Shipping → Settings model: reads config · Shipping rules and integration credentials are settings-driven.
- Notifications → Settings model: reads config · SMTP and SMS credentials are loaded from settings.
- QR codes → Public assets: writes · QR artifacts are stored in the web-accessible upload tree.
- Store views → Public assets: loads assets · Storefront pages consume CSS, JS, images, and uploads.
- Admin views → Public assets: loads assets · Admin screens consume shared assets and uploads.
- Config → Schema seed: bootstraps · Database and app configuration are initialized from schema seed data.
- Deploy workflow → Front controller: deploys · Workflow publishes the PHP application entrypoint and assets.
- Bundled libs → Payments: supports · Bundled libraries support PDFs, QR codes, and SMTP mail.
- Bundled libs → QR codes: supports · QR generation library backs token artifacts.
- Bundled libs → Notifications: supports · Mailer library supports transactional email delivery.
