# tranquockhanhdev/ecommerce-fashion architecture

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

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

## Overview

The Synergy 4.0 project is a full-featured e-commerce website built on the Laravel Framework. Its purpose is to support online fashion stores, handling both customer-facing functionalities (product search, shopping cart, checkout, account management) and admin operations (product, category, order, and customer management). The project follows the Model-View-Controller (MVC) pattern, with distinct directories for controllers (including separate subdirectories for client and admin controllers), models, views, and additional configuration, service, and middleware components.

##### Main components of the system
- Client-side (Frontend):
- Blade templates found under resources/views and public/client (static assets like CSS, JavaScript, images)
- Client controllers and views handling account, shopping cart, product search, checkout, etc.
- Server-side (Backend):
- Laravel Controllers located in app/Http/Controllers, further split between client, admin, and authentication features.
- Models under app/Models that represent the business data (e.g., Account, Article, Order, Product, Category, etc.)
- Services such as VNPayService in app/Services for payment processing.
- Middleware (e.g., RoleMiddleware) to handle authorization and access control.
- Database:
- MySQL as indicated in the README, with migrations under database/migrations and seeders under database/seeders.
- External Services:
- Payment gateways (for example, integration with VNPay)
- Third-party libraries integrated via Composer and Node.js (for frontend builds via Laravel Mix/Vite)

##### Relationships and interactions
- Client (browser) sends requests routed through Laravel’s routing (defined in routes/web.php and routes/console.php).
- Requests are processed by controllers that separate admin and client logic.
- Controllers interact with models to perform CRUD operations on the database.
- Service classes (like VNPayService) are used by controllers to handle external payment processing.
- Middleware intercepts requests to enforce security (authentication and role-based access).
- Views (Blade templates) are used to render the UI for both customer-facing and admin-facing pages.
- Public static assets and storage (files under public/ and storage/) deliver images, CSS, and JavaScript.

##### Architectural patterns and design principles
- MVC architecture: Clear separation between data representation (Models), user interactions (Views), and application logic (Controllers).
- Modular structure: Separation of concerns between admin functionalities and client experiences.
- Service layer abstraction: Payment integration and possibly other business processes encapsulated in dedicated service classes.
- Middleware implementation for security.

- Controller Layer: Split into Admin and Client Controllers.
- Service Layer: Include VNPayService and any other services.
- Model Layer: Include key models (Account, Order, Product, etc.).
- Middleware: Represent RoleMiddleware responsible for securing routes.
- A separate block for the Database (MySQL) that interacts with Models.
- External components such as the payment gateway integration.
- Client sends HTTP requests to the server.
- Controllers receive requests, use middleware for authentication/authorization.
- Controllers interact with Models and Services to retrieve or store data.
- Responses are rendered using Blade Templates and then delivered back to the client.
- Rectangles for controllers and services.
- Rounded rectangles for external services or middleware.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client Browser"]:::frontend
    B["Routing (routes/web.php)"]:::routing

    A -->|"HTTPRequest"| B

    subgraph "Laravel Application"
        direction TB
        C1["Client Controllers"]:::controller
        C2["Admin Controllers"]:::controller
        C3["Auth Controllers"]:::controller
        M["Role Middleware"]:::middleware
        MD["Business Models"]:::model
        S["VNPay Service"]:::service
        V["Blade Templates"]:::view
        SA["Static Assets"]:::asset

        B -->|"Dispatches"| C1
        B --> C2
        B --> C3

        C1 -->|"authCheck"| M
        C2 -->|"authCheck"| M
        C3 -->|"authCheck"| M

        C1 -->|"CRUD"| MD
        C2 -->|"CRUD"| MD
        C3 -->|"CRUD"| MD

        C1 -->|"Payment"| S
        C2 --> S
        C3 --> S

        V -->|"Renders"| A
        SA -->|"Serves"| A

        S -->|"Calls"| E
    end

    subgraph "Database"
        D["MySQL Database"]:::database
        DM["Migrations"]:::database
        DS["Seeders"]:::database
    end

    MD -->|"DBOps"| D
    D -->|"Data"| MD

    E["External Payment Gateway"]:::external

    %% Click Events
    click V "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/resources/views/client"
    click SA "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/public/client"
    click C1 "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/app/Http/Controllers/client"
    click C2 "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/app/Http/Controllers/admin"
    click C3 "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/app/Http/Controllers/Auth"
    click MD "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/app/Models"
    click S "https://github.com/tranquockhanhdev/ecommerce-fashion/blob/master/app/Services/VNPayService.php"
    click M "https://github.com/tranquockhanhdev/ecommerce-fashion/blob/master/app/Http/Middleware/RoleMiddleware.php"
    click B "https://github.com/tranquockhanhdev/ecommerce-fashion/blob/master/routes/web.php"
    click DM "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/database/migrations"
    click DS "https://github.com/tranquockhanhdev/ecommerce-fashion/tree/master/database/seeders"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#000,stroke-width:2px;
    classDef routing fill:#d4edda,stroke:#000,stroke-width:2px;
    classDef controller fill:#fff3cd,stroke:#000,stroke-width:2px;
    classDef middleware fill:#ffeeba,stroke:#000,stroke-width:2px;
    classDef model fill:#d1ecf1,stroke:#000,stroke-width:2px;
    classDef service fill:#f8d7da,stroke:#000,stroke-width:2px;
    classDef view fill:#e2e3e5,stroke:#000,stroke-width:2px;
    classDef asset fill:#e2e3e5,stroke:#000,stroke-width:2px;
    classDef database fill:#d4d4f9,stroke:#000,stroke-width:2px;
    classDef external fill:#fad0c4,stroke:#000,stroke-width:2px;
```
