# yosp313/ecommerce-system-laravel architecture

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

- Interactive diagram: https://gitdiagram.com/yosp313/ecommerce-system-laravel
- Repository: https://github.com/yosp313/ecommerce-system-laravel

## Overview

##### Main Components

a) Client Layer:
- GraphQL API Endpoints
- Web Interface (indicated by resources/views)
- External Client Applications (that would consume the GraphQL API)

b) Application Layer:
- GraphQL Layer (Mutations & Queries)
- HTTP Controllers
- Authentication & Authorization
- Job Processing System
- Mail System

c) Domain Layer:
- Models
- Business Logic
- Services

d) Infrastructure Layer:
- Database
- Cache System
- Queue System
- File Storage
- Email Service

**[Client Applications] ←→ [GraphQL/HTTP API Layer]**
- ↓
**[Application Services Layer]**
- ↓
**[Domain Layer]**
- ↓
**[Infrastructure Layer]**

##### Detailed Component Breakdown

a) API Layer (Top):
- GraphQL endpoint handling mutations (AddToCart, CreateOrder, etc.)
- REST endpoints for admin functions
- Authentication middleware

b) Application Services (Middle):
- Order Processing Flow
- Cart Management
- User Management
- Payment Processing
- Admin Reporting System

c) Domain Layer:
- Relationships between key models:
- User → Cart → CartItems → Products
- Order → OrderItems → Products
- User → Addresses
- User → PaymentMethods

d) Infrastructure (Bottom):
- Database (MySQL/PostgreSQL)
- Redis for cache/queue
- SMTP for emails
- File storage system

##### Specific Flows

a) Order Processing:
**Client → GraphQL CreateOrder Mutation → Order Processing Service →**
**Database → Queue (OrderConfirmation) → Email Service**

b) Cart Management:
**Client → AddToCart Mutation → Cart Service → Database**

c) Admin Reporting:
**Scheduled Task → DailyOrdersReport Command →**
**Export Service → Email Service**

##### Additional Elements

- Version information and key technologies
- External service integrations
- Scalability points

##### Technical Stack Callouts

- Laravel Framework
- GraphQL (via Lighthouse)
- Queue System
- Mail System
- Database
- Cache Layer
- Authentication (Sanctum)

For this specific e-commerce application, pay special attention to:
- The separation between GraphQL and REST endpoints
- The order processing flow
- Cart management system
- Authentication and authorization boundaries
- Asynchronous processing of reports and notifications

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL[Client Layer]
        WEB[Web Interface]
        MOB[Mobile Apps]
        EXT[External Clients]
    end

    %% API Layer
    subgraph API[API Layer]
        GQL[GraphQL API]:::api
        click GQL "https://github.com/yosp313/ecommerce-system-laravel/blob/master/graphql/schema.graphql"
        
        subgraph Resolvers
            MUT[Mutations]:::api
            QRY[Queries]:::api
            click MUT "https://github.com/yosp313/ecommerce-system-laravel/tree/master/app/GraphQL/Mutations/"
            click QRY "https://github.com/yosp313/ecommerce-system-laravel/tree/master/app/GraphQL/Queries/"
        end
    end

    %% Application Layer
    subgraph APP[Application Layer]
        subgraph Controllers
            PCTRL[Product Controller]:::controller
            OCTRL[Order Controller]:::controller
            CCTRL[Category Controller]:::controller
            click PCTRL "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Http/Controllers/ProductController.php"
            click OCTRL "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Http/Controllers/OrderController.php"
            click CCTRL "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Http/Controllers/CategoryController.php"
        end

        subgraph Auth
            AUTH[Authentication]:::auth
            ADMW[Admin Middleware]:::auth
            click AUTH "https://github.com/yosp313/ecommerce-system-laravel/blob/master/config/auth.php"
            click ADMW "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Http/Middleware/AdminAuthMiddleware.php"
        end
    end

    %% Domain Layer
    subgraph DOM[Domain Layer]
        subgraph Models
            USER[User]:::model
            PROD[Product]:::model
            CAT[Category]:::model
            CART[Cart]:::model
            ORD[Order]:::model
            PAY[Payment]:::model
            ADDR[Address]:::model
            click USER "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/User.php"
            click PROD "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/Product.php"
            click CAT "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/Category.php"
            click CART "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/Cart.php"
            click ORD "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/Order.php"
            click PAY "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/PaymentMethod.php"
            click ADDR "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Models/Address.php"
        end
    end

    %% Infrastructure Layer
    subgraph INF[Infrastructure Layer]
        subgraph Background
            JOBS[Job Processing]:::infra
            QUEUE[Queue System]:::infra
            DAILY[Daily Reports Job]:::infra
            click JOBS "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Jobs/DailyOrdersReportJob.php"
            click QUEUE "https://github.com/yosp313/ecommerce-system-laravel/blob/master/config/queue.php"
            click DAILY "https://github.com/yosp313/ecommerce-system-laravel/blob/master/app/Console/Commands/DailyOrdersReport.php"
        end

        subgraph Storage
            DB[(Database)]:::infra
            CACHE[(Cache)]:::infra
            click DB "https://github.com/yosp313/ecommerce-system-laravel/blob/master/config/database.php"
            click CACHE "https://github.com/yosp313/ecommerce-system-laravel/blob/master/config/cache.php"
        end

        subgraph Notifications
            MAIL[Mail System]:::infra
            MTEMP[Email Templates]:::infra
            click MAIL "https://github.com/yosp313/ecommerce-system-laravel/blob/master/config/mail.php"
            click MTEMP "https://github.com/yosp313/ecommerce-system-laravel/tree/master/resources/views/mail/"
        end
    end

    %% Clear Relationships with Labels
    CL -->|"API Requests"| API
    API -->|"Process Requests"| APP
    APP -->|"Data Operations"| DOM
    DOM -->|"Storage & Services"| INF
    JOBS -->|"Send Notifications"| MAIL
    AUTH -->|"Validate Access"| DOM

    %% Styles with Distinct Colors
    classDef api fill:#2196F3,stroke:#1976D2,color:white
    classDef controller fill:#4CAF50,stroke:#388E3C,color:white
    classDef model fill:#FF9800,stroke:#F57C00,color:white
    classDef auth fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef infra fill:#607D8B,stroke:#455A64,color:white

    %% Clear Legend
    subgraph Legend
        API_L[API Components]:::api
        CTRL_L[Controllers]:::controller
        MOD_L[Models]:::model
        AUTH_L[Auth Components]:::auth
        INFRA_L[Infrastructure]:::infra
    end
```
