# sunwarul/ecommerce architecture

> Architecture diagram of the GitHub repository sunwarul/ecommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sunwarul/ecommerce
- Repository: https://github.com/sunwarul/ecommerce

## Overview

##### 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)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        CustomerBrowser["Customer Website"]:::frontend
        AdminBrowser["Admin Panel"]:::admin
        MobileClient["Mobile/Third‐party Client"]:::frontend
    end

    %% Edge & Ingress
    subgraph "Edge & Ingress"
        direction TB
        DNSLB["DNS / Load Balancer"]:::backend
        NGINX["Nginx (Docker)"]:::backend
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        LaravelApp["Laravel App Server"]:::backend
        InertiaBridge["Inertia.js Bridge"]:::backend
        Controllers["Controllers"]:::backend
        Services["Service Layer"]:::backend
        Interfaces["Interfaces"]:::backend
        Models["Eloquent Models"]:::backend
        Queue["Queue Workers & Schedulers"]:::backend
        RoutesAuth["Routes & Auth"]:::backend
        Exports["Exports & Code Generation"]:::backend
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        DB["MySQL/Postgres Database"]:::datastore
        Redis["Redis Cache/Queue"]:::datastore
        Storage["File Storage (Local/S3)"]:::datastore
    end

    %% External Integrations
    subgraph "External Integrations"
        direction TB
        Payment["Payment Gateways"]:::external
        Notification["Email/SMS & Notifications"]:::external
        CDN["CDN (Static Assets)"]:::external
        DevOps["DevOps & CI/CD"]:::external
    end

    %% Connections
    CustomerBrowser -->|HTTPS Request| DNSLB
    AdminBrowser -->|HTTPS Request| DNSLB
    MobileClient -->|HTTPS Request| DNSLB

    DNSLB --> NGINX
    NGINX --> LaravelApp

    LaravelApp --> InertiaBridge
    InertiaBridge --> Controllers
    Controllers --> Services
    Services --> Interfaces
    Interfaces --> Models
    Models --> DB

    LaravelApp -->|get/set cache| Redis
    LaravelApp -.->|Queue Job| Queue
    Queue -->|Job Execution| ExternalJobs
    subgraph ExternalJobs[ ]
        Payment
        Notification
    end

    LaravelApp -->|file upload/download| Storage

    MobileClient -->|API Request| Controllers

    Exports -->|CQRS Exports| DB
    RoutesAuth -->|Route Registration| LaravelApp

    DevOps -->|Deploy| NGINX
    DevOps -->|Build| LaravelApp
    DevOps -->|Push Images| DNSLB

    %% Click Events
    click CustomerBrowser "https://github.com/sunwarul/ecommerce/blob/main/resources/js/Pages/Frontend/Welcome.vue"
    click CustomerBrowser "https://github.com/sunwarul/ecommerce/blob/main/app/Http/Controllers/Frontend/WelcomePageController.php"
    click AdminBrowser "https://github.com/sunwarul/ecommerce/tree/main/resources/js/Pages/Admin/"
    click AdminBrowser "https://github.com/sunwarul/ecommerce/tree/main/app/Http/Controllers/Admin/"
    click MobileClient "https://github.com/sunwarul/ecommerce/blob/main/routes/api.php"
    click MobileClient "https://github.com/sunwarul/ecommerce/tree/main/app/Http/Controllers/Api/"
    click NGINX "https://github.com/sunwarul/ecommerce/blob/main/docker/nginx/conf.d/app.conf"
    click NGINX "https://github.com/sunwarul/ecommerce/blob/main/docker/nginx/conf.d/default.conf"
    click DevOps "https://github.com/sunwarul/ecommerce/blob/main/docker-compose.yml"
    click DevOps "https://github.com/sunwarul/ecommerce/tree/main/Dockerfile"
    click DevOps "https://github.com/sunwarul/ecommerce/blob/main/README.md"
    click LaravelApp "https://github.com/sunwarul/ecommerce/blob/main/bootstrap/app.php"
    click LaravelApp "https://github.com/sunwarul/ecommerce/blob/main/public/index.php"
    click LaravelApp "https://github.com/sunwarul/ecommerce/blob/main/app/Http/Kernel.php"
    click InertiaBridge "https://github.com/sunwarul/ecommerce/blob/main/resources/js/bootstrap.js"
    click InertiaBridge "https://github.com/sunwarul/ecommerce/blob/main/app/Http/Middleware/HandleInertiaRequests.php"
    click Controllers "https://github.com/sunwarul/ecommerce/tree/main/app/Http/Controllers/"
    click Services "https://github.com/sunwarul/ecommerce/tree/main/app/Services/"
    click Interfaces "https://github.com/sunwarul/ecommerce/tree/main/app/Interfaces/"
    click Models "https://github.com/sunwarul/ecommerce/tree/main/app/Models/"
    click Queue "https://github.com/sunwarul/ecommerce/blob/main/config/queue.php"
    click DB "https://github.com/sunwarul/ecommerce/blob/main/config/database.php"
    click Redis "https://github.com/sunwarul/ecommerce/blob/main/config/cache.php"
    click Redis "https://github.com/sunwarul/ecommerce/blob/main/.env.example"
    click Storage "https://github.com/sunwarul/ecommerce/blob/main/config/filesystems.php"
    click Exports "https://github.com/sunwarul/ecommerce/tree/main/app/Exports/"
    click Exports "https://github.com/sunwarul/ecommerce/tree/main/app/Generators/"
    click Payment "https://github.com/sunwarul/ecommerce/blob/main/app/Services/PaymentService.php"
    click Notification "https://github.com/sunwarul/ecommerce/blob/main/config/services.php"
    click RoutesAuth "https://github.com/sunwarul/ecommerce/blob/main/routes/web.php"
    click RoutesAuth "https://github.com/sunwarul/ecommerce/blob/main/routes/auth.php"

    %% Styles
    classDef frontend fill:#D0E7FF,stroke:#004A99,color:#004A99;
    classDef admin fill:#D0F0FF,stroke:#007BFF,color:#007BFF;
    classDef backend fill:#DFFFE0,stroke:#2E7D32,color:#2E7D32;
    classDef datastore fill:#F0F0F0,stroke:#555555,color:#555555;
    classDef external fill:#FFE0E0,stroke:#C62828,color:#C62828;
```
