# coconerd/ibeleaf architecture

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

- Interactive diagram: https://gitdiagram.com/coconerd/ibeleaf
- Repository: https://github.com/coconerd/ibeleaf

## Overview

Based on our analysis of the full file tree and the README, this project is a full-stack e-commerce website (named “iBeleaf”) for selling plants. It uses the Laravel framework to structure its backend code (with MVC–style directories like app/Http/Controllers, app/Models, app/Providers, etc.), integrates with third‐party APIs (for example, GHN for shipping fee calculations), and incorporates a rich frontend built on Blade templates, JavaScript, CSS, and Bootstrap.

##### Main Components
- Client Side (Frontend): Illustrate different web clients such as the customer-facing website (pages like Home, Product Detail, Cart, Checkout, Profile) and the Admin Dashboard. Note that the frontend assets are served from the public directory (assets like CSS, JS, images) and the dynamic content is rendered through Blade views (in resources/views).
- Backend Server: Represent the Laravel application as the core engine. Within this layer, include:
– HTTP Layer: Controllers (both customer-facing and admin controllers in app/Http/Controllers) and Middleware (located under app/Http/Middleware for authentication, role checking, CSRF protection, etc.).
– Application Layer: Business logic implemented in Services (app/Services such as OrderService, ShippingService, FeedbackService, GHNService) and Service Providers (which bootstrap core dependencies).
– Domain Layer: Models (e.g., Product, Order, Cart, Voucher, User) representing the core data and business entities.
– Console/Commands: For scheduled or background tasks (e.g., GenerateProvinceData.php).
- Database: Represent a MySQL (or similar) database layer which stores user data, product catalogs, orders, vouchers, and other transactional records. Note that migrations and seeders (in database/migrations and database/seeders) clearly define the database schema.
- External Services & Integrations:
– OAuth Services: External authentication providers (Google, Facebook) for login functionality.
– Email/Notification Service: Indicate the notification layer (emails sent on order updates, claim statuses) and real-time notifications via websockets.

##### Relationships and Data Flow
- Within the backend, show communication:
– Controllers receive user actions and delegate processing to the appropriate Service classes.
– Service classes interact with Models, which in turn communicate with the Database.
- For admin functions (dashboard, order management, product management), separate out a distinct admin module that communicates with the same business logic but may enforce additional middleware (e.g., CheckRole).

##### Architectural Patterns and Design Principles
- Layered (N-tier/MVC) Architecture: Separate presentation (Blade templates, public assets) from business logic (controllers and services) and persistence (database via Eloquent models).
- Separation of Concerns: Use clear boundaries between services (order management, shipping, feedback) and controllers.
- Modular components: The file tree indicates clear modules for authentication, product catalog, order processing, voucher management, notifications, and exception handling.
- External integrations: Mark integration points to external APIs (like GHN’s shipping API and OAuth providers).

##### Relevant Technologies, Frameworks, & Libraries
- Backend: PHP/Laravel (and its components such as Console, Middleware, Routing, Eloquent ORM).
- Frontend: HTML, CSS, Bootstrap, JavaScript (with vendor scripts noted in the public/assets/vendors and resources/js).
- Database: MySQL (supported by migrations and the provided SQL file “plant_paradise_final.sql”).
- APIs: GHN API for shipping and OAuth2 integrations.
- Real-time: Websocket components (as mentioned in the notifications section of the README).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client Side"
        direction TB
        CustViews["Customer Blade Views"]:::client
        CustAssets["Public Assets (CSS/JS/Images)"]:::client
        AdminViews["Admin Blade Views"]:::client
        AdminCSS["Admin CSS Assets"]:::client
        AdminJS["Admin JS Assets"]:::client
    end

    %% Backend Server
    subgraph "Backend Server"
        direction TB
        %% HTTP Layer
        HTTP["HTTP Layer"]:::backend
        subgraph "HTTP Layer"
            direction TB
            Controllers["Controllers"]:::backend
            Middleware["Middleware"]:::backend
        end
        %% Application Layer
        Application["Application Layer"]:::backend
        subgraph "Application Layer"
            direction TB
            Services["Services"]:::backend
            Providers["Providers"]:::backend
        end
        %% Domain Layer
        Domain["Domain Layer"]:::backend
        subgraph "Domain Layer"
            direction TB
            Models["Models"]:::backend
        end
        Commands["Console/Commands"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        direction TB
        MySQLDB["MySQL Database"]:::database
        Migrations["Migrations"]:::database
        Seeders["Seeders"]:::database
        SQLSchema["SQL Schema File"]:::database
    end

    %% External Services & Integrations
    subgraph "External Services"
        direction TB
        GHNAPI["GHN Shipping API"]:::external
        OAuth["OAuth Providers"]:::external
        Notifications["Email/Notification Service"]:::external
    end

    %% Data Flow Connections
    CustViews -->|"sends request"| Controllers
    CustAssets -->|"sends request"| Controllers
    AdminViews -->|"sends request"| Controllers
    AdminCSS -->|"sends request"| Controllers
    AdminJS -->|"sends request"| Controllers

    Controllers -->|"authenticates"| Middleware
    Controllers -->|"delegates to"| Services
    Services -->|"processes business logic"| Models
    Models -->|"persists data"| MySQLDB

    Services -->|"calls shipping API"| GHNAPI
    Services -->|"calls OAuth"| OAuth
    Services -->|"triggers notifications"| Notifications

    Providers -->|"configures"| Services
    Commands -->|"updates"| MySQLDB

    %% Click Events for Component Mapping
    click CustViews "https://github.com/coconerd/ibeleaf/tree/main/resources/views"
    click CustAssets "https://github.com/coconerd/ibeleaf/tree/main/public/assets"
    click AdminViews "https://github.com/coconerd/ibeleaf/tree/main/resources/views/admin"
    click AdminCSS "https://github.com/coconerd/ibeleaf/tree/main/public/css/admin"
    click AdminJS "https://github.com/coconerd/ibeleaf/tree/main/public/js/admin"
    click Controllers "https://github.com/coconerd/ibeleaf/tree/main/app/Http/Controllers"
    click Middleware "https://github.com/coconerd/ibeleaf/tree/main/app/Http/Middleware"
    click Services "https://github.com/coconerd/ibeleaf/tree/main/app/Services"
    click Providers "https://github.com/coconerd/ibeleaf/tree/main/app/Providers"
    click Models "https://github.com/coconerd/ibeleaf/tree/main/app/Models"
    click Commands "https://github.com/coconerd/ibeleaf/tree/main/app/Console/Commands"
    click Migrations "https://github.com/coconerd/ibeleaf/tree/main/database/migrations"
    click Seeders "https://github.com/coconerd/ibeleaf/tree/main/database/seeders"
    click SQLSchema "https://github.com/coconerd/ibeleaf/blob/main/plant_paradise_final.sql"
    click GHNAPI "https://github.com/coconerd/ibeleaf/blob/main/app/Services/GHNService.php"
    click OAuth "https://github.com/coconerd/ibeleaf/blob/main/config/services.php"
    click Notifications "https://github.com/coconerd/ibeleaf/tree/main/app/Notifications"

    %% Styles
    classDef client fill:#DDEEFF,stroke:#000,stroke-width:1px;
    classDef backend fill:#FFEEAA,stroke:#000,stroke-width:1px;
    classDef database fill:#CCFFCC,stroke:#000,stroke-width:1px;
    classDef external fill:#FFCCCC,stroke:#000,stroke-width:1px;
```
