Skip to main content

oxirs_embed/
enterprise_knowledge.rs

1//! Enterprise Knowledge Graphs - Business Domain Embeddings
2//!
3//! This module provides specialized embeddings and analysis for enterprise knowledge graphs,
4//! including product catalogs, organizational knowledge, employee skill embeddings, and
5//! recommendation systems for business applications.
6//!
7//! This is a thin facade over the focused companion modules. The
8//! [`EnterpriseKnowledgeAnalyzer`] struct is defined here so that its inherent
9//! methods can be split across companion modules, while all domain types are
10//! re-exported from:
11//! - [`enterprise_knowledge_config`](crate::enterprise_knowledge_config): analyzer
12//!   and recommendation configuration.
13//! - [`enterprise_knowledge_product`](crate::enterprise_knowledge_product): product,
14//!   category, and sales types.
15//! - [`enterprise_knowledge_employee`](crate::enterprise_knowledge_employee): employee,
16//!   skill, organizational, and project types.
17//! - [`enterprise_knowledge_customer`](crate::enterprise_knowledge_customer): customer,
18//!   purchase, preference, and recommendation types.
19//! - [`enterprise_knowledge_engine`](crate::enterprise_knowledge_engine): recommendation
20//!   engine, market analysis, and enterprise metrics types.
21//!
22//! The analyzer's public methods live in
23//! [`enterprise_knowledge_analyzer`](crate::enterprise_knowledge_analyzer) and its private
24//! helpers, background tasks, and metrics live in
25//! [`enterprise_knowledge_analyzer_helpers`](crate::enterprise_knowledge_analyzer_helpers).
26
27pub use crate::enterprise_knowledge_config::*;
28pub use crate::enterprise_knowledge_customer::*;
29pub use crate::enterprise_knowledge_employee::*;
30pub use crate::enterprise_knowledge_engine::*;
31pub use crate::enterprise_knowledge_product::*;
32
33use std::collections::HashMap;
34use std::sync::{Arc, RwLock};
35use tokio::task::JoinHandle;
36
37/// Enterprise knowledge graph analyzer and embedding generator
38pub struct EnterpriseKnowledgeAnalyzer {
39    /// Product catalog embeddings
40    pub(crate) product_embeddings: Arc<RwLock<HashMap<String, ProductEmbedding>>>,
41    /// Employee embeddings
42    pub(crate) employee_embeddings: Arc<RwLock<HashMap<String, EmployeeEmbedding>>>,
43    /// Customer embeddings
44    pub(crate) customer_embeddings: Arc<RwLock<HashMap<String, CustomerEmbedding>>>,
45    /// Product categories and hierarchies
46    pub(crate) category_hierarchy: Arc<RwLock<CategoryHierarchy>>,
47    /// Organizational structure
48    pub(crate) organizational_structure: Arc<RwLock<OrganizationalStructure>>,
49    /// Recommendation engines
50    pub(crate) recommendation_engines: Arc<RwLock<HashMap<String, RecommendationEngine>>>,
51    /// Configuration
52    pub(crate) config: EnterpriseConfig,
53    /// Background analysis tasks
54    pub(crate) analysis_tasks: Vec<JoinHandle<()>>,
55}
56
57impl EnterpriseKnowledgeAnalyzer {
58    /// Create new enterprise knowledge analyzer
59    pub fn new(config: EnterpriseConfig) -> Self {
60        Self {
61            product_embeddings: Arc::new(RwLock::new(HashMap::new())),
62            employee_embeddings: Arc::new(RwLock::new(HashMap::new())),
63            customer_embeddings: Arc::new(RwLock::new(HashMap::new())),
64            category_hierarchy: Arc::new(RwLock::new(CategoryHierarchy {
65                categories: HashMap::new(),
66                parent_child: HashMap::new(),
67                category_embeddings: HashMap::new(),
68            })),
69            organizational_structure: Arc::new(RwLock::new(OrganizationalStructure {
70                departments: HashMap::new(),
71                teams: HashMap::new(),
72                reporting_structure: HashMap::new(),
73                projects: HashMap::new(),
74            })),
75            recommendation_engines: Arc::new(RwLock::new(HashMap::new())),
76            config,
77            analysis_tasks: Vec::new(),
78        }
79    }
80}