WooAI Chatbot Pro - Developer Documentation

Comprehensive technical documentation for developers working with WooAI Chatbot Pro WordPress plugin.

Version: 0.2.1 Last Updated: December 2024 Minimum Requirements: PHP 8.1+, WordPress 6.6+, WooCommerce 8.0+


Documentation Index

# Document Description
00 Quick Reference START HERE - Cheatsheet for fast lookup
01 Architecture Overview High-level architecture, design patterns, and system components
02 API Reference Complete REST API documentation with endpoints and examples
03 Hooks & Filters WordPress hooks used and provided, extension points
04 Database Schema Custom tables, options, transients, and data models
05 Frontend Development React/TypeScript architecture, components, and build system
06 AI Integration Multi-provider AI system, tools, and RAG implementation
07 Testing Guide PHPUnit, Jest, Playwright testing frameworks and practices
08 Contributing Development setup, code standards, and contribution workflow
09 Troubleshooting Common issues, debugging, error codes
10 Security Guide Security best practices, input validation, CSRF
11 Changelog & Migration Version history, upgrade guides, deprecations

Quick Start

Prerequisites

Development Setup

# Clone repository
git clone https://github.com/LeoWebMarketing/WP_plugin_chat_ai.git
cd WP_plugin_chat_ai

# Install PHP dependencies
composer install

# Install Node dependencies
npm install

# Build assets (development)
npm run dev

# Build assets (production)
npm run build

Environment Configuration

Create a .env file in the plugin root:

# AI Provider API Keys (at least one required)
OPENAI_API_KEY=sk-...
CLAUDE_API_KEY=sk-ant-...
GEMINI_API_KEY=AIza...

# Supabase RAG Configuration (optional)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=eyJ...

# Logging
LOG_LEVEL=debug

Architecture at a Glance

┌─────────────────────────────────────────────────────────────────┐
│                        WooAI Chatbot Pro                        │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────┐ │
│  │   Chat Widget   │    │   Admin Panel   │    │  REST API   │ │
│  │  (React/TS)     │    │   (React/TS)    │    │   (PHP)     │ │
│  └────────┬────────┘    └────────┬────────┘    └──────┬──────┘ │
│           │                      │                     │        │
│           └──────────────────────┼─────────────────────┘        │
│                                  ▼                              │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │                     AI Orchestrator                       │  │
│  │  ┌─────────┐  ┌─────────┐  ┌─────────┐  ┌─────────────┐  │  │
│  │  │ Claude  │  │ OpenAI  │  │ Gemini  │  │ Tool System │  │  │
│  │  └─────────┘  └─────────┘  └─────────┘  └─────────────┘  │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                  │                              │
│           ┌──────────────────────┼──────────────────────┐       │
│           ▼                      ▼                      ▼       │
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────┐  │
│  │  RAG/Search     │    │   Playbooks     │    │  Analytics  │  │
│  │  (Supabase)     │    │   (CPT Engine)  │    │  (Tracking) │  │
│  └─────────────────┘    └─────────────────┘    └─────────────┘  │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Components

Backend (PHP)

Component Location Purpose
Plugin Core /includes/class-plugin.php Main singleton, initialization
AI System /includes/AI/ Multi-provider orchestration
Chat Engine /includes/chat/ Message handling, sessions
Playbooks /includes/playbook/ Visual automation workflows
Search/RAG /includes/search/ Semantic search, embeddings
Admin /includes/admin/ Settings, REST APIs
Analytics /includes/analytics/ Event tracking, KPIs

Frontend (React/TypeScript)

Component Location Purpose
Admin Panel /assets/src/admin/ Dashboard, settings UI
Chat Widget /assets/src/chat/ Customer-facing chat
Contexts /assets/src/contexts/ State management
Services /assets/src/services/ API communication

Namespaces

WooAIChatbot\              // Main namespace
├── Admin\                 // Admin panel & REST APIs
├── AI\                    // AI providers & orchestration
│   └── Providers\         // Claude, OpenAI, Gemini
│   └── Tools\             // WooCommerce action tools
├── Chat\                  // Chat engine & widget
├── Search\                // RAG & semantic search
├── Topic\                 // Topic detection & routing
├── Analytics\             // Event tracking
├── Integration\           // WooCommerce hooks
├── License\               // License management
└── Core\                  // Infrastructure (DB, Logger, i18n)

WooAI\Playbook\            // M3 Playbook system
WooAI\Promotion\           // Promotion management

NPM Scripts

npm run dev          # Development build with watch
npm run build        # Production build
npm run typecheck    # TypeScript type checking
npm run lint         # ESLint with auto-fix
npm run lint:check   # ESLint check only
npm run test         # Jest unit tests
npm run test:watch   # Jest watch mode
npm run test:coverage # Jest with coverage
npm run clean        # Remove build artifacts

Composer Scripts

composer phpcs       # PHP CodeSniffer check
composer phpcbf      # PHP CodeSniffer auto-fix
composer test        # PHPUnit tests

Support & Resources


License

This plugin is licensed under GPL-3.0+.