# d0mmmm/ecommerce-app architecture

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

- Interactive diagram: https://gitdiagram.com/d0mmmm/ecommerce-app
- Repository: https://github.com/d0mmmm/ecommerce-app

## Overview

##### Identify the Project Type and Purpose
- **Project Type:** Full-stack Ecommerce Application
- **Purpose:** Facilitate online sales and management of cars for a local car shop, including user interactions (browsing, purchasing), admin management (inventory, orders), and payment processing.

##### Analyze the File Structure

**Top-Level Directories and Files:**
- **admin:** Contains assets, backend scripts, configurations, views, and libraries for the admin panel.
- **backend:** Includes PHP scripts handling functionalities like cart management, user authentication, payment processing, and order handling.
- **config:** Configuration files, primarily for database connections.
- **frontend:** PHP files for user-facing pages such as account info, cart, checkout, dashboard, and authentication.
- **includes & user-includes:** Shared components like headers, footers, modals, and sliders.
- **node_modules, vendor, package.json, composer.json:** Dependencies for frontend and backend functionalities.
- **Other Files:** `.gitignore`, `README.md`, and configuration files for development environments.

**Architectural Patterns:**
- **MVC Pattern:** Separation of concerns is evident with distinct frontend and backend directories, admin panel, and shared includes.
- **Client-Server Architecture:** Frontend interacts with backend APIs for data retrieval and actions.
- **Modular Structure:** Organized directories for assets, includes, and libraries promote reusability and scalability.

##### Examine the README for Additional Insights

- **Project Description:** Ecommerce application tailored for a local car shop.
- **Use Cases:** Browsing cars, managing cart, processing payments, admin management of users and orders.
- **Technologies Mentioned:** PHP for backend, JavaScript for frontend interactions, CSS for styling, and various libraries like DataTables and jQuery.

**a. Identify the Main Components:**
- **Frontend:**
- User Interface (UI) Components: Account Info, Cart, Checkout, Dashboard, Login, Register, etc.
- **Backend:**
- PHP Scripts: Handle business logic for user authentication, cart management, order processing, payment integration (GCash, PayPal).
- Database: Manage data related to users, cars, orders, payments.
- **Admin Panel:**
- Admin Backend Scripts: User management, car inventory, order details, revenue tracking.
- Admin Views: Dashboard, edit user, manage cars (Honda, Mitsubishi, Toyota), orders, profiles.
- **Shared Components:**
- Includes: Headers, Footers, Modals, Sliders.
- **External Services:**
- Payment Gateways: GCash, PayPal.
- **Configuration:**
- Database Configuration.
- **Dependencies:**
- Libraries: jQuery, DataTables, Font Awesome.
- Node Modules and Composer Packages.

**b. Determine Relationships and Interactions:**
- **Frontend ↔ Backend:**
- Frontend PHP pages interact with backend PHP scripts via HTTP requests to perform actions like login, cart updates, and order processing.
- **Backend ↔ Database:**
- Backend scripts communicate with the database for CRUD operations on users, cars, and orders.
- **Admin Panel ↔ Backend:**
- Admin views interact with backend scripts to manage the application's data.
- **Frontend ↔ External Services:**
- Payment processing through integration with GCash and PayPal APIs.
- **Shared Components:**
- UI consistency through shared headers, footers, and modals across frontend and admin panels.

**c. Highlight Architectural Patterns or Design Principles:**
- **Separation of Concerns:** Distinct separation between frontend, backend, and admin functionalities.
- **Reusability:** Shared includes and asset directories promote reuse across different parts of the application.
- **Scalability:** Modular structure allows for easy addition of new features or components.

**d. Include Relevant Technologies, Frameworks, or Libraries:**
- **Frontend:**
- HTML, CSS, JavaScript
- jQuery for DOM manipulation
- DataTables for enhanced table functionalities
- **Backend:**
- PHP for server-side scripting
- Composer for dependency management
- **Database:**
- MySQL or similar relational database (inferred from PHP usage)
- **External Services:**
- GCash and PayPal for payment processing

##### Elements

- **Clear Labels for Each Component:**
- Name each part of the system such as Frontend, Backend, Admin Panel, Database, External Services.

