Skip to content

diggilly/leadflux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ LeadFlux - Multi-Tenant SaaS Lead Recovery Platform

Automate lead qualification, website verification, and WhatsApp outreach at scale


πŸ“‹ Table of Contents


🎯 Overview

LeadFlux is a production-ready, multi-tenant SaaS platform designed to help businesses:

  1. Import leads from Excel/CSV files with intelligent column mapping
  2. Verify websites automatically to qualify leads based on online presence
  3. Send targeted WhatsApp messages via the onhandi.com gateway
  4. Track campaigns with real-time analytics and isolated user workspaces

Built for marketing agencies, sales teams, and entrepreneurs who need to:

  • βœ… Qualify leads at scale without manual research
  • βœ… Personalize outreach based on website status
  • βœ… Maintain data isolation between clients/teams
  • βœ… Scale messaging while avoiding WhatsApp bans

✨ Core Features

πŸ” Lead Import & Verification

  • Smart Excel/CSV Import: Auto-detect columns (Name, Phone, Website)
  • Website Verification Engine:
    • Tests HTTP/HTTPS endpoints
    • Handles Facebook URLs, redirects, and edge cases
    • Returns detailed status: WORKING, NOT_WORKING, NO_WEBSITE, ERROR
  • Live Progress Tracking: Modal with progress bar during bulk verification
  • Verification Results Dashboard: Filterable table with targeting recommendations

🏒 Multi-Tenant SaaS Architecture

  • Complete Data Isolation: Every query scoped to user_id
  • Per-User Workspaces: Custom names, slugs, timezones, branding
  • Subscription System: Free/Starter/Pro/Enterprise plans with feature limits
  • Tenant Settings: Per-user WhatsApp credentials, daily limits, working hours
  • Admin Tools: Database management, migration runner, SQL executor (with safety confirmations)

πŸ‘€ User Experience

  • Modern Responsive UI: Bootstrap 5, custom CSS, mobile-optimized
  • Real-Time Notifications: Toast system for actions, alerts, and system updates
  • Profile Management: Update info, change password, manage preferences
  • Onboarding Flow: 3-step workspace setup with timezone and use-case selection

πŸ” Security & Reliability

  • Authentication: Email/password login with OTP phone verification
  • CSRF Protection: Token validation on all state-changing requests
  • Role-Based Access: Admin vs. regular user permissions
  • Error Handling: Graceful failures with user-friendly messages
  • Logging: Comprehensive activity logs for audit trails

πŸ—οΈ Architecture

