mod html;
mod layout;
mod markdown;
mod sections;
mod tables;
use crate::engine::Weavatrix;
use blazingly_json::{Value, json};
const ENGINE: &str = env!("CARGO_PKG_VERSION");
pub struct Report {
pub markdown: String,
pub html: String,
pub data: Value,
}
pub fn compose(engine: &mut Weavatrix) -> Result<Report, String> {
let evidence = sections::gather(engine)?;
let summary = tables::summary(&evidence);
let sections = tables::sections(&evidence);
Ok(Report {
markdown: markdown::render(&summary, §ions, evidence.depth, ENGINE),
html: html::render(&summary, §ions, &evidence, ENGINE),
data: data(&evidence),
})
}
fn data(evidence: §ions::Evidence) -> Value {
json!({
"schema": "weavatrix.report.v1",
"engine": ENGINE,
"graph_stats": evidence.stats,
"verify_architecture": evidence.architecture,
"god_nodes": evidence.hubs,
"hot_path_review": evidence.hot,
"find_dead_code": evidence.dead,
"find_duplicates": evidence.duplicates,
"list_endpoints": evidence.endpoints,
"n8n_inventory": evidence.workflows,
"dify_inventory": evidence.apps,
"module_map": {
"depth": evidence.depth,
"modules": evidence.modules.iter().map(|module| json!({
"path": module.path,
"files": module.files,
"symbols": module.symbols,
"violations": module.violations,
"x": module.position.0,
"y": module.position.1
})).collect::<Vec<_>>(),
"links": evidence.links.iter().map(|(from, to, weight)| json!({
"from": from,
"to": to,
"weight": weight
})).collect::<Vec<_>>()
}
})
}