init: archlens — architecture diagram generator
Some checks failed
CI / Check / Test (push) Failing after 1m24s

Hex arch + DDD, tree-sitter parsing, Mermaid/ASCII output.
Supports Rust + Python. 92 tests. CI, diff, --check for staleness detection.
This commit is contained in:
2026-06-16 16:13:04 +02:00
commit 35f27d00b0
106 changed files with 6744 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
use archlens_domain::{CodeGraph, DomainError, RenderOutput, RenderedFile, ports::DiagramRenderer};
pub struct FakeDiagramRenderer;
impl FakeDiagramRenderer {
pub fn new() -> Self {
Self
}
}
impl DiagramRenderer for FakeDiagramRenderer {
fn render(&self, graph: &CodeGraph) -> Result<RenderOutput, DomainError> {
let content = format!("graph with {} elements", graph.elements().len());
let file = RenderedFile::new("output.mmd", &content)?;
Ok(RenderOutput::single(file))
}
}

View File

@@ -0,0 +1,27 @@
use std::path::Path;
use archlens_domain::{AnalysisConfig, DomainError, SourceFile, ports::FileDiscovery};
pub struct FakeFileDiscovery {
files: Vec<SourceFile>,
}
impl FakeFileDiscovery {
pub fn new(files: Vec<SourceFile>) -> Self {
Self { files }
}
pub fn empty() -> Self {
Self { files: Vec::new() }
}
}
impl FileDiscovery for FakeFileDiscovery {
fn discover(
&self,
_root: &Path,
_config: &AnalysisConfig,
) -> Result<Vec<SourceFile>, DomainError> {
Ok(self.files.clone())
}
}

View File

@@ -0,0 +1,9 @@
mod diagram_renderer;
mod file_discovery;
mod output_writer;
mod source_analyzer;
pub use diagram_renderer::FakeDiagramRenderer;
pub use file_discovery::FakeFileDiscovery;
pub use output_writer::FakeOutputWriter;
pub use source_analyzer::FakeSourceAnalyzer;

View File

@@ -0,0 +1,26 @@
use std::cell::RefCell;
use archlens_domain::{DomainError, RenderOutput, ports::OutputWriter};
pub struct FakeOutputWriter {
written: RefCell<Vec<RenderOutput>>,
}
impl FakeOutputWriter {
pub fn new() -> Self {
Self {
written: RefCell::new(Vec::new()),
}
}
pub fn written_outputs(&self) -> Vec<RenderOutput> {
self.written.borrow().clone()
}
}
impl OutputWriter for FakeOutputWriter {
fn write(&self, output: &RenderOutput) -> Result<(), DomainError> {
self.written.borrow_mut().push(output.clone());
Ok(())
}
}

View File

@@ -0,0 +1,43 @@
use std::collections::HashMap;
use archlens_domain::{AnalysisResult, DomainError, SourceFile, ports::SourceAnalyzer};
enum FakeResponse {
Success(AnalysisResult),
Failure(DomainError),
}
pub struct FakeSourceAnalyzer {
results: HashMap<String, FakeResponse>,
}
impl FakeSourceAnalyzer {
pub fn new() -> Self {
Self {
results: HashMap::new(),
}
}
pub fn with_result(mut self, file_path: &str, result: AnalysisResult) -> Self {
self.results
.insert(file_path.to_string(), FakeResponse::Success(result));
self
}
pub fn with_error(mut self, file_path: &str, error: DomainError) -> Self {
self.results
.insert(file_path.to_string(), FakeResponse::Failure(error));
self
}
}
impl SourceAnalyzer for FakeSourceAnalyzer {
fn analyze_file(&self, file: &SourceFile) -> Result<AnalysisResult, DomainError> {
let key = file.path().as_str().to_string();
match self.results.get(&key) {
Some(FakeResponse::Success(result)) => Ok(result.clone()),
Some(FakeResponse::Failure(_)) => Err(DomainError::AnalysisError(key)),
None => Ok(AnalysisResult::empty()),
}
}
}