How expediagroup/jarviz works
Project Type & Purpose
• Jarviz is a multi‐module, open‐source dependency‐analysis tool for Java bytecode.
• Purpose: scan JAR/WAR artifacts, extract method‐level coupling data (JSONL), and render it as an interactive HTML graph via a Node.js component, all orchestrated by a shell CLI.
File Structure
• Top‐level modules:
– jarviz-lib (Java library, Maven project)
– jarviz-graph (Node.js/TypeScript or JavaScript project, npm‐based)
– jarviz-cli (Bash/POSIX shell wrapper)
• build-config holds CI/CD and Maven settings; GitHub workflows for build, test, release.
• jarviz-lib/src contains packages for config, model, service, util, visitor → indicates a service‐oriented, visitor‐pattern–based bytecode analyzer using ASM.
• jarviz-graph/lib/client contains static HTML/JS/CSS → the front‐end graph renderer.
• jarviz-cli/jarviz is the shell script orchestrating Java and Node tools.
Extract Architecture Insights from README
• Three distinct components → clear separation of concerns.
• jarviz-lib uses ASM to analyze bytecode, outputs JSON Lines (.jsonl).
• jarviz-graph reads JSONL, produces a self‐contained HTML graph.
• jarviz-cli glues both pieces together via command‐line arguments and sample JSON configs (artifacts.json, filter.json).
Main Components & Their Interactions
A. External Inputs & Platforms
– Java runtime + Maven (for jarviz-lib)
– Node.js + npm (for jarviz-graph)
– Shell environment (for jarviz-cli)
– Artifacts to analyze (JAR/WAR files)
– JSON config files: artifacts.json, filter.json
B. Jarviz Library (jarviz-lib)
– Services: ArtifactDiscoveryService, ClassLoaderService, CouplingAnalyser
– Workflow: load artifacts → custom classloader → ASM visitor (FilteredClassVisitor, FilteredMethodVisitor) → collect MethodCoupling records → JsonUtils → write JSONL
C. Jarviz Graph Tool (jarviz-graph)
– Node.js process reads JSONL → lib/index.js → transforms data → write-to-disk → produces index.html + graph.js + CSS → uses client‐side D3/force‐layout (graph.js)
D. Jarviz CLI (jarviz-cli)
– Shell script “jarviz” parses CLI args → invokes jarviz-lib’s AnalyzeCommand (via java -cp) to emit JSONL → invokes jarviz-graph bin/index.js (via node) to produce HTML → opens or saves output
E. Outputs
– .jsonl coupling data file
– .html interactive graph
Architectural Patterns & Design Principles
• Modularization: each component lives in its own module (Java, Node, Shell).
• Visitor pattern in jarviz-lib (ASM visitors).
• Service locator / dependency‐injection (JarvizServiceLocator).
• Pipeline/producer‐consumer: jarviz-lib produces JSONL → jarviz-graph consumes it.
• CLI orchestration adheres to Unix philosophy (small, composable tools).
• Configuration‐driven (filter.json, artifacts.json).
Final Checklist
• External dependencies/platforms (Java VM, Node.js, Maven, npm).
• Configuration inputs (JSON configs, command‐line flags).
• Patterns (visitor, service‐locator, pipeline).