# fayroozh/laravel-shop architecture

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

- Interactive diagram: https://gitdiagram.com/fayroozh/laravel-shop
- Repository: https://github.com/fayroozh/laravel-shop

## Overview

##### Project type and purpose
- This is a full-stack e-commerce and inventory management application.
- Backend: Laravel (PHP), exposing both a Blade-based admin dashboard and a REST/JSON API.
- Frontend: React/Vite SPA under the “front” folder, serving the customer storefront and checkout flows.
- Database: relational (MySQL/PostgreSQL) via Eloquent ORM.
- Features: user authentication (Sanctum), product/catalog management, orders, feedback, inventory, reporting, role/permission control, real-time notifications.

##### File structure
- Top level
- app/: Laravel MVC code (Http/Controllers, Models, Middleware, Services, Reports, Notifications)
- resources/views/: Blade templates for admin and auth UI
- front/: React SPA (JSX components, router, state/store, API client)
- public/: entrypoint to PHP app (index.php) and static assets
- database/: migrations & seeders define schema and initial data
- routes/: web.php (Blade/admin UI + API tests), api.php (SPA JSON endpoints)
- Patterns / architecture
- MVC in Laravel: Controllers → Models → Views (Blade)
- Service layer: app/Services and app/Reports encapsulate business logic
- Event/Notification layer: Laravel Notifications queued via app/Notifications
- API layer: routes/api.php + Controllers returning JSON
- SPA layer: React app using a REST API client (Sanctum for auth, axios/fetch in front/src/services/api-client.js)

