Files
hub/docs/modules.md
kelly ce5c670bf2 feat: Add AI Copilot module with multi-provider support + brand-scoped campaigns + comprehensive docs
## AI Copilot Module System
- Add copilot_enabled flag to businesses table
- Add Copilot Module toggle in Filament admin (Premium Features)
- Gate all Copilot buttons with copilot_enabled check
- Enable by default for Cannabrands only

## AI Settings Multi-Provider Support
- Support 5 AI providers: Anthropic, OpenAI, Perplexity, Canva, Jasper
- Separate encrypted API keys per provider
- Model dropdowns populated from config/ai.php
- Test Connection feature with real API validation
- Existing Connections summary shows status for all providers
- Provider-specific settings only shown when provider selected

## Brand-Scoped Campaign System
- Add brand_id to broadcasts table
- Brand selector component (reusable across forms)
- Campaign create/edit requires brand selection
- All campaigns now scoped to specific brand

## Documentation (9 New Files)
- docs/modules.md - Module system architecture
- docs/messaging.md - Messaging and conversation system
- docs/copilot.md - AI Copilot features and configuration
- docs/segmentation.md - Buyer segmentation system
- docs/sendportal.md - SendPortal multi-brand integration
- docs/campaigns.md - Campaign creation and delivery flow
- docs/conversations.md - Conversation lifecycle and threading
- docs/brand-settings.md - Brand configuration and voice system
- docs/architecture.md - High-level system overview

## Bug Fixes
- Remove duplicate FailedJobResource (Horizon already provides this at /horizon/failed)
- Fix missing Action import in Filament resources
- Update brand policy for proper access control

## Database Migrations
- 2025_11_23_175211_add_copilot_enabled_to_businesses_table.php
- 2025_11_23_180000_add_brand_id_to_broadcasts_table.php
- 2025_11_23_180326_update_ai_settings_for_multiple_providers.php
- 2025_11_23_184331_add_new_ai_providers_to_ai_settings.php

## Notes
- Pint:  Passed (all code style checks)
- Tests: Failing due to pre-existing database schema dump conflicts (not related to these changes)
- Schema issue needs separate fix: pgsql-schema.sql contains tables that migrations also create
2025-11-23 12:31:19 -07:00

3.3 KiB

Modules System

Overview

The platform uses a modular premium features system where each business can enable/disable specific functionality modules. Modules are managed through the Filament admin panel (/admin/businesses → Edit Business → Modules tab).

Module Configuration

Modules are enabled via boolean flags on the businesses table:

Module Flag Display Name Category Type Description Cannabrands Default
has_analytics Analytics Module Business Intelligence Premium Premium analytics: Buyer engagement tracking, intent signals, RFDI scoring, email campaign analytics No
has_marketing Marketing Module Marketing Premium Email campaigns, marketing automation, broadcast messages, templates, SendPortal integration No
has_manufacturing Manufacturing Module Operations Premium Work orders, batch production, BOM management, purchase orders No
has_processing Processing Module Operations Premium Hash washing, rosin pressing, material conversions, wash reports, batch tracking No
has_inventory Advanced Inventory Module Operations Premium Multi-location tracking, batch/lot numbers, expiration management, inventory movements, alerts No
has_compliance Compliance Module Regulatory Premium METRC integration, regulatory tracking, lab results, chain of custody No
copilot_enabled Copilot Module AI/Automation Premium AI-powered content generation and assistance across campaigns, product content, messaging, and brand editing Yes (Cannabrands only)

Module Access Methods

In Models

// Business.php
public function hasAnalytics(): bool
public function hasMarketing(): bool
public function hasAiCopilot(): bool
public function hasManufacturing(): bool
public function hasProcessing(): bool
public function hasInventory(): bool
public function hasCompliance(): bool
public function getEnabledModules(): array

In Blade Views

@if($business->hasMarketing())
    {{-- Marketing features --}}
@endif

@if($business->copilot_enabled)
    {{-- AI Copilot buttons --}}
@endif

In Controllers

if (!$business->hasMarketing()) {
    abort(403, 'Marketing module not enabled');
}

Module Management

Modules are toggled through:

  • Admin Panel: /admin/businesses → Edit → Modules tab
  • Toggle Components: Filament Toggle fields with helper text
  • Real-time Effect: Changes apply immediately (no restart required)

Module Dependencies

Some modules have implicit dependencies:

  • Marketing Module → Requires brand setup for sender identity
  • Copilot Module → Requires AI Settings configured with provider API keys
  • Processing Module → Often used with Manufacturing Module for complete production workflow

Cannabrands Special Configuration

Cannabrands business has unique default settings:

  • Copilot Module: Enabled by default (copilot_enabled = true)
  • All other modules: Follow standard enablement process

To enable Copilot for other businesses:

UPDATE businesses SET copilot_enabled = true WHERE id = <business_id>;

Or via admin panel: /admin/businesses → Edit Business → Modules → Toggle "Copilot Module"