**Example:**
- **Frontend Components:** Blue rectangles
- **Backend Services:** Green rectangles

##### Detailed Capture of Architectural Elements

- **Frontend:**
- Pages: Account Info, Cart, Checkout, Dashboard, Login, Register, etc.
- Assets: CSS files, JavaScript files (e.g., cart.js, checkout.js), images.
- **Backend:**
- Scripts: add_to_cart.php, login.php, register.php, process_paypal.php, etc.
- Database: Tables for users, cars, orders, payments.
- **Admin Panel:**
- Scripts: admin_login.php, add_user.php, delete_user.php, etc.
- Views: dashboard.php, manage cars (honda.php, mitsubishi.php, toyota.php), order management.
- **Shared Includes:**
- Headers, footers, modals used across frontend and admin panels.
- **External Integrations:**
- Payment gateways (GCash, PayPal) integrations.
- **Configuration:**
- Database connection files (`config/db.php`).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px
    classDef admin fill:#ffcccb,stroke:#000,stroke-width:1px
    classDef database fill:#f9f,stroke:#000,stroke-width:1px
    classDef external fill:#ffa500,stroke:#000,stroke-width:1px
    classDef shared fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef dependencies fill:#e0e0e0,stroke:#000,stroke-width:1px
    classDef config fill:#ffffe0,stroke:#000,stroke-width:1px

    %% Main Components
    Frontend["Frontend"]:::frontend
    Backend["Backend"]:::backend
    AdminPanel["Admin Panel"]:::admin
    Database[(Database)]:::database
    ExternalServices["Payment Gateways"]:::external
    SharedComponents["Shared Components"]:::shared
    Dependencies["Dependencies"]:::dependencies
    Configuration["Configuration"]:::config

    %% Assets
    Assets["Assets"]:::shared
    AdminAssets["Admin Assets"]:::shared

    %% Subgraphs
    subgraph Frontend_Components
        AccountInfo["Account Info"]:::frontend
        Cart["Cart"]:::frontend
        Checkout["Checkout"]:::frontend
        Dashboard["Dashboard"]:::frontend
        Login["Login"]:::frontend
        Register["Register"]:::frontend
    end

    subgraph Backend_Scripts
        AddToCart["add_to_cart.php"]:::backend
        LoginScript["login.php"]:::backend
        RegisterScript["register.php"]:::backend
        ProcessPayPal["process_paypal.php"]:::backend
        ProcessGCash["process_gcash.php"]:::backend
        VerifyGCashPayment["verify_gcash_payment.php"]:::backend
        VerifyAccount["verifyaccount.php"]:::backend
    end

    subgraph Admin_Backend_Scripts
        AddUser["add_user.php"]:::admin
        AdminLogin["admin_login.php"]:::admin
        DeleteUser["delete_user.php"]:::admin
        FetchData["fetch_data.php"]:::admin
        GetOrderDetails["get_order_details.php"]:::admin
        Honda["honda.php"]:::admin
        Mitsubishi["mitsubishi.php"]:::admin
        Orders["orders.php"]:::admin
        Revenue["revenue.php"]:::admin
        Toyota["toyota.php"]:::admin
        UpdateCar["update_car.php"]:::admin
        UpdateOrderStatus["update_order_status.php"]:::admin
    end

    subgraph Shared_Components
        Includes["includes/"]:::shared
        UserIncludes["user-includes/"]:::shared
        AdminIncludes["admin/include/"]:::shared
    end

    subgraph Dependencies_List
        NodeModules["node_modules/"]:::dependencies
        Vendor["vendor/"]:::dependencies
        PackageJSON["package.json"]:::dependencies
        ComposerJSON["composer.json"]:::dependencies
    end

    %% Connections
    Frontend -->|Uses| AccountInfo
    Frontend -->|Uses| Cart
    Frontend -->|Uses| Checkout
    Frontend -->|Uses| Dashboard
    Frontend -->|Uses| Login
    Frontend -->|Uses| Register
    Frontend -->|Interacts with| Backend

    Backend -->|Handles| AddToCart
    Backend -->|Handles| LoginScript
    Backend -->|Handles| RegisterScript
    Backend -->|Handles| ProcessPayPal
    Backend -->|Handles| ProcessGCash
    Backend -->|Handles| VerifyGCashPayment
    Backend -->|Handles| VerifyAccount
    Backend -->|Communicates with| Database
    Backend -->|Integrates| ExternalServices
    Backend -->|Configures| Configuration
    Backend -->|Depends on| Dependencies_List

    AdminPanel -->|Uses| Admin_Backend_Scripts
    AdminPanel -->|Manages| Backend
    AdminPanel -->|Uses| SharedComponents
    AdminPanel -->|Uses| AdminAssets

    SharedComponents -->|Includes| Includes
    SharedComponents -->|Includes| UserIncludes
    SharedComponents -->|Includes| AdminIncludes

    Dependencies -->|Contains| NodeModules
    Dependencies -->|Contains| Vendor
    Dependencies -->|Contains| PackageJSON
    Dependencies -->|Contains| ComposerJSON

    ExternalServices -->|Processes Payments via| ProcessGCash
    ExternalServices -->|Processes Payments via| ProcessPayPal

    %% Click Events
    click Frontend "https://github.com/d0mmmm/ecommerce-app/tree/master/frontend/"
    click Backend "https://github.com/d0mmmm/ecommerce-app/tree/master/backend/"
    click AdminPanel "https://github.com/d0mmmm/ecommerce-app/tree/master/admin/"
    click Assets "https://github.com/d0mmmm/ecommerce-app/tree/master/assets/"
    click AdminAssets "https://github.com/d0mmmm/ecommerce-app/tree/master/admin/asset/"
    click Includes "https://github.com/d0mmmm/ecommerce-app/tree/master/includes/"
    click UserIncludes "https://github.com/d0mmmm/ecommerce-app/tree/master/user-includes/"
    click AdminIncludes "https://github.com/d0mmmm/ecommerce-app/tree/master/admin/include/"
    click Configuration "https://github.com/d0mmmm/ecommerce-app/blob/master/config/db.php"
    click Configuration "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/config/db.php"
    click Dependencies_List "https://github.com/d0mmmm/ecommerce-app/tree/master/node_modules/"
    click Dependencies_List "https://github.com/d0mmmm/ecommerce-app/tree/master/vendor/"
    click Dependencies_List "https://github.com/d0mmmm/ecommerce-app/blob/master/package.json"
    click Dependencies_List "https://github.com/d0mmmm/ecommerce-app/blob/master/composer.json"
    click ProcessGCash "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/process_gcash.php"
    click ProcessPayPal "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/process_paypal.php"
    click VerifyGCashPayment "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/verify_gcash_payment.php"
    click VerifyAccount "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/verifyaccount.php"
    click AddUser "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/add_user.php"
    click AdminLogin "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/admin_login.php"
    click DeleteUser "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/delete_user.php"
    click FetchData "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/fetch_data.php"
    click GetOrderDetails "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/get_order_details.php"
    click Honda "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/honda.php"
    click Mitsubishi "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/mitsubishi.php"
    click Orders "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/orders.php"
    click Revenue "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/revenue.php"
    click Toyota "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/toyota.php"
    click UpdateCar "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/update_car.php"
    click UpdateOrderStatus "https://github.com/d0mmmm/ecommerce-app/blob/master/admin/backend/update_order_status.php"
    click AddToCart "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/add_to_cart.php"
    click LoginScript "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/login.php"
    click RegisterScript "https://github.com/d0mmmm/ecommerce-app/blob/master/backend/register.php"

    %% Styles
    class AccountInfo,Cart,Checkout,Dashboard,Login,Register frontend
    class AddToCart,LoginScript,RegisterScript,ProcessPayPal,ProcessGCash,VerifyGCashPayment,VerifyAccount backend
    class AddUser,AdminLogin,DeleteUser,FetchData,GetOrderDetails,Honda,Mitsubishi,Orders,Revenue,Toyota,UpdateCar,UpdateOrderStatus admin
    class Database database
    class ExternalServices external
    class Includes,UserIncludes,AdminIncludes shared
    class Assets,AdminAssets shared
    class NodeModules,Vendor,PackageJSON,ComposerJSON dependencies
    class Configuration config
```