/home3/nyumban9/app.onhandi.com/
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”œβ”€β”€ AuthController.php (handles login, register, OTP via middleware)
β”‚   β”‚   β”œβ”€β”€ DashboardController.php
β”‚   β”‚   β”œβ”€β”€ WhatsAppController.php
β”‚   β”‚   β”œβ”€β”€ LeadController.php
β”‚   β”‚   β”œβ”€β”€ CampaignController.php
β”‚   β”‚   β”œβ”€β”€ ContactController.php
β”‚   β”‚   β”œβ”€β”€ HistoryController.php
β”‚   β”‚   β”œβ”€β”€ SettingsController.php
β”‚   β”‚   β”œβ”€β”€ ProfileController.php
β”‚   β”‚   β”œβ”€β”€ DatabaseController.php
β”‚   β”‚   β”œβ”€β”€ CronController.php
β”‚   β”‚   β”œβ”€β”€ NotificationController.php
β”‚   β”‚   β”œβ”€β”€ DatabaseToolsController.php
β”‚   β”‚   β”œβ”€β”€ OnboardingController.php
β”‚   β”‚   β”œβ”€β”€ PromoteController.php
β”‚   β”‚   └── TroubleshootController.php
β”‚   β”‚
β”‚   β”œβ”€β”€ Middleware/
β”‚   β”‚   β”œβ”€β”€ Auth.php (authentication middleware)
β”‚   β”‚   └── Tenant.php (multi-tenant middleware)
β”‚   β”‚
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   β”œβ”€β”€ Lead.php
β”‚   β”‚   β”œβ”€β”€ Campaign.php
β”‚   β”‚   β”œβ”€β”€ Contact.php
β”‚   β”‚   └── Log.php
β”‚   β”‚
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ WhatsAppGateway.php
β”‚   β”‚   β”œβ”€β”€ LeadProcessor.php
β”‚   β”‚   β”œβ”€β”€ MessageTemplates.php
β”‚   β”‚   β”œβ”€β”€ Campaign.php
β”‚   β”‚   β”œβ”€β”€ ExportService.php
β”‚   β”‚   └── WebsiteVerifier.php
β”‚   β”‚
β”‚   β”œβ”€β”€ Views/
β”‚   β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.php (main dashboard layout)
β”‚   β”‚   β”‚   └── auth.php (login/register/OTP layout)
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”‚   └── content.php (main dashboard content with WhatsApp)
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”œβ”€β”€ login.php
β”‚   β”‚   β”‚   β”œβ”€β”€ register.php (if exists, or handled by middleware)
β”‚   β”‚   β”‚   └── verify-otp.php
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ onboarding/
β”‚   β”‚   β”‚   └── index.php
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ marketing/
β”‚   β”‚   β”‚   β”œβ”€β”€ verify.php (import & verify leads)
β”‚   β”‚   β”‚   β”œβ”€β”€ campaigns.php
β”‚   β”‚   β”‚   └── contacts.php
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ settings/
β”‚   β”‚   β”‚   └── index.php
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ profile/
β”‚   β”‚   β”‚   └── index.php
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ history/
β”‚   β”‚   β”‚   └── index.php
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   └── database-tools.php
β”‚   β”‚   β”‚
β”‚   β”‚   └── whatsapp/
β”‚   β”‚       └── sessions.php (if separate page exists)
β”‚   β”‚
β”‚   └── Core/
β”‚       β”œβ”€β”€ Controller.php (base controller with tenant methods)
β”‚       β”œβ”€β”€ Router.php
β”‚       β”œβ”€β”€ Database.php
β”‚       └── Logger.php
β”‚
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ index.php (main entry point with .env loader)
β”‚   β”œβ”€β”€ .htaccess
β”‚   └── assets/ (CSS, JS, images)
β”‚
β”œβ”€β”€ storage/
β”‚   β”œβ”€β”€ logs/
β”‚   β”‚   └── app.log
β”‚   β”œβ”€β”€ cache/
β”‚   β”‚   └── whatsapp/
β”‚   └── exports/
β”‚
β”œβ”€β”€ .env (environment variables)
β”œβ”€β”€ vendor/
└── composer.json

Data Flow

User Uploads Excel
        ↓
LeadController::processMapped()
        ↓
WebsiteVerifier::checkDetailed() β†’ HTTP/HTTPS requests
        ↓
Results saved to `leads` table (scoped to user_id)
        ↓
Dashboard displays user's isolated data
        ↓
[Phase 3] WhatsAppGateway sends messages via onhandi.com API

qualified leads

πŸ“₯ Qualified Leads (88 imported)
β”‚
β”œβ”€πŸ“± STEP 1: WhatsApp Number Verification
β”‚  β”œβ”€ POST to https://tools.onhandi.com/api/number-checker/check
β”‚  β”œβ”€ Batch up to 100 numbers per API call
β”‚  β”œβ”€ Cache results for 24h to avoid redundant checks
β”‚  └─ ONLY proceed if response: {"isValid": true}
β”‚
β”œβ”€πŸ“¨ STEP 2: Send Personalized Messages (Anti-Ban Protected)
β”‚  β”œβ”€ IF website WORKING β†’ 
β”‚  β”‚   "Hi {name}, noticed your site is live! We offer maintenance, SEO, social media management. Interested?"
β”‚  β”œβ”€ IF website MISSING/NOT_WORKING β†’ 
β”‚  β”‚   "Hi {name}, saw your business could use a professional website. We design affordable, mobile-friendly sites. Free consultation?"
β”‚  β”œβ”€ Anti-ban logic:
β”‚  β”‚  β€’ Random delay: sleep(rand(5,15)) between each message
β”‚  β”‚  β€’ Batch cooldown: sleep(rand(120,300)) after every 15 messages
β”‚  β”‚  β€’ Daily limits: 30/day (new number) / 70/day (warmed) tracked in DB
β”‚  β”‚  β€’ Working hours: Only send 09:00-18:00 Africa/Nairobi
β”‚  β”‚  β€’ Message rotation: Cycle 3-5 templates randomly
β”‚  └─ POST to https://tools.onhandi.com/api/sessions/{sessionId}/send
β”‚
β”œβ”€πŸ“Š STEP 3: Log & Track
β”‚  β”œβ”€ Log every action: WHATSAPP_CHECKED β†’ MESSAGE_SENT/FAILED
β”‚  β”œβ”€ Store messageId for delivery tracking
β”‚  └─ Dashboard shows real-time progress via AJAX
β”‚
β””β”€πŸŽ›οΈ STEP 4: Dashboard Controls
   β”œβ”€ WhatsApp session status indicator (🟒 Connected / πŸ”΄ Disconnected)
   β”œβ”€ "Send Test Message" button for manual triggers
   β”œβ”€ Live send progress with success/fail counters
   └─ Anti-ban status panel: "Today: X/30 sent β€’ Next allowed: HH:MM"

