1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! Product, category, and sales-related types for enterprise knowledge.
use crate::Vector;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Product embedding with business context
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProductEmbedding {
/// Product unique identifier
pub product_id: String,
/// Product name
pub name: String,
/// Product description
pub description: String,
/// Product category
pub category: String,
/// Subcategories
pub subcategories: Vec<String>,
/// Product features
pub features: Vec<ProductFeature>,
/// Price information
pub price: f64,
/// Availability status
pub availability: ProductAvailability,
/// Sales metrics
pub sales_metrics: SalesMetrics,
/// Customer ratings
pub ratings: CustomerRatings,
/// Product embedding vector
pub embedding: Vector,
/// Similar products
pub similar_products: Vec<String>,
/// Market position score
pub market_position: f64,
/// Last updated
pub last_updated: DateTime<Utc>,
}
/// Product feature information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProductFeature {
/// Feature name
pub feature_name: String,
/// Feature value
pub feature_value: String,
/// Feature type
pub feature_type: FeatureType,
/// Feature importance score
pub importance_score: f64,
}
/// Types of product features
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FeatureType {
Categorical,
Numerical,
Boolean,
Text,
List,
}
/// Product availability status
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ProductAvailability {
InStock(u32),
OutOfStock,
Discontinued,
PreOrder(DateTime<Utc>),
Limited(u32),
}
/// Sales metrics for products
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SalesMetrics {
/// Total units sold
pub units_sold: u64,
/// Revenue generated
pub revenue: f64,
/// Sales velocity (units per day)
pub sales_velocity: f64,
/// Conversion rate
pub conversion_rate: f64,
/// Return rate
pub return_rate: f64,
/// Profit margin
pub profit_margin: f64,
}
/// Customer ratings and reviews
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CustomerRatings {
/// Average rating (1-5)
pub average_rating: f64,
/// Total number of reviews
pub review_count: u32,
/// Rating distribution
pub rating_distribution: HashMap<u8, u32>,
/// Sentiment score (-1 to 1)
pub sentiment_score: f64,
}
/// Category hierarchy structure
#[derive(Debug, Clone)]
pub struct CategoryHierarchy {
/// Category tree
pub categories: HashMap<String, Category>,
/// Category relationships
pub parent_child: HashMap<String, Vec<String>>,
/// Category embeddings
pub category_embeddings: HashMap<String, Vector>,
}
/// Category information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Category {
/// Category ID
pub category_id: String,
/// Category name
pub name: String,
/// Parent category
pub parent: Option<String>,
/// Child categories
pub children: Vec<String>,
/// Products in this category
pub products: Vec<String>,
/// Category attributes
pub attributes: HashMap<String, String>,
/// Category performance metrics
pub performance: CategoryPerformance,
}
/// Category performance metrics
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CategoryPerformance {
/// Total sales
pub total_sales: f64,
/// Product count
pub product_count: u32,
/// Average rating
pub average_rating: f64,
/// Growth rate
pub growth_rate: f64,
/// Market share
pub market_share: f64,
}