##### README for additional insights
- Standard Laravel framework boilerplate README (doesn’t include specifics).
- We infer tech stack: PHP 8+, Laravel, MySQL, Redis/queue (maybe), Vite, React, Tailwind CSS.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Customer Frontend (React SPA)" 
        direction TB
        SPA["React SPA"]:::frontend
        Router["SPA Router\n(front/src/main.jsx,\nfront/src/router/router.jsx)"]:::frontend
        Store["State Management & Auth Store\n(front/src/app/store.js,\nfront/src/app/authStore.js)"]:::frontend
        APIClient["SPA API Client\n(front/src/services/api-client.js)"]:::frontend
        subgraph "Checkout Flow Components"
            direction TB
            Checkout["Checkout Components\n(front/src/Checkout/*)"]:::frontend
        end
        subgraph "Product Components"
            direction TB
            Products["Product Listing & Details\n(front/src/Home/*,\nfront/src/Products/*)"]:::frontend
        end
        subgraph "Authentication Pages"
            direction TB
            AuthPages["Auth Pages\n(front/src/auth/LoginPage.jsx,\nRegisterPage.jsx,\nProfilePage.jsx)"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Laravel Application)" 
        direction TB
        WebRoutes["Web Routes & API Tests\n(routes/web.php)"]:::backend
        BladeViews["Blade Admin Dashboard Views\n(resources/views/admin/*)"]:::backend
        AuthView["Auth Login View\n(resources/views/auth/login.blade.php)"]:::backend
        APIControllers["API Controllers\n(routes/api.php + app/Http/Controllers/*Controller.php)"]:::backend
        AuthController["Auth Controller\n(app/Http/Controllers/AuthController.php)"]:::backend
        subgraph "Service Layer"
            direction TB
            ActivityLogger["ActivityLogger Service\n(app/Services/ActivityLogger.php)"]:::backend
        end
        subgraph "Reports Modules"
            direction TB
            Reports["Reports Generation\n(app/Reports/*)"]:::backend
        end
        subgraph "Notification & Queue Subsystem"
            direction TB
            Notifications["Notifications\n(app/Notifications/*)"]:::backend
            QueueConfig["Queue Config\n(config/queue.php)"]:::backend
        end
        subgraph "Middleware"
            direction TB
            Middleware["Auth & Permission Middleware\n(app/Http/Middleware/*)"]:::backend
        end
        subgraph "Providers & Kernel"
            direction TB
            Providers["Service Providers\n(app/Providers/*)"]:::backend
            Kernel["HTTP Kernel\n(app/Http/Kernel.php)"]:::backend
        end
    end

    %% Database
    subgraph "Database" 
        direction TB
        DB["Relational DB\n(MySQL/PostgreSQL)"]:::db
        Migrations["Migrations & Seeders\n(database/migrations/*,\ndatabase/seeders/*)"]:::db
    end

    %% External Services
    subgraph "External Services & Queues"
        direction TB
        QueueBroker["Queue Broker\n(Redis/Beanstalkd)"]:::external
        MailSMS["Email/SMS Gateway\n(Mail driver, Twilio)"]:::external
        SocialAuth["Third-party Auth Providers"]:::external
    end

    %% Entrypoint
    PublicIndex["Public Entrypoint\n(public/index.php)"]:::backend

    %% Connections
    SPA -->|renders| Router
    SPA -->|uses| Store
    SPA -->|calls| APIClient
    APIClient -->|HTTPS/JSON| APIControllers
    APIClient -->|auth via Sanctum| AuthController
    AuthController -->|renders| AuthView
    WebRoutes -->|serves| BladeViews
    BladeViews -->|form submissions| APIControllers
    APIControllers -->|calls| ActivityLogger
    APIControllers -->|calls| Reports
    APIControllers -->|triggers| Notifications
    Notifications -->|push to| QueueBroker
    QueueBroker -->|delivers| MailSMS
    APIControllers -->|DB queries| DB
    ActivityLogger -->|DB writes| DB
    Reports -->|DB reads| DB
    Migrations -->|DB setup| DB
    Providers -->|registers| Middleware
    Kernel -->|applies| Middleware
    PublicIndex -->|bootstraps| WebRoutes
    PublicIndex -->|bootstraps| APIControllers
    SocialAuth -->|used by| AuthController

    %% Click Events
    click SPA "https://github.com/fayroozh/laravel-shop/tree/main/front/src"
    click Router "https://github.com/fayroozh/laravel-shop/blob/main/front/src/main.jsx"
    click Router "https://github.com/fayroozh/laravel-shop/blob/main/front/src/router/router.jsx"
    click Store "https://github.com/fayroozh/laravel-shop/blob/main/front/src/app/store.js"
    click Store "https://github.com/fayroozh/laravel-shop/blob/main/front/src/app/authStore.js"
    click APIClient "https://github.com/fayroozh/laravel-shop/blob/main/front/src/services/api-client.js"
    click Checkout "https://github.com/fayroozh/laravel-shop/tree/main/front/src/Checkout"
    click Products "https://github.com/fayroozh/laravel-shop/tree/main/front/src/Home"
    click Products "https://github.com/fayroozh/laravel-shop/tree/main/front/src/Products"
    click AuthPages "https://github.com/fayroozh/laravel-shop/blob/main/front/src/auth/LoginPage.jsx"
    click AuthPages "https://github.com/fayroozh/laravel-shop/blob/main/front/src/auth/RegisterPage.jsx"
    click AuthPages "https://github.com/fayroozh/laravel-shop/blob/main/front/src/auth/ProfilePage.jsx"
    click APIControllers "https://github.com/fayroozh/laravel-shop/blob/main/routes/api.php"
    click APIControllers "https://github.com/fayroozh/laravel-shop/tree/main/app/Http/Controllers"
    click BladeViews "https://github.com/fayroozh/laravel-shop/tree/main/resources/views/admin"
    click WebRoutes "https://github.com/fayroozh/laravel-shop/blob/main/routes/web.php"
    click AuthController "https://github.com/fayroozh/laravel-shop/blob/main/app/Http/Controllers/AuthController.php"
    click AuthView "https://github.com/fayroozh/laravel-shop/blob/main/resources/views/auth/login.blade.php"
    click ActivityLogger "https://github.com/fayroozh/laravel-shop/blob/main/app/Services/ActivityLogger.php"
    click Reports "https://github.com/fayroozh/laravel-shop/tree/main/app/Reports"
    click Notifications "https://github.com/fayroozh/laravel-shop/tree/main/app/Notifications"
    click QueueConfig "https://github.com/fayroozh/laravel-shop/blob/main/config/queue.php"
    click Middleware "https://github.com/fayroozh/laravel-shop/tree/main/app/Http/Middleware"
    click Providers "https://github.com/fayroozh/laravel-shop/tree/main/app/Providers"
    click Kernel "https://github.com/fayroozh/laravel-shop/blob/main/app/Http/Kernel.php"
    click Migrations "https://github.com/fayroozh/laravel-shop/tree/main/database/migrations"
    click Migrations "https://github.com/fayroozh/laravel-shop/tree/main/database/seeders"
    click PublicIndex "https://github.com/fayroozh/laravel-shop/blob/main/public/index.php"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#E6FFEA,stroke:#28a745,color:#155724
    classDef db fill:#FFF5E6,stroke:#d39e00,color:#856404
    classDef external fill:#F0F0F0,stroke:#6c757d,color:#343a40
```