whatsapp integration

βœ… app/Messaging/WhatsAppGateway.php
   - Full onhandi.com API client (number checker + message sender)
   - Batch processing (100 numbers max per call)
   - 24h result caching to avoid redundant API calls
   - Error handling with retries

βœ… app/Services/LeadProcessor.php  
   - Complete workflow: Verify β†’ Qualify β†’ Check WhatsApp β†’ Send
   - Anti-ban logic: 
     β€’ Random delay: sleep(rand(5,15)) between messages
     β€’ Batch cooldown: sleep(rand(120,300)) every 15 messages
     β€’ Daily limits: 30/day (new) / 70/day (warmed) tracked in DB
     β€’ Working hours: Only send 09:00-18:00 Africa/Nairobi
   - Message rotation: Cycle 3-5 templates randomly via MessageRotator

βœ… app/Controllers/WhatsAppController.php
   - AJAX endpoints: /api/whatsapp/status, /api/whatsapp/send-test
   - Real-time progress updates for dashboard
   - Session management for onhandi.com gateway

βœ… Updated Dashboard UI
   - WhatsApp session status indicator (🟒 Connected / πŸ”΄ Disconnected)
   - "Send Test Message" button for qualified leads
   - Live send progress with success/fail counters
   - Anti-ban status panel (today's count, next allowed send time)

βœ… Message Templates (Your Business Logic)
   β€’ IF website WORKING β†’ 
     "Hi {name}, noticed your site is live! We offer maintenance, SEO, social media management. Interested?"
   β€’ IF website MISSING/NOT_WORKING β†’ 
     "Hi {name}, saw your business could use a professional website. We design affordable, mobile-friendly sites. Free consultation?"

πŸš€ LeadFlux Public API - Complete File Structure & Code

Great! the exact file structure and complete code for your Lead flux API system. πŸ“ Complete File Structure

app.onhandi.com/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   β”œβ”€β”€ Api/
β”‚   β”‚   β”‚   β”œβ”€β”€ ApiController.php          ← Base API controller
β”‚   β”‚   β”‚   β”œβ”€β”€ LeadsController.php        ← Leads endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ NumbersController.php      ← Number verification
β”‚   β”‚   β”‚   β”œβ”€β”€ CampaignsController.php    ← Campaign management
β”‚   β”‚   β”‚   β”œβ”€β”€ WhatsAppController.php     ← WhatsApp messaging
β”‚   β”‚   β”‚   └── ApiKeysController.php      ← API key management
β”‚   β”‚   └── ... (existing controllers)
β”‚   β”‚
β”‚   β”œβ”€β”€ Middleware/
β”‚   β”‚   β”œβ”€β”€ ApiAuth.php                    ← API authentication
β”‚   β”‚   └── ... (existing middleware)
β”‚   β”‚
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   β”œβ”€β”€ ApiRateLimiter.php             ← Rate limiting service
β”‚   β”‚   └── ... (existing services)
β”‚   β”‚
β”‚   └── Views/
β”‚       └── api/
β”‚           β”œβ”€β”€ documentation.php          ← API docs page
β”‚           └── keys.php                   ← API key management UI
β”‚
β”œβ”€β”€ public/
β”‚   └── api/
β”‚       └── docs.php                       ← Public API documentation
β”‚
└── storage/
    └── logs/
        └── api.log                        ← API usage logs

🎯 Core Features (User-Facing)

  1. πŸ“ Campaign Creation Wizard Step-by-step flow:

[Step 1: Basics]
β”œβ”€ Campaign Name (required)
β”œβ”€ Description (optional)
β”œβ”€ Campaign Type:
β”‚  β”œβ”€ One-time broadcast
β”‚  β”œβ”€ Scheduled campaign
β”‚  └─ Recurring (daily/weekly)
└─ Tags/Labels for organization

[Step 2: Recipients]
β”œβ”€ Select Source:
β”‚  β”œβ”€ All contacts
β”‚  β”œβ”€ Specific groups
β”‚  β”œβ”€ Custom filters (qualifier, website status, tags)
β”‚  β”œβ”€ Upload CSV list
β”‚  └─ API-provided lead IDs
β”œβ”€ Preview recipient count
β”œβ”€ Exclude duplicates/already-messaged
└─ Test send to 1-5 numbers first

[Step 3: Message Content]
β”œβ”€ Message Type Selector:
β”‚  β”œβ”€ πŸ“ Text (with emoji support)
β”‚  β”œβ”€ πŸ–ΌοΈ Image + caption
β”‚  β”œβ”€ 🎬 Video + caption
β”‚  β”œβ”€ πŸ“„ Document (PDF, DOC, etc.)
β”‚  β”œβ”€ 🎡 Audio message
β”‚  β”œβ”€ πŸ“ Location share
β”‚  β”œβ”€ πŸ‘€ Contact card (vCard)
β”‚  β”œβ”€ πŸ—³οΈ Interactive poll
β”‚  └─ πŸ‘οΈ View-once media
β”œβ”€ Rich Text Editor:
β”‚  β”œβ”€ Variables: {name}, {phone}, {custom_field}
β”‚  β”œβ”€ Emoji picker
β”‚  β”œβ”€ Character counter (WhatsApp limits)
β”‚  └─ Preview on phone mockup
β”œβ”€ Media Upload:
β”‚  β”œβ”€ Drag & drop
β”‚  β”œβ”€ URL import
β”‚  β”œβ”€ Library of previously uploaded media
β”‚  └─ Auto-compress for WhatsApp limits
└─ Fallback message (if media fails)

[Step 4: Sending Strategy]
β”œβ”€ Delivery Mode:
β”‚  β”œβ”€ 🐌 Sequential (one-by-one, slow)
β”‚  β”œβ”€ 🎲 Random order (avoid patterns)
β”‚  β”œβ”€ πŸ”„ Round-robin (across sessions)
β”‚  β”œβ”€ βš–οΈ Balanced (by gateway health)
β”‚  └─ πŸ’₯ Burst (fast, for small lists)
β”œβ”€ Rate Limiting:
β”‚  β”œβ”€ Messages per minute (10-100)
β”‚  β”œβ”€ Daily cap per session
β”‚  β”œβ”€ Pause between batches
β”‚  └─ Business hours only toggle
β”œβ”€ Anti-Ban Protections:
β”‚  β”œβ”€ Random delay (500ms-3000ms)
β”‚  β”œβ”€ Simulate typing indicator
β”‚  β”œβ”€ Rotate WhatsApp sessions
β”‚  β”œβ”€ Auto-pause on high error rate
β”‚  └─ Human-like sending patterns
└─ Retry Logic:
   β”œβ”€ Max retries per message (0-3)
   β”œβ”€ Exponential backoff
   └─ Skip after N failures

[Step 5: Schedule & Launch]
β”œβ”€ Send Options:
β”‚  β”œβ”€ πŸš€ Send now
β”‚  β”œβ”€ πŸ“… Schedule for later (date/time picker)
β”‚  └─ ⏰ Recurring schedule (cron-like)
β”œβ”€ Notifications:
β”‚  β”œβ”€ Email on completion
β”‚  β”œβ”€ Webhook on status change
β”‚  └─ In-app alerts for failures
β”œβ”€ Review Summary:
β”‚  β”œβ”€ Recipient count
β”‚  β”œβ”€ Estimated duration
β”‚  β”œβ”€ Cost estimate (if applicable)
β”‚  └─ Compliance checklist
└─ [Launch Campaign] button




πŸ’» Technology Stack

Layer Technology Purpose
Backend PHP 8.3+ Server-side logic
Framework Custom MVC Lightweight, no bloat
Database MySQL 8+/MariaDB Data persistence
Frontend Bootstrap 5 + Vanilla JS Responsive UI
HTTP Client cURL External API calls
Excel Parsing PhpSpreadsheet Import .xlsx/.csv files
Session Management Native PHP Sessions Authentication state
Hosting Shared Hosting (cPanel) Deployment target
WhatsApp API tools.onhandi.com Message sending

βœ… Phase 1: Foundation (Completed)

Delivered Features

  • βœ… Core MVC Framework: Router, Controller, Database, Logger
  • βœ… Authentication System: Login, registration, CSRF protection
  • βœ… Lead Import Pipeline: Excel upload β†’ column mapping β†’ database insert
  • βœ… Website Verification Service:
    • Robust URL parsing with parse_url()
    • HTTP/HTTPS fallback testing
    • Detailed result objects (status, HTTP code, response time)
  • βœ… Dashboard UI: Stats cards, verification results table, live logs
  • βœ… Progress Modal: Real-time feedback during bulk operations
  • βœ… Error Handling: User-friendly messages, logging, graceful failures

Key Files Created

app/Core/Controller.php
app/Core/Router.php
app/Controllers/LeadController.php
app/Services/WebsiteVerifier.php
app/Views/dashboard.php

βœ… Phase 2: Multi-Tenant SaaS (Completed)

Delivered Features

  • βœ… Tenant Isolation Middleware: Tenant::requireTenant() enforces data scoping
  • βœ… Database Schema Updates:
    • user_id columns on all data tables (leads, campaigns, contacts, etc.)
    • tenant_settings table for per-user config
    • subscriptions table for plan management
  • βœ… Workspace Onboarding: 3-step setup flow with slug generation
  • βœ… Per-User Settings: WhatsApp credentials, timezone, daily limits, working hours
  • βœ… Admin Database Tools:
    • Migration runner with one-click execution
    • Safe SQL executor with dangerous operation warnings
    • Real query results display (SELECT, DESCRIBE, SHOW)
  • βœ… Notification System: Toast alerts for all user actions
  • βœ… Responsive Header: Workspace selector, user menu, notification badge
  • βœ… Profile Management: Update info, change password, view stats

Key Files Created

app/Middleware/Tenant.php
app/Controllers/OnboardingController.php
app/Controllers/DatabaseToolsController.php
app/Services/NotificationService.php
app/Views/onboarding/index.php
app/Views/admin/database-tools.php
database/migrations.sql (tenant isolation)

Security Enhancements

  • πŸ” Query Scoping: All data queries include WHERE user_id = :user_id
  • πŸ” Session Validation: $_SESSION['user_id'] cast to int to prevent injection
  • πŸ” Admin-Only Routes: Database tools protected by Auth::requireAdmin()
  • πŸ” SQL Safety: Dangerous operations require explicit confirmation modal

πŸ”„ Phase 3: WhatsApp Integration (Next)

🎯 Objective

Enable automated, compliant WhatsApp messaging to qualified leads using the onhandi.com API, with anti-ban protections and per-user configuration.

πŸ“¦ Components to Implement

1. app/Messaging/WhatsAppGateway.php

class WhatsAppGateway
{
    // API Client for tools.onhandi.com
    - checkNumber(string $phone): array    // Verify WhatsApp availability
    - sendMessage(string $phone, string $message, array $options): array  // Send message
    - getDeliveryStatus(string $messageId): array  // Track delivery
    
    // Anti-Ban Logic
    - applyRandomDelay(int $min, int $max): void  // Sleep between messages
    - checkDailyLimit(int $userId): bool  // Enforce per-user limits
    - isWithinWorkingHours(string $timezone): bool  // Respect business hours
    
    // Caching
    - cacheNumberCheck(string $phone, array $result, int $ttl): void  // 24h cache
    - getCachedResult(string $phone): ?array  // Avoid redundant API calls
}

2. app/Services/LeadProcessor.php

class LeadProcessor
{
    // Complete workflow
    public function processQualifiedLeads(int $userId, int $batchSize = 10): array
    {
        // 1. Fetch qualified leads (scoped to user)
        // 2. Check WhatsApp availability via gateway
        // 3. Apply anti-ban logic (delays, limits, hours)
        // 4. Send personalized message based on website status:
        //    - WORKING β†’ "SEO/Maintenance" offer
        //    - NOT_WORKING/NO_WEBSITE β†’ "Web Design" offer
        // 5. Log results to activity_logs (user-scoped)
        // 6. Update lead status (SENT/FAILED)
    }
}

3. app/Controllers/WhatsAppController.php

class WhatsAppController extends Controller
{
    // AJAX endpoints for dashboard
    public function getStatus(): void      // Check gateway connection
    public function sendTest(): void       // Send test message to phone
    public function startCampaign(): void  // Begin bulk send with progress
    public function getProgress(): void    // Poll for real-time updates
}

4. Updated Dashboard UI

  • 🟒 Connection Status Indicator: WhatsApp gateway status (Connected/Disconnected)
  • πŸ“€ Send Test Message: Input phone + send hardcoded "LeadFlux is up and running"
  • πŸ“Š Live Send Progress: Progress bar + success/fail counters during campaigns
  • βš™οΈ Anti-Ban Panel: "Today: X/30 sent β€’ Next: HH:MM" with limit controls
  • πŸ“‹ Message Templates: Rotate 3-5 templates randomly to avoid spam detection

5. Business Logic Implementation

// Message selection based on website verification
if ($lead['website_status'] === 'WORKING') {
    $message = "Hi {name}, noticed your site is live! πŸŽ‰ We offer maintenance, SEO, and social media management. Interested in a free audit?";
} elseif (in_array($lead['website_status'], ['NOT_WORKING', 'NO_WEBSITE', 'ERROR'])) {
    $message = "Hi {name}, saw your business could use a professional website. πŸš€ We design affordable, mobile-friendly sites. Free consultation?";
}

6. Export Functionality

  • πŸ“₯ with_website.csv: Leads with working websites (SEO/maintenance offers)
  • πŸ“₯ without_website.csv: Leads without/broken websites (web design offers)
  • πŸ“Š campaign_report.csv: Send results with timestamps and status codes

πŸ” Anti-Ban Protection Strategy

Technique Implementation Purpose
Random Delays sleep(rand(5, 15)) between messages Mimic human behavior
Batch Cooldowns sleep(rand(120, 300)) after 15 messages Avoid rate limiting
Daily Limits Track sends in DB; enforce per-plan limits Prevent account flags
Working Hours Only send 09:00-18:00 Africa/Nairobi (configurable) Respect recipient time
Message Rotation Cycle 3-5 templates randomly Avoid spam pattern detection
Number Validation Pre-check via Number Checker API Avoid sending to invalid numbers

πŸ“Š Dashboard Enhancements

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 🟒 WhatsApp: Connected  β€’  Today: 12/30 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ [Send Test Message]  [Start Campaign]   β”‚
β”‚                                         β”‚
β”‚ Progress: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘] 80%           β”‚
β”‚ βœ… Sent: 24  ❌ Failed: 2  ⏳ Pending: 4 β”‚
β”‚                                         β”‚
β”‚ Next Send: 14:32 (in 8 min)            β”‚
β”‚ Anti-Ban: Random delay β€’ Batch cooldownβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”— API Integration Details

