Software Engineering
Graph neural networks outperform simpler models at mapping code to software architecture
A new study shows that dependency graphs can significantly improve machine learning models' ability to automatically align source files with their intended architectural modules.
Maintaining accurate documentation of how code maps to the intended architecture of a system remains a persistent challenge in software engineering. When source files drift away from their planned modular structure, "architectural technical debt" accumulates—making systems harder to maintain and evolve. Researchers have now explored whether analyzing the dependency relationships between files can help machine learning models automatically recover these mappings.
The Problem: Incomplete Architecture Maps#
In many large systems, the relationship between source code files and architectural modules is missing, incomplete, or expensive to maintain by hand. This gap between intended design and actual implementation creates a form of technical debt. Recovering an accurate mapping would help teams understand and maintain their systems more effectively.
The Approach: Graph-Based Semi-Supervised Learning#
The research frames code-to-architecture mapping as a node classification problem over a dependency graph. Files serve as nodes, while typed dependencies (function calls, imports, etc.) form edges. The model also incorporates lexical features extracted from code identifiers and directory structure. Starting with a small sample of manually labeled files, an iterative self-training procedure expands predictions to unlabeled files.
Comparing Three Neural Models#
Researchers compared three machine learning approaches using identical features and training procedures:
- Graph Convolutional Network (GCN) — propagates information directly through dependency edges
- Graph Attention Network (GAT) — learns which dependencies matter most via attention mechanisms
- Multi-Layer Perceptron (MLP) — ignores the graph entirely and relies only on file features
All three neural models outperformed a Naive Bayes baseline across 100 runs on ten open-source Java and C/C++ systems. GAT achieved the highest average performance, reaching macro and micro F1 scores of 83.5 and 92.2, respectively. Interestingly, MLP remained competitive or superior on several smaller systems.