# ngthanhvu/du-an-mau-summer2024 architecture

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

- Interactive diagram: https://gitdiagram.com/ngthanhvu/du-an-mau-summer2024
- Repository: https://github.com/ngthanhvu/du-an-mau-summer2024

## Overview

##### Main Components

a) Client Layer:
- Frontend Views (app/views/home)
- Admin Views (app/views/admin)
- Static Assets (CSS, JS)

b) Application Layer:
- Controllers (AdminController, ViewController)
- Models (Product, User, Cart, Order, etc.)
- Authentication System (including Google OAuth)

c) Data Layer:
- MySQL Database (indicated by duanmau.sql)
- File Storage (uploads directory)

d) External Services:
- Payment Gateway (VNPAY integration)
- Google Authentication
- Email Service (indicated by Mail.php model)

**[Client Tier]**
- ↕
**[Application Tier]**
- ↕
**[Data Tier]**

##### Detailed Component Breakdown

a) Client Tier (Top):
- Subcomponents for each major view (Home, Products, Cart, Checkout, etc.)
- Static asset management

b) Application Tier (Middle):
- Controllers section (showing AdminController and ViewController)
- Models section (showing all model classes)
- Router/Request Handler (.htaccess and index.php)
- Authentication Manager component
- Payment Processing component
- Email Service component

c) Data Tier (Bottom):
- Database component (MySQL)
- File Storage component
- Cache/Session Storage

##### Connection and Flow Representation

- Double lines (⇒) for data flow

##### Additional Elements

- Configuration Management (config directory)
- Third-party Integrations (Google, VNPAY)
- Error Handling (404.html)

##### Notes for Implementation

- The MVC architecture pattern
- Security flow for both public and admin areas
- Integration points with external services
- Data flow between components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef frontend fill:#a8d1ff,stroke:#333
    classDef admin fill:#ffb3d9,stroke:#333
    classDef controller fill:#b3ffb3,stroke:#333
    classDef model fill:#ffd9b3,stroke:#333
    classDef database fill:#d9d9d9,stroke:#333
    classDef external fill:#e6b3ff,stroke:#333
    classDef auth fill:#ffff99,stroke:#333
    classDef config fill:#c2c2d6,stroke:#333

    %% Client Layer
    subgraph ClientLayer
        FE["Frontend Interface"]:::frontend
        AD["Admin Interface"]:::admin
        SA["Static Assets"]:::frontend
    end

    %% Application Layer
    subgraph AppLayer
        %% Controllers
        subgraph Controllers
            MC["Main Controller"]:::controller
            AC["Admin Controller"]:::controller
            VC["View Controller"]:::controller
        end

        %% Models
        subgraph Models
            PM["Product Model"]:::model
            UM["User Model"]:::model
            CM["Cart Model"]:::model
            OM["Order Model"]:::model
            CAT["Category Model"]:::model
            COP["Coupon Model"]:::model
            COM["Comment Model"]:::model
            VM["Views Model"]:::model
            CNT["Count Model"]:::model
        end

        %% Auth System
        subgraph AuthSystem
            GA["Google Auth"]:::auth
            REG["User Registration"]:::auth
            GCONF["Google Config"]:::auth
        end

        %% Payment System
        subgraph PaymentSystem
            PAY["Payment Processing"]:::model
            VNP["VNPAY Integration"]:::model
        end

        %% Email Service
        MAIL["Email Service"]:::model
    end

    %% Data Layer
    subgraph DataLayer
        DB[(MySQL Database)]:::database
        FS["File Storage"]:::database
        DBC["Database Connection"]:::database
    end

    %% Configuration
    subgraph ConfigLayer
        CONF["Main Config"]:::config
        RT["Routing Config"]:::config
    end

    %% External Services
    subgraph ExternalServices
        GGL["Google Services"]:::external
        VNPAY["VNPAY Gateway"]:::external
    end

    %% Relationships
    ClientLayer --> Controllers
    Controllers --> Models
    Models --> DataLayer
    AuthSystem --> ExternalServices
    PaymentSystem --> ExternalServices
    Models --> MAIL
    ConfigLayer --> AppLayer

    %% Click Events
    click FE "https://github.com/ngthanhvu/du-an-mau-summer2024/tree/master/app/views/home/"
    click AD "https://github.com/ngthanhvu/du-an-mau-summer2024/tree/master/app/views/admin/"
    click SA "https://github.com/ngthanhvu/du-an-mau-summer2024/tree/master/app/views/home/includes/css/"
    click MC "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/controllers/Controller.php"
    click AC "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/controllers/AdminController.php"
    click VC "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/controllers/ViewController.php"
    click PM "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Product.php"
    click UM "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/User.php"
    click CM "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Cart.php"
    click OM "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Order.php"
    click CAT "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Category.php"
    click GA "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/google.php"
    click REG "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Register.php"
    click GCONF "https://github.com/ngthanhvu/du-an-mau-summer2024/tree/master/google/"
    click PAY "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Payment.php"
    click VNP "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Vnpay_return.php"
    click DB "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/duanmau.sql"
    click DBC "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/includes/database.php"
    click FS "https://github.com/ngthanhvu/du-an-mau-summer2024/tree/master/uploads/"
    click MAIL "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Mail.php"
    click COP "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Coupon.php"
    click COM "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Comment.php"
    click VM "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Views.php"
    click CNT "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/app/models/Count.php"
    click CONF "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/config/config.php"
    click RT "https://github.com/ngthanhvu/du-an-mau-summer2024/blob/master/.htaccess"
```