Endpoint: https://tools.onhandi.com/api/sessions/{sessionId}/send
Headers:

X-API-Key: {user_configured_key}
Content-Type: application/json

Request Body:

{
  "to": "254712345678",
  "message": "Your personalized message here",
  "skipValidation": false
}

Response Handling:

  • βœ… 200-299: Message queued/sent β†’ log as SENT
  • ❌ 401/403: Auth error β†’ alert user to check credentials
  • ❌ 404: Invalid endpoint β†’ alert user to check base URL
  • ❌ 429: Rate limited β†’ apply exponential backoff
  • ❌ Other: Log error, mark as FAILED, continue batch

πŸš€ Getting Started

Prerequisites

  • PHP 8.3+ with extensions: curl, pdo_mysql, mbstring, zip, xml
  • MySQL 8+ or MariaDB 10.5+
  • Composer for dependency management
  • cPanel or similar hosting with cron support

Installation

# 1. Clone repository
git clone https://github.com/yourorg/leadflux.git
cd leadflux

# 2. Install dependencies
composer install

# 3. Configure environment
cp .env.example .env
# Edit .env with your database credentials and WhatsApp API details

# 4. Run migrations
php artisan migrate

# 5. Set permissions
chmod -R 755 storage bootstrap/cache

# 6. Setup cron (for scheduled tasks)
* * * * * /usr/local/bin/php /path/to/leadflux/artisan schedule:run >> /dev/null 2>&1

