use crate::Vector;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CustomerEmbedding {
pub customer_id: String,
pub name: String,
pub segment: CustomerSegment,
pub purchase_history: Vec<Purchase>,
pub preferences: CustomerPreferences,
pub behavior_metrics: BehaviorMetrics,
pub embedding: Vector,
pub predicted_ltv: f64,
pub churn_risk: f64,
pub recommendations: Vec<ProductRecommendation>,
pub last_updated: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CustomerSegment {
HighValue,
Regular,
Occasional,
NewCustomer,
AtRisk,
Churned,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Purchase {
pub product_id: String,
pub purchase_date: DateTime<Utc>,
pub quantity: u32,
pub price: f64,
pub channel: PurchaseChannel,
pub satisfaction: Option<u8>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum PurchaseChannel {
Online,
InStore,
Mobile,
Phone,
ThirdParty,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CustomerPreferences {
pub preferred_categories: Vec<String>,
pub price_sensitivity: f64,
pub brand_loyalty: HashMap<String, f64>,
pub preferred_channels: Vec<PurchaseChannel>,
pub communication_preferences: CommunicationPreferences,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommunicationPreferences {
pub email_opt_in: bool,
pub sms_opt_in: bool,
pub frequency: CommunicationFrequency,
pub content_types: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum CommunicationFrequency {
Daily,
Weekly,
Monthly,
Quarterly,
Never,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BehaviorMetrics {
pub visit_frequency: f64,
pub avg_session_duration: f64,
pub avg_products_viewed: f64,
pub cart_abandonment_rate: f64,
pub return_visit_rate: f64,
pub referral_rate: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProductRecommendation {
pub product_id: String,
pub score: f64,
pub reason: RecommendationReason,
pub confidence: f64,
pub expected_revenue: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum RecommendationReason {
SimilarProducts,
CustomersBought,
PopularInCategory,
PersonalizedPreference,
TrendingNow,
SeasonalRecommendation,
}