How amitnverma/giftdekedekho works
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 Front controller · CheckoutController.php Checkout flow · home.php Store views · AdminDashboardController.php Admin ops
Components 26
Web boundary
Front controller, rewrite rules, and public assets exposed to the browser.
- Front controller · Main storefront request entry that routes public pages.
index.php - Rewrite rules · URL rewriting and access control boundary for the app.
.htaccess - Public assets · Browser-served CSS, JS, and uploaded media.
public
Storefront
Customer-facing pages and flows.
- Storefront pages · Primary customer-facing controllers for browsing and account flows.
app/controllers/HomeController.php - Catalog flow · Category, product, and cart interaction controllers.
app/controllers/CategoryController.php - Checkout flow · Checkout orchestration and order placement.
app/controllers/CheckoutController.php - Account area · Customer profile, orders, addresses, and wishlist pages.
app/controllers/AccountController.php - Watch page · Tokenized public view for gift media delivery.
app/controllers/WatchController.php
Admin area
Back-office routing, pages, and management screens.
- Admin router · Separate routing entry for the admin application.
app/controllers/AdminRouter.php - Admin ops · 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 · Shared PDO-backed model foundation.
app/models/BaseModel.php - Catalog models · Products, categories, carts, wishlists, reviews, and coupons.
app/models/Product.php - Order models · Orders, addresses, shipping, and user records.
app/models/Order.php - Settings model · Database-backed runtime settings and site configuration.
app/models/Settings.php - Gift media model · Order-linked personalized video/photo assets.
app/models/OrderVideoPhoto.php
Services
Cross-cutting business services for payments, shipping, media, and notifications.
- Payments · Gateway orchestration for checkout providers.
app/services/PaymentService.php - Shipping · Shiprocket integration and shipping-rule logic.
app/services/ShiprocketService.php - Notifications · Transactional email and SMS delivery service.
app/services/NotificationService.php - QR codes · QR generation for watch links and delivery artifacts.
app/services/QrCodeService.php
API endpoints
Lightweight AJAX-style endpoints for targeted interactions.
- Public API · Coupon validation, pincode checks, and wishlist toggling.
api/validate-coupon.php
Views
Template layer for storefront and admin rendering.
- Store views · Customer-facing page templates and shared sections.
app/views/store/home.php - Admin views · Back-office templates for management and reporting.
app/views/admin/dashboard.php
Infrastructure
Configuration, database, libraries, and deployment assets.
- Config · Application and database configuration files.
config/config.php - Schema seed · Initial schema, seed data, and default settings.
database.sql - Bundled libs · Bundled PDF, QR, and mail libraries.
libs/fpdf - Deploy workflow · GitHub Actions deployment pipeline.
.github/workflows/deploy.yml
Connections 42
- 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.