# 7. Access application
# Visit: https://yourdomain.com/public

First-Time Setup

  1. Register admin account (first user auto-promoted to admin)
  2. Complete workspace onboarding (name, slug, timezone)
  3. Configure WhatsApp credentials in Settings β†’ WhatsApp Gateway
  4. Import leads via Marketing β†’ Verify
  5. Start campaigns from Dashboard β†’ WhatsApp Panel

πŸ” Security & Compliance

Data Protection

  • πŸ”’ Encryption: Passwords hashed with password_hash() (bcrypt)
  • πŸ”’ Input Sanitization: All user inputs escaped with htmlspecialchars()
  • πŸ”’ SQL Injection Prevention: Prepared statements with bound parameters
  • πŸ”’ XSS Protection: Output encoding on all dynamic content

WhatsApp Compliance

  • βœ… Opt-In Requirement: Only message leads who provided phone numbers
  • βœ… Unsubscribe Handling: Include opt-out instructions in messages
  • βœ… Rate Limiting: Respect WhatsApp's messaging policies via anti-ban logic
  • βœ… Data Retention: Configurable log retention periods

Multi-Tenant Security

  • πŸ” Query Scoping: Middleware enforces user_id isolation on all data access
  • πŸ” Session Validation: User ID cast to int to prevent session fixation
  • πŸ” Admin Separation: Admin features protected by role checks
  • πŸ” Audit Logging: All sensitive actions logged with user context

