Files
hub/docs/MODULES_CURRENT_STATE.md
kelly 3905f86d6a feat: V1 Release - Complete platform with all premium modules
Major Features:
- CRM Lite: Pipeline, tasks, accounts, calendar, inbox
- AI Copilot: Multi-provider support, brand voice, content rules
- Marketing: Campaigns, templates, channels, broadcasts
- Intelligence: Buyer analytics, market intelligence dashboard
- Orchestrator: Sales & marketing automation with AI
- Compliance: License tracking (minimal shell)
- Conversations: Buyer-seller messaging with email/SMS routing

Infrastructure:
- Suites & Plans system for feature gating
- 60+ new migrations
- Module middleware for access control
- Database seeders for production sync
- Enhanced product management (varieties, inventory modes)

Documentation:
- V1 scope, launch checklist, QA scripts
- Module current state audit
- Feature matrix (standard vs premium)
2025-12-01 09:48:40 -07:00

13 KiB

Modules & Features - Current State Audit

Date: 2025-11-28 Auditor: Claude (read-only audit) Status: DOCUMENTATION ONLY - No code changes made


1. Module Flag Definitions

Database Columns on businesses Table

All module flags are stored as boolean columns on the businesses table:

Column Type Default Description
has_inventory boolean false Inventory management module
has_analytics boolean false Analytics dashboards
has_marketing boolean false Marketing campaigns, templates, broadcasts
has_manufacturing boolean false Work orders, purchase orders, assembly
has_processing boolean false Wash reports, stage conversions
has_compliance boolean false License tracking, regulatory
has_accounting boolean false (Placeholder - not implemented)
has_crm boolean false Sales pipeline, accounts, tasks
has_assemblies boolean false Product assemblies (within manufacturing)
has_conversations boolean false Messaging inbox module
has_buyer_intelligence boolean false Buyer analytics, RFDI scoring
copilot_enabled boolean false AI content generation

Tier Columns on businesses Table

Each module also has an optional tier column (string, nullable):

Column Values Purpose
marketing_tier basic, premium, custom Feature level within marketing
analytics_tier basic, premium, custom Feature level within analytics
manufacturing_tier basic, premium, custom Feature level within manufacturing
processing_tier basic, premium, custom Feature level within processing
inventory_tier basic, premium, custom Feature level within inventory
compliance_tier basic, premium, custom Feature level within compliance
copilot_tier basic, premium, custom Feature level within AI copilot
crm_tier basic, premium, custom Feature level within CRM
conversations_tier basic, premium, custom Feature level within messaging
buyer_intelligence_tier basic, premium, custom Feature level within buyer intel
assemblies_tier basic, premium, custom Feature level within assemblies
accounting_tier basic, premium, custom (Placeholder)

Note: Tier columns are defined but NOT actively enforced in routes/middleware. The has_* boolean is the primary gate.


2. Module Middleware

All module middleware is located in app/Http/Middleware/:

Middleware Class Alias (in bootstrap/app.php) Checks
EnsureBusinessHasModule module Generic, accepts parameter
EnsureBusinessHasMarketing EnsureBusinessHasMarketing has_marketing
EnsureBusinessHasAnalytics EnsureBusinessHasAnalytics has_analytics
EnsureBusinessHasInventory EnsureBusinessHasInventory has_inventory
EnsureBusinessHasManufacturing (none) has_manufacturing
EnsureBusinessHasProcessing (none) has_processing
EnsureBusinessHasCompliance (none) has_compliance
EnsureBusinessHasCrm (none) has_crm
EnsureBusinessHasConversations (none) has_conversations
EnsureBusinessHasBuyerIntelligence (none) has_buyer_intelligence
EnsureBusinessHasCopilot (none) copilot_enabled
CheckAnalyticsModule module.analytics Legacy alias

3. Routes Gated by Module

Processing Module (has_processing)

  • /s/{business}/processing/* - All processing routes
    • Wash reports
    • Work orders (processing)
    • Stage conversions

Manufacturing Module (has_manufacturing)

  • /s/{business}/manufacturing/* - All manufacturing routes
    • Purchase orders
    • Work orders (manufacturing)

Inventory Module (has_inventory)

  • /s/{business}/inventory/* - All inventory routes
    • Dashboard
    • Items, movements, alerts

Compliance Module (has_compliance)

  • /s/{business}/compliance/* - All compliance routes

CRM Module (has_crm)

  • /s/{business}/crm/* - All CRM routes
    • Pipeline, accounts, tasks
    • Activity, calendar
    • Inbox (CRM-enhanced)

Marketing Module (has_marketing)

  • /s/{business}/marketing/* - All marketing routes
    • Broadcasts, templates, channels, campaigns

Conversations Module (has_conversations)

  • /s/{business}/messaging/* - Messaging inbox routes

Buyer Intelligence Module (has_buyer_intelligence)

  • /s/{business}/buyer-intelligence/* - Buyer analytics routes

AI Copilot (copilot_enabled)

  • /s/{business}/ai/* - AI preview/generate endpoints
  • /s/{business}/brands/{brand}/ai/* - Brand AI regeneration
  • /s/{business}/marketing/templates/ai/* - Template AI generation

4. Routes NOT Gated (Always Available)

These routes are available to ALL approved sellers regardless of module flags:

Core Business Operations

  • /s/{business}/orders/* - Order management
  • /s/{business}/invoices/* - Invoice management
  • /s/{business}/customers/* - Customer list
  • /s/{business}/products/* - Product catalog (CRUD)
  • /s/{business}/batches/* - Batch management
  • /s/{business}/components/* - Component management
  • /s/{business}/promotions/* - Promotions (basic)
  • /s/{business}/brands/* - Brand management (basic)
  • /s/{business}/documents/* - Document management
  • /s/{business}/fleet/* - Fleet management (drivers, vehicles)
  • /s/{business}/settings/* - Business settings

Dashboard & Analytics (partial)

  • /s/{business}/dashboard - Main dashboard (always available)
  • /s/{business}/analytics - Analytics index (shows upgrade prompt if has_analytics=false)
  • /s/{business}/orchestrator - Shows if has_crm && has_buyer_intelligence && copilot_enabled (checked in controller, not middleware)

5. Hard-Coded Assumptions

Sales is Always Enabled

In app/Helpers/BusinessHelper.php:137:

'sales' => true, // Sales is always enabled (base product)

This is the core marketplace functionality (orders, invoices, products).

Filament Admin - Modules Tab

In app/Filament/Resources/BusinessResource.php:467:

Tab::make('Modules')
    ->visible(fn () => auth('admin')->check() && auth('admin')->user()->user_type === 'superadmin')

Only superadmins can see/edit module flags.


6. View-Level Checks

Blade templates check module flags for conditional rendering:

View Check Purpose
seller-sidebar.blade.php $sidebarBusiness->has_manufacturing Show Manufacturing section
seller-sidebar.blade.php $sidebarBusiness->has_marketing Show Marketing section
seller-sidebar.blade.php $sidebarBusiness->has_crm Show CRM section
seller-sidebar.blade.php $sidebarBusiness->has_conversations Show Inbox link
seller-sidebar.blade.php $sidebarBusiness->has_processing Show Wash Reports
seller-sidebar.blade.php $sidebarBusiness->has_inventory Show Inventory Dashboard link
contacts/show.blade.php $business->has_marketing Show engagement timeline
products/edit.blade.php $business->has_assemblies Show assemblies tab
analytics/index.blade.php !$business->has_analytics Show upgrade prompt
Various analytics views !$business->has_buyer_intelligence Show upgrade prompt

7. Business Model Helper Methods

The Business model (app/Models/Business.php) provides helper methods:

public function hasAiCopilot(): bool { return (bool) $this->copilot_enabled; }
public function hasAnalytics(): bool { return (bool) $this->has_analytics; }
public function hasMarketing(): bool { return (bool) $this->has_marketing; }
public function hasManufacturing(): bool { return (bool) $this->has_manufacturing; }
public function hasProcessing(): bool { return (bool) $this->has_processing; }
public function hasInventory(): bool { return (bool) $this->has_inventory; }
public function hasCompliance(): bool { return (bool) $this->has_compliance; }

8. No Config Files

There is:

  • NO config/modules.php
  • NO config/features.php
  • NO Module or Feature Eloquent model

All module state is stored directly on the businesses table.


9. Tier Feature Configuration (In Filament Only)

The Filament BusinessResource defines feature lists for each tier, but these are not enforced in code. They're only used in the admin UI for visual display:

Example from BusinessResource.php:

$features = match ($state) {
    'basic' => ['campaigns', 'templates'],
    'premium' => ['campaigns', 'templates', 'channels', 'messaging', 'analytics'],
    default => [],
};

These feature arrays are NOT checked anywhere else in the codebase. The *_tier columns are metadata only.



Mapping to Kelly's Module Plan

Kelly's Proposed Tiers

Based on ChatGPT conceptual model:

  • BASIC - Core marketplace functionality, always included
  • BASE_PLUS - Enhanced features, first paid tier
  • PREMIUM - Full feature set, highest tier

Current Modules Mapped to Proposed Tiers

Current Module Current Default Proposed Tier Notes
Sales (Orders, Invoices, Products) Always ON BASIC Core marketplace - no flag exists
Dashboard Always ON BASIC Always available
Product Catalog (CRUD) Always ON BASIC Always available
Brand Management (basic) Always ON BASIC Always available
Promotions (basic) Always ON BASIC Always available
Customers/Contacts Always ON BASIC Always available
Documents Always ON BASIC Always available
Fleet (Drivers/Vehicles) Always ON BASIC Always available
Batches Always ON BASIC Always available
Components Always ON BASIC Always available
has_inventory OFF BASE_PLUS Inventory tracking, movements, alerts
has_compliance OFF BASE_PLUS License tracking, expiration
has_analytics OFF BASE_PLUS Basic analytics dashboards
has_processing OFF BASE_PLUS Wash reports, stage conversions (industry-specific)
has_manufacturing OFF PREMIUM Work orders, purchase orders, full MRP
has_marketing OFF PREMIUM Campaigns, broadcasts, templates
has_crm OFF PREMIUM Full sales pipeline, accounts
has_conversations OFF PREMIUM Messaging inbox
has_buyer_intelligence OFF PREMIUM Advanced buyer analytics, RFDI
copilot_enabled OFF PREMIUM AI content generation
has_assemblies OFF SALES SUITE Basic BOM/assemblies (now via hasAssemblies() helper)
has_accounting OFF (Not Implemented) Future module

Naming Mismatches

Current Name Potential Cleaner Name Notes
copilot_enabled has_copilot Inconsistent with has_* pattern
has_assemblies N/A Now available via Business::hasAssemblies() which includes Sales Suite
has_accounting - Placeholder, not implemented
has_buyer_intelligence has_buyer_intel Name is long but clear

Observations

  1. No explicit "tier" enforcement - The *_tier columns exist but are only used in Filament UI, not route/middleware checks.

  2. Binary gating only - Currently, modules are either ON or OFF. There's no "lite" vs "full" enforcement at the route level.

  3. Orchestrator has complex gate - Requires has_crm && has_buyer_intelligence && copilot_enabled - this is the "AI Command Center" for premium users.

  4. Sales is not gated - The core marketplace (orders, invoices, products) is always available. This aligns with BASIC tier.

  5. Feature arrays in Filament are aspirational - The feature checkboxes in admin (campaigns, templates, channels, etc.) are defined but not enforced anywhere.


  1. Define tier constants - Create an enum or config for BASIC / BASE_PLUS / PREMIUM
  2. Group modules into tiers - Decide which modules belong to which tier
  3. Decide on tier column usage - Either:
    • Remove *_tier columns (simplify to boolean only)
    • Or implement tier-level feature gating (more complex)
  4. Rename copilot_enabled - Align with has_* pattern for consistency
  5. Consider has_assemblies - May be redundant if manufacturing includes it

Summary

The current module system is simple and functional:

  • Boolean flags on businesses table
  • Middleware gates routes by flag
  • Sidebar/views hide sections if flag is false
  • Tier columns exist but are NOT enforced

No changes were made during this audit. This document is purely descriptive.