A small companion tool on top of clang-uml that turns huge C++ UML outputs into small, meaningful diagrams.
Instead of staring at a giant *.puml hairball, you get:
- Focused namespace / module views
- Automatically detected communities of related classes
- Layer views (API / Service / Core, etc.)
- Importance-based views (PageRank)
- Sequence diagrams generated from clang-uml JSON
- A lightweight HTML dashboard and analysis report with SVG/PUML links
-
Multi‑view UML generation (class diagrams)
- Namespace-based diagrams (
namespace_*) - Community-based diagrams (
community_*) via Louvain clustering - Layer diagrams (
layer_api,layer_service,layer_core, …) - Importance view (
importance) using PageRank - Optional hotspot/god‑class views for refactoring targets
- Namespace-based diagrams (
-
Sequence diagram support
- Parses clang-uml sequence diagram JSON (schema v3)
- Generates focused PlantUML sequence diagrams
- Can be run independently from class-diagram mode
-
Graph‑based analysis
- Builds a directed graph from
clang-umlJSON (classes + relationships) - PageRank, degree and betweenness centrality
- Louvain community detection
- Namespace‑level cohesion/coupling metrics
- Builds a directed graph from
-
Developer‑friendly output
- Multiple small
*.pumlfiles instead of one unreadable giant - Automatic SVG rendering via PlantUML
- Smart
index.html:- If SVG exists → “View Diagram (SVG)” link
- Always offers a PUML fallback if the file exists
analysis_report.mdwith high‑level metrics
- Multiple small
This project assumes you already use clang-uml to extract UML information from your C++ codebase.
Typical flow:
- Build your C++ project and generate
compile_commands.json - Run
clang-umlto produce JSON + PlantUML outputs (class / sequence) - Point this tool at the JSON file
- Open the generated
index.htmland navigate through small, focused diagrams
# Create and activate a virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
uv pip install -r requirements.txtRequired Python libraries:
networkxpython-louvainpyyamlnumpyscipy- (optional)
matplotlib
Follow the official installation guide here:
clang-umlGitHub repo- Documentation:
https://clang-uml.github.io
On macOS, for example:
brew install clang-umlcd your_cpp_project
mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
# Run clang-uml to generate JSON
clang-uml -g json -g plantumlThen run the analyzer:
cd /path/to/uml_analyzer_repo
source .venv/bin/activate
python -m uml_analyzer.main \
-i /absolute/path/to/your/class_diagram.json \
-o /absolute/path/to/output/views
open /absolute/path/to/output/views/index.htmlpython -m uml_analyzer.main \
-i /absolute/path/to/your/sequence_diagram.json \
-o /absolute/path/to/output/sequence_viewsThis automatically detects diagram_type: "sequence" and generates a PlantUML sequence diagram (and SVG if enabled).
All behavior is driven by config.yaml. Example:
input:
json_file: "path/to/diagram.json"
output:
directory: "output/views"
generate_svg: true
plantuml_jar: "~/bin/plantuml.jar"
generate_index: true
views:
namespace:
enabled: true
min_nodes: 2
community:
enabled: true
min_size: 3
hotspot:
enabled: true
min_degree: 5
min_complexity: 10
include_neighbors: true
importance:
enabled: true
top_n: 15
metric: "pagerank"
include_neighbors: true
layer:
enabled: true
layers:
api: "your::namespace::api"
service: "your::namespace::service"
core: "your::namespace::core"
diagram:
show_members: true
show_methods: true
group_by_namespace: trueYou can tune thresholds (e.g. what counts as a hotspot) based on your project size.
If you want to script your own workflows on top of the graph:
from pathlib import Path
from uml_analyzer import (
ClangUMLParser,
GraphBuilder,
GraphAnalyzer,
DiagramFilter,
PumlGenerator,
)
parser = ClangUMLParser()
data = parser.parse_file(Path("path/to/class_diagram.json"))
builder = GraphBuilder(data)
analyzer = GraphAnalyzer(builder.get_graph())
filter_ = DiagramFilter(data, builder, analyzer)
# Example: context view around a core service
nodes = filter_.create_context_view(
center_class_name="UserService",
max_hops=2,
direction="both",
)
generator = PumlGenerator(data, builder)
generator.save_puml(
node_ids=nodes,
output_path=Path("output/UserService_context.puml"),
title="UserService Context View",
)For sequence diagrams:
from pathlib import Path
from uml_analyzer import SequenceDiagramParser, SequenceDiagramGenerator
parser = SequenceDiagramParser()
data = parser.parse_file(Path("path/to/sequence_diagram.json"))
generator = SequenceDiagramGenerator(data)
generator.save_puml(
output_path=Path("output/login_sequence.puml"),
title="User Login Flow",
)The code in this repository (the multiview analyzer itself) is licensed under the MIT License.