use super::super::types::*;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct KnowledgeGraph {
pub(crate) components: HashMap<String, StackComponent>,
pub(crate) capability_index: HashMap<String, Vec<String>>,
pub(crate) domain_capabilities: HashMap<ProblemDomain, Vec<String>>,
pub(crate) integrations: Vec<IntegrationPattern>,
}
impl Default for KnowledgeGraph {
fn default() -> Self {
Self::new()
}
}
impl KnowledgeGraph {
pub fn new() -> Self {
let mut graph = Self {
components: HashMap::new(),
capability_index: HashMap::new(),
domain_capabilities: HashMap::new(),
integrations: Vec::new(),
};
graph.initialize_domain_mappings();
graph
}
pub fn sovereign_stack() -> Self {
let mut graph = Self::new();
graph.register_sovereign_stack();
graph.register_integration_patterns();
graph
}
pub fn register_component(&mut self, component: StackComponent) {
let name = component.name.clone();
for cap in &component.capabilities {
self.capability_index
.entry(cap.name.clone())
.or_default()
.push(name.clone());
}
self.components.insert(name, component);
}
}