Welcome to GrocerEase v2, a modern, secure, and production-grade rewrite of the legacy GrocerEase e-commerce platform. Built with Laravel 11 / PHP 8.3, this application elevates the original procedural PHP site into a secure, modular, service-oriented architecture designed to handle high transaction volumes with sub-second response times.
GrocerEase v2 employs a Service-Repository Pattern to decouple database mutations, third-party payment gateways, and image processing from controller endpoints. This ensures that application controllers remain thin and testable, while business logic is fully isolated.
graph TD
Client[Web Client] -->|Routes| WebController[Controllers]
WebController -->|Eager Load| Model[Eloquent Models]
WebController -->|Use Cases| Service[Services Layer]
Service -->|Database Transaction| DB[(SQLite/Postgres)]
Service -->|API Clients| Payment[eSewa & Khalti Gateways]
Service -->|Cloud Storage Driver| S3[Cloudflare R2 / Spaces]
- Legacy Flaw: The original admin area had no authentication layer—URLs were exposed to any visitor.
- V2 Solution: Fully rewritten authentication flow using secure hashing (BCrypt) with distinct roles.
- Security Features: Added a highly robust custom
AdminMiddlewarethat intercepts requests to all admin endpoints and blocks unauthorized accounts.
- Legacy Flaw: Direct database query injections, missing URL slugs, and manual pagination calculations.
- V2 Solution: Implemented a comprehensive search & dynamic filtration engine inside
ProductService. - Key Features: Supports category filters, brand filters, min/max price boundaries, and raw keyword wildcard searches. Supports SEO-friendly slugs using
Str::slug.
- Legacy Flaw: Cart association relied entirely on the user's IP address (a severe security vulnerability).
- V2 Solution: Designed a session-based state machine via
CartService. - Cart Sync:
- Guests: Associated using a secure session-stored UUID (
session('cart_id')). - Authenticated Users: Mapped directly to
user_idin the database. - Automatic Reconciliation: On login, guest items are automatically transferred and merged into the user's persistent cart, deduplicating products and enforcing strict stock-quantity limits.
- Guests: Associated using a secure session-stored UUID (
- Legacy Flaw: Prone to overselling due to race conditions during parallel transactions.
- V2 Solution: Implemented strict transactional atomicity inside
OrderService::placeOrder. - Concurrency Protection: Uses
DB::transaction()with pessimistic database locking. Line-item pricing is snapshotted directly from the live product catalog, and checkout automatically aborts with an exception if any product drops below the required stock levels.
- eSewa (v2): Integrates modern HMAC-SHA256 signature authorization using the base64-encoded payload protocol. Handled via a hidden form auto-POST redirection mechanism inside
esewa_redirect.blade.php. - Khalti: Fully API-driven payment orchestration that requests transaction URLs dynamically from the Khalti Sandbox endpoints and maps verification callouts transparently.
- Reliability: Fully logged payment tracking maps states (
pending→completed/failed) ensuring reliable auditing.
- Dashboard: Full business insight showing aggregate revenue (from paid orders), transaction metrics, product stats, and low-stock alarms (
stock_quantity < 5). - Image Optimization: Leverages the
Intervention Imagelibrary (v3) to intercept multi-image file uploads, instantly scales them down to800x800(preserving aspect ratio), and saves them using the custom driver. - Order Management: Full data table with range-based date filters and dynamic, zero-reload AJAX order status transition validation.
- Cloud Decoupling: Installed S3 Flysystem driver to serve files out-of-box from Cloudflare R2 or DigitalOcean Spaces. Dynamic URL resolution resolves to
Storage::disk(config('filesystems.default'))->url($path)seamlessly. - Artisan Importer: Wrote a high-performance console migration utility
php artisan grocerease:migrate-imageswhich scans and transfers legacy files from the old project, uploads them to the active storage disk, and updates DB mappings.
- Smooth Section Scrolling: Integrated direct anchor scroll buttons in the main navigation. Clicking on "Categories", "Brands", or "Contact" smoothly navigates the user using native CSS
scroll-behavior: smooth;layout parameters. - High-Contrast Premium Footer: Redesigned the developer contact block using a high-visibility, deep brand-green linear gradient. Re-engineered typography using highly legible crisp white (
#ffffff) and mint-white (#e8f5e9) text on top of a dark glassmorphic card overlay (rgba(0, 0, 0, 0.22)), yielding perfect readability.
Below is a roadmap of the critical service and controller configurations:
app/
├── Http/
│ ├── Controllers/
│ │ ├── Admin/
│ │ │ ├── DashboardController.php # Business intelligence metrics
│ │ │ ├── ProductController.php # Image resizing CRUD
│ │ │ ├── CategoryController.php # Slugs & Integrity constraints
│ │ │ └── OrderController.php # AJAX status transitions
│ │ └── PaymentController.php # Payment gateway endpoint routes
│ └── Middleware/
│ └── AdminMiddleware.php # Security gatekeeper for admin routes
├── Services/
│ ├── ProductService.php # High-performance catalog filtering
│ ├── CartService.php # Merges guest & authenticated carts
│ ├── OrderService.php # Atomic transactional checkout flow
│ └── PaymentService.php # eSewa v2 signature & Khalti gateway
└── Console/
└── Commands/
└── MigrateImages.php # Bulk legacy image cloud importer
- Homepage (Catalog): http://localhost:8000/
- Product Details:
http://localhost:8000/products/{slug} - Shopping Cart: http://localhost:8000/cart
- Checkout: http://localhost:8000/checkout
- Login / Register: http://localhost:8000/login
- Production URL: https://grocerease.up.railway.app/
- Admin Dashboard: https://grocerease.up.railway.app/admin
Must log in as an administrator (credentials provided below).
- Admin Dashboard: http://localhost:8000/admin
- Product Management: http://localhost:8000/admin/products
- Category Control: http://localhost:8000/admin/categories
- Brand Control: http://localhost:8000/admin/brands
- Order Tracking: http://localhost:8000/admin/orders
If you encounter any unexpected application issues, Laravel stores full stack traces in:
📂 /storage/logs/
- Primary Error Logs File:
storage/logs/laravel.log - Pro-tip: You can tail live errors via console:
tail -f storage/logs/laravel.log