# adamsallehleanis/leanx architecture

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

- Interactive diagram: https://gitdiagram.com/adamsallehleanis/leanx
- Repository: https://github.com/adamsallehleanis/leanx

## Overview

##### Main Components

a) Core Components:
- WordPress Core
- WooCommerce Plugin
- LeanX Payment Gateway Plugin
- LeanX Payment API (External Service)

b) Plugin Internal Components:
- Gateway Class (class-leanx-gateway.php)
- Admin Interface (leanx-admin-page.php)
- Order Management System (leanx-pending-orders-handler.php)
- Payment Processing System
- Verification System (verification.php)

**[User Layer]**

**[WordPress Layer]**

**[WooCommerce Layer]**

**[LeanX Plugin Layer]**

**[External Services Layer]**

##### Component Relationships to Highlight

a) Data Flow:
- Order status updates flowing back through the system
- Admin configuration flow

b) Integration Points:
- WooCommerce Payment Gateway Hook Points
- WordPress Admin Interface Integration
- LeanX API Communication Points

##### Specific Elements

a) Payment Processing Flow:
**[Checkout] → [Gateway Class] → [Verification] → [LeanX API]**
- ↓
- [Order Handler] → [Database]

b) Admin Configuration:
**[WordPress Admin] → [LeanX Settings] → [Configuration Storage]**

##### Important Technical Details to Note

- Sandbox/production environment switch
- Authentication flow (Auth Token, Hash Key)
- Invoice generation system
- Order status management flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef wordpress fill:#4584b6,color:white
    classDef woocommerce fill:#96588a,color:white
    classDef plugin fill:#2ecc71,color:white
    classDef external fill:#e67e22,color:white
    classDef database fill:#95a5a6,color:white
    classDef template fill:#3498db,color:white

    %% User Layer
    User[Customer Browser]

    %% WordPress Layer
    subgraph WP[WordPress System]
        WPCore[WordPress Core]:::wordpress
        WPAdmin[WordPress Admin]:::wordpress
    end

    %% WooCommerce Layer
    subgraph WC[WooCommerce System]
        WCCore[WooCommerce Core]:::woocommerce
        Checkout[Checkout Process]:::woocommerce
        Orders[Order Management]:::woocommerce
    end

    %% LeanX Plugin Layer
    subgraph LX[LeanX Plugin]
        MainPlugin[Plugin Entry Point]:::plugin
        Gateway[Gateway Class]:::plugin
        Admin[Admin Interface]:::plugin
        OrderHandler[Order Handler]:::plugin
        Verify[Verification System]:::plugin
        PayProcess[Payment Processor]:::plugin
        Invoice[Invoice Management]:::plugin
        Template[Payment Template]:::plugin
        Lang[Localization]:::plugin
        Table[Admin Table]:::plugin
        Graph[Graph Visualization]:::plugin
    end

    %% External Layer
    LeanXAPI[LeanX Payment API]:::external
    DB[(Database)]:::database

    %% Relationships
    User --> Checkout
    Checkout --> Gateway
    Gateway --> Verify
    Verify --> LeanXAPI
    Gateway --> OrderHandler
    OrderHandler --> DB
    WPAdmin --> Admin
    Admin --> Gateway
    PayProcess --> LeanXAPI
    OrderHandler --> Invoice
    Gateway --> Template
    Admin --> Table
    Table --> Graph

    %% Click Events
    click Gateway "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/class-leanx-gateway.php"
    click Admin "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/leanx-admin-page.php"
    click OrderHandler "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/leanx-pending-orders-handler.php"
    click Verify "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/verification.php"
    click PayProcess "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/leanx-functions.php"
    click Invoice "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/invoice_column_functions.php"
    click Template "https://github.com/AdamSallehLeanis/leanx/blob/main/templates/leanx-payment-success.php"
    click Lang "https://github.com/AdamSallehLeanis/leanx/blob/main/languages/leanx-en_US.mo"
    click MainPlugin "https://github.com/AdamSallehLeanis/leanx/blob/main/leanx-woocomerce.php"
    click Table "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/leanx-table.php"
    click Graph "https://github.com/AdamSallehLeanis/leanx/blob/main/includes/draw_graph.js"

    %% Legend
    subgraph Legend
        L1[WordPress Components]:::wordpress
        L2[WooCommerce Components]:::woocommerce
        L3[Plugin Components]:::plugin
        L4[External Services]:::external
        L5[(Database)]:::database
    end
```
