A full-stack e-commerce platform built with Laravel 12, React, and Inertia.js, featuring real-time cart synchronization, live order tracking, and advanced search capabilities.
- Product Search: Powered by Typesense for blazing-fast, typo-tolerant search
- Real-Time Stock Updates: Live product availability broadcasting to all users
- Smart Product Filtering: Category-based filtering with faceted search
- Product Details: Comprehensive product pages with image galleries
- Redis-Based Cart Storage: Lightning-fast cart operations with Redis hash storage
- Real-Time Cart Sync: WebSocket-based cart synchronization across multiple tabs/devices
- Guest to User Cart Migration: Seamless cart merge on login using session-based sync
- Broadcast Cart Events: Live updates on cart add/remove/update actions
- Session & User ID Broadcasting: Dual-channel support for guest and authenticated users
- Real-Time Driver Location: Live GPS tracking with Google Maps integration
- ETA Calculations: Dynamic distance and time estimates
- Delivery Status Broadcasting: Live order status updates via WebSockets
- Multi-Role Order Channels: Secure broadcasting for customers, drivers, and admins
- Order History: Complete order tracking with status timeline
- Multi-Auth System: Laravel Sanctum for API authentication
- Google OAuth: Social login integration with Laravel Socialite
- Role-Based Access Control: Spatie Laravel Permission (Admin, Driver, Customer)
- Secure Sessions: Session-based auth with CSRF protection
- Admin Panel: Full-featured admin panel with Filament 4.0
- Analytics Widgets: Real-time stats (orders, revenue, users, products)
- Chart Visualizations: Orders and revenue trends over time
- Resource Management: CRUD operations for products, orders, users, drivers
- Role-Based Widgets: Admin-only dashboard with permission checks
- Laravel Reverb: WebSocket server for real-time events
- Private Channels: Secure user-specific cart and order channels
- Public Channels: Guest cart broadcasting
- Event Broadcasting:
CartSynced- Cart synchronization across sessionsCartItemAdded/Updated/Removed- Individual cart item changesDriverLocationUpdate- Live driver GPS coordinatesDeliveryStatus- Order status changesStockUpdated- Product availability updates
- Payment Integration: Secure checkout flow
- Order Management: Automated order creation and confirmation
- Stock Management: Real-time inventory updates with Redis caching
- Framework: Laravel 12
- Database: MySQL/PostgreSQL
- Cache & Queue: Redis (Predis client)
- Search Engine: Typesense
- Real-Time: Laravel Reverb (WebSockets)
- Background Jobs: Laravel Horizon (Redis-based queue)
- Authentication: Laravel Sanctum + Laravel Socialite (Google OAuth)
- Permissions: Spatie Laravel Permission
- Admin Panel: Filament 4.0
- Framework: React 18
- Router: Inertia.js 2.0
- Styling: Tailwind CSS 3.0
- UI Components: Headless UI
- Forms: Tailwind Forms
- Build Tool: Vite
- Real-Time: Laravel Echo + Pusher.js
- Search UI: React InstantSearch + Typesense Adapter
- Maps: Google Maps React API
- Notifications: React Toastify
- Development: Laravel Sail (Docker)
- Code Quality: Laravel Pint, PHPUnit
- Logging: Laravel Pail
- Route Generation: Ziggy (Laravel routes in JavaScript)
- Concurrency: Concurrently (multi-process development)
βββ app/
β βββ Events/ # Broadcasting events
β β βββ CartSynced.php # Cart sync across sessions
β β βββ CartItemAdded.php # Cart item events
β β βββ DriverLocationUpdate.php # GPS broadcasting
β β βββ DeliveryStatus.php # Order status updates
β βββ Services/
β β βββ CartService.php # Redis-based cart logic
β β βββ CheckoutService.php # Checkout processing
β βββ Filament/Admin/ # Admin panel
β β βββ Resources/ # CRUD resources
β β βββ Widgets/ # Dashboard widgets
β βββ Http/Controllers/
β βββ CartController.php # Cart operations
β βββ OrderController.php # Order & tracking
β βββ GoogleAuthController.php # OAuth
βββ resources/js/
β βββ Pages/ # Inertia pages
β β βββ Welcome.jsx # Product listing
β β βββ ProductDetail.jsx # Product page
β β βββ Checkout.jsx # Checkout flow
β β βββ CustomerTrack.jsx # Order tracking
β βββ components/
β βββ CartProvider.jsx # Cart state + real-time sync
β βββ StatusProvider.jsx # Order status broadcasting
β βββ StockProvider.jsx # Stock update listener
β βββ ProductHit.jsx # Typesense search results
βββ routes/
βββ channels.php # Broadcast channel authorization
// Dual identifier support: sessionId for guests, userId for authenticated
$identifier = auth()->check() ? 'user:' . auth()->id() : 'session:' . session()->getId();
Redis::hincrby("cart:{$identifier}", $productId, $quantity);// MergeGuestCartOnLogin listener
$guestCart = Redis::hgetall("cart:session:{$oldSessionId}");
foreach ($guestCart as $productId => $qty) {
Redis::hincrby("cart:user:{$userId}", $productId, $qty);
}
Redis::del("cart:session:{$oldSessionId}");// CartSynced event with dual channel support
public function broadcastOn(): array {
if ($this->isAuthenticated) {
return [new PrivateChannel("cart.{$this->identifier}")];
}
return [new Channel("cart.{$this->identifier}")];
}// Real-time GPS updates to customer
broadcast(new DriverLocationUpdate(
$orderId,
['lat' => $lat, 'lng' => $lng, 'eta' => $eta],
$userId
))->toOthers();// Scout searchable configuration
public function toSearchableArray() {
return [
'id' => (string) $this->id,
'name' => $this->name,
'description' => $this->description,
'price' => (float) $this->price,
'category' => $this->category->name,
];
}| Channel | Type | Purpose |
|---|---|---|
cart.{sessionId} |
Public | Guest cart updates |
cart.{userId} |
Private | Authenticated user cart |
order.{userId} |
Private | Order status & driver location |
- Redis Caching: Cart data, driver locations, ETA calculations
- Lazy Loading: Optimized React component loading
- Queue Processing: Background jobs with Horizon
- Typesense Indexing: Sub-50ms search responses
- WebSocket Persistence: Maintained connections for real-time updates
- PHP 8.2+
- Node.js 18+
- Redis
- MySQL/PostgreSQL
- Typesense Server
- Clone the repository
git clone <repository-url>
cd ecommerce_inertia- Install dependencies
composer install
npm install- Environment setup
cp .env.example .env
php artisan key:generate- Configure services
# Database
DB_CONNECTION=mysql
DB_DATABASE=ecommerce
# Redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
# Typesense
SCOUT_DRIVER=typesense
TYPESENSE_API_KEY=your-api-key
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
# Broadcasting
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=your-app-id
REVERB_APP_KEY=your-app-key
REVERB_APP_SECRET=your-app-secret
# Google OAuth
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret- Database migration & seeding
php artisan migrate --seed- Index products in Typesense
php artisan scout:import "App\Models\Product"- Build frontend assets
npm run buildRun all services concurrently:
composer devThis starts:
- Laravel server (
php artisan serve) - Queue worker (
php artisan queue:listen) - Vite dev server (
npm run dev) - Pail logger (
php artisan pail)
Or run individually:
# Terminal 1: Backend
php artisan serve
# Terminal 2: Reverb WebSocket
php artisan reverb:start
# Terminal 3: Queue worker
php artisan queue:work
# Terminal 4: Frontend
npm run dev| Role | Permissions |
|---|---|
| Admin | Full dashboard access, manage all resources, view analytics |
| Driver | Update delivery status, share GPS location |
| Customer | Browse products, manage cart, place orders, track deliveries |
- Customer Journey: Browse β Search β Add to Cart β Login (cart merges) β Checkout β Track Order
- Driver Workflow: Accept order β Update location β Mark delivered
- Admin Operations: Monitor sales β Manage inventory β View analytics
- Payment gateway integration (Stripe/PayPal)
- Multi-vendor support
- Product reviews & ratings
- Wishlist functionality
- Email notifications
- SMS order updates
- Advanced analytics dashboard
This project is open-sourced software licensed under the MIT license.
Contributions, issues, and feature requests are welcome!
Built with β€οΈ using Laravel, React, TypeSense, and Redis