How sunwarul/ecommerce works
Project type and purpose
• This is a full-stack web application built on Laravel (PHP) with Inertia.js/Vue for the frontend.
• It provides two main web interfaces:
– Customer-facing website (landing pages, catalog, cart/checkout)
– Admin panel (product, inventory, user, order, POS management)
• It also exposes a REST API for mobile/third-party integrations.
• Features include multi-currency payments, role/permission, file exports, job queues, real-time notifications, etc.
File structure
• app/Http/Controllers/*
– Admin web controllers (app/Http/Controllers/Admin)
– Frontend/Inertia controllers (app/Http/Controllers/Frontend)
– API controllers (app/Http/Controllers/Api)
– Auth controllers (app/Http/Controllers/Auth)
• app/Services + app/Interfaces
– Business logic abstraction (Service layer)
– Interfaces for decoupling and testability
• app/Models
– Eloquent ORM Data layer
• resources/js
– Inertia/Vue pages & components (Layouts, Pages/Admin, Pages/Frontend, Pages/Auth)
• routes/*.php
– api.php for JSON API
– web.php & auth.php for browser routes
• infrastructure
– Docker (docker-compose.yml, Dockerfile)
– nginx config
– Redis (cache/queue), MySQL/Postgres, filesystem (public/, storage/)
• docs/REST_API – Postman/HTTP request definitions
• queue workers, schedulers (via artisan commands, supervisor)
README for additional insights
• Multi-tenant, multi-vendor vision (future expansion)
• POS and plugin modules planned
• Devops: Docker, CI/CD pipelines, monitoring (Sentry, Telescope), End-to-end tests
• Payment gateways: Stripe, SSLCommerz, Paddle, etc.
Components
A. Client Tier
• Browser (Customer website)
• Browser (Admin panel)
• Mobile App / Third-party Clients (via REST API)
B. Edge & Ingress
• DNS / Load Balancer
• Nginx (Docker container)
C. Application Tier
• PHP-FPM / Laravel app server
• Inertia.js server-side rendering bridge
• Controllers → Services → Repositories/Models
• Artisan queue workers & schedulers
D. Data Tier
• Relational Database (MySQL or Postgres)
• Redis (cache, session store, queue backend)
• File storage (Local or S3 for exports, uploads)
E. External Integrations
• Payment gateways (Stripe, Razorpay, etc)
• Email/SMS providers (Mailgun, AWS SES, Twilio)
• Notification channels (WebSockets/Pusher for real-time)
• Monitoring & Logging (Sentry, Slack notifications)
• CDN (for static assets)
F. DevOps & CI/CD (side note)
• Docker registry, GitHub Actions → staging/production
Relationships & data flows
– Browser → Load Balancer → Nginx → Laravel (web routes) → Controllers → Services → Models → DB
– Laravel → Redis (get/set cache, queue push/pop)
– Laravel → Redis Queue Worker → Job → external API (email, payment) → DB
– Mobile App → Nginx → Laravel (API routes) → JSON Responses
– Laravel → External Payment Gateway → Callbacks → Controllers → Services
Architectural patterns & principles
• MVC pattern (Controllers, Models, Views via Inertia)
• Service layer with Interfaces → decoupled business logic
• Repository/Model layer (Eloquent)
• Inertia.js as a “shared-state” SPA approach (no JSON API for web UI)
• Dockerized 12-factor app (config via env, stateless containers)
• CQRS for exports/generators (app/Exports, app/Generators)
• Event/Queue-based async processing (Notifications, file export)