πŸ—“οΈ Roadmap

Phase 3: WhatsApp Integration (Current)

  • WhatsAppGateway API client with error handling
  • LeadProcessor workflow with anti-ban logic
  • Real-time campaign progress dashboard
  • Message template rotation system
  • Export qualified leads by website status

Phase 4: Billing & Monetization

  • Stripe/PayPal integration for subscription payments
  • Usage-based billing (messages sent, leads imported)
  • Plan upgrade/downgrade flow
  • Invoice generation and payment history

Phase 5: Advanced Analytics

  • Campaign performance dashboards
  • Lead conversion tracking
  • A/B testing for message templates
  • Exportable reports (PDF/CSV)

Phase 6: Team Collaboration

  • Multi-user workspaces with roles (Admin, Member, Viewer)
  • Shared lead pools and assignment
  • Team activity feeds and notifications
  • Audit trails for compliance

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Coding Standards

  • Follow PSR-12 coding style
  • Use strict types: declare(strict_types=1);
  • Document public methods with PHPDoc
  • Write tests for new features (future)

πŸ“„ License

LeadFlux is proprietary software. All rights reserved.


πŸ†˜ Support


LeadFlux β€” Turn leads into conversations, automatically. πŸš€

Built with ❀️ by kinflux digital

About

LeadFlux - Multi-Tenant SaaS Lead Recovery Platform Automate lead qualification, website verification, and WhatsApp outreach at scale

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors