HotCRM Logo
Technical SpecsAI Specs

AI Cloud

The unified AI/ML service layer providing model registry, prediction services, caching, explainability, and performance monitoring across all HotCRM modules.

AI Cloud Subsystem

The AI Cloud module (@hotcrm/ai) provides a unified AI/ML infrastructure for all HotCRM business modules. It follows a provider-based architecture supporting multiple ML frameworks and cloud services through a consistent interface.

1. Architecture Overview

The AI Cloud is designed as a shared service layer — it does not define its own business objects but provides ML capabilities consumed by other packages (Sales, HR, Service, Marketing). The architecture follows these principles:

  • Provider Abstraction: Swap between OpenAI, AWS SageMaker, Azure ML, or custom models without changing consumer code.
  • Multi-Model Support: Register and manage multiple models with versioning, A/B testing, and lifecycle tracking.
  • Built-in Observability: Every prediction is cached, monitored, and explainable by default.
  • Graceful Degradation: Falls back to in-memory cache and mock predictions when external services are unavailable.

2. Core Components

ComponentModuleDescription
Model Registrymodel-registry.tsCentral catalog for all AI/ML models with versioning, configuration, and lifecycle management.
Prediction Serviceprediction-service.tsUnified inference interface with caching, A/B testing, batch support, and error handling.
Cache Managercache-manager.tsRedis-based prediction caching with in-memory fallback. Configurable TTL per model.
Explainability Serviceexplainability-service.tsSHAP-like feature attribution for model predictions. Generates human-readable explanations.
Performance Monitorperformance-monitor.tsReal-time tracking of prediction latency, accuracy, cache hit rates, and health status.
GenAI Reportinggenai_reporting.action.tsNatural language query interface for analytics. Converts questions to ObjectQL queries.
AI Utilitiesutils.tsShared math and ML utilities: normalization, similarity, clustering, trend detection.

3. Provider Integrations

All providers implement the BaseMLProvider abstract class defined in providers/base-provider.ts:

ProviderModuleCapabilities
OpenAIopenai-provider.tsNLP, classification, text generation, embeddings
AWS SageMakeraws-sagemaker-provider.tsCustom model hosting, batch inference, real-time endpoints
Azure MLazure-ml-provider.tsManaged model deployment, AutoML, batch scoring

3.1 Provider Interface

Every provider must implement:

abstract validate(): Promise<boolean>;
abstract predict<T>(modelId: string, input: PredictionInput): Promise<PredictionOutput<T>>;
abstract batchPredict<T>(modelId: string, inputs: PredictionInput[]): Promise<PredictionOutput<T>[]>;
abstract healthCheck(): Promise<{ healthy: boolean; latency?: number; error?: string }>;

3.2 Provider Configuration

interface MLProviderConfig {
  provider: 'aws-sagemaker' | 'azure-ml' | 'openai' | 'anthropic' | 'custom';
  endpoint?: string;
  credentials: {
    apiKey?: string;
    secretKey?: string;
    region?: string;
  };
  config?: Record<string, any>;
}

4. Pre-Registered Models

The following models are registered by default in the Model Registry:

Model IDNameTypeMetrics
lead-scoring-v1Lead Scoring ModelClassificationAccuracy: 87.5%, F1: 87.1%
churn-prediction-v1Churn Prediction ModelClassificationAccuracy: 82.3%, F1: 82.3%
sentiment-analysis-v1Sentiment AnalysisNLPAccuracy: 88.7%, F1: 88.6%
revenue-forecast-v1Revenue ForecastingForecastingMSE: 12,500, MAE: 8,200
product-recommendation-v1Product RecommendationRecommendationPrecision: 75.8%, Recall: 78.3%

5. Integration Diagram

graph TB
    subgraph "Business Modules"
        SALES["Sales Cloud"]
        HR["HR Cloud"]
        SERVICE["Service Cloud"]
        MARKETING["Marketing Cloud"]
    end

    subgraph "AI Cloud (@hotcrm/ai)"
        PS["Prediction Service"]
        MR["Model Registry"]
        CM["Cache Manager"]
        ES["Explainability Service"]
        PM["Performance Monitor"]
        GAR["GenAI Reporting"]
    end

    subgraph "ML Providers"
        OPENAI["OpenAI"]
        AWS["AWS SageMaker"]
        AZURE["Azure ML"]
        CUSTOM["Custom Models"]
    end

    SALES --> PS
    HR --> PS
    SERVICE --> PS
    MARKETING --> PS
    SALES --> GAR
    HR --> GAR

    PS --> MR
    PS --> CM
    PS --> PM
    PS --> ES
    PS --> OPENAI
    PS --> AWS
    PS --> AZURE
    PS --> CUSTOM

6. Shared Utilities

The utils.ts module exports mathematical and ML helper functions used across all predictions:

  • Scoring: calculateConfidence, normalizeScore, weightedAverage, sigmoid
  • Similarity: cosineSimilarity
  • Statistics: standardDeviation, detectOutliers, pearsonCorrelation
  • Time Series: movingAverage, exponentialSmoothing, calculateTrend
  • Preprocessing: minMaxScale, zScoreNormalize
  • Clustering: kMeansClustering

On this page