https://www.mdu.se/

mdu.sePublications
Planned maintenance
A system upgrade is planned for 17/11-2026, at 12:00-13:00. During this time DiVA will be unavailable.
Change search
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf
Automated C4 Diagram Generation from Source Code: Static-Analysis Grounding and the Consistency of Large Language Model Output
Mälardalen University, Faculty of Engineering and Health Sciences, Department of Computer Science & Engineering.
Mälardalen University, Faculty of Engineering and Health Sciences, Department of Computer Science & Engineering.
2026 (English)Independent thesis Advanced level (degree of Master (One Year)), 10 credits / 15 HE creditsStudent thesis
Abstract [en]

Software architectural documentation is frequently missing or outdated, and large language models (LLMs) are increasingly proposed as a way to recover architectural views from source code. A practical obstacle is that LLM output is not deterministic: repeated generation from the same input can yield different diagrams, even at temperature 0. This thesis studies this problem for the Container (C2) and Component (C3) levels of the C4 model, and investigates whether providing structural evidence extracted by static analysis changes how consistent LLM-generated diagrams are across repeated runs. The study measures consistency only; it does not assess whether the diagrams are architecturally correct. A five-stage pipeline (static-analysis extraction with Spoon, transformation into LLM input, prompt construction, LLM invocation, and output processing) was implemented and applied to three open-source Java projects of increasing size (jhipster ≈4,500 LOC, spring-boot-admin ≈15,300 LOC, apache-maven-3.9.15 ≈84,000 LOC). Three models (GPT-4.1 mini, GPT-4.1 nano, Gemini 2.5 Flash) were each given three input conditions: source code only, static analysis output only, and both combined. Every condition was run ten times, yielding 810 PlantUML diagrams. Consistency was measured as node and edge Jaccard similarity over all pairs of runs, after an automated, deterministic label-alignment procedure. Differences between conditions were tested with Wilcoxon signed-rank tests over model × project × target cells, with Holm correction. All 810 diagrams were syntactically valid PlantUML. Repeated generation was not deterministic: only 4 of 27 C2 conditions produced the same diagram in all ten runs. The combined condition had the highest mean C2 consistency (node Jaccard 0.83 versus 0.78 for source code only; edge Jaccard 0.71 versus 0.60), but none of the differences was statistically significant after Holm correction for multiple comparisons, and the effect of adding static analysis was positive for one model, negative for another and negligible for the third. At C3, consistency was high in all conditions (node Jaccard 0.92–0.97); however, for two of the three projects every run of every model produced an identical set of components, so the C3 differences stem almost entirely from the largest project. Gemini 2.5 Flash produced the most stable output overall and GPT-4.1 nano the least. Label normalisation changed the measured consistency by at most 0.032, which indicates that run-to-run variation is structural rather than terminological. The lowest consistency values were concentrated in outputs with large numbers of repeated declarations. Overall, adding static analysis did not reliably make LLM-generated architectural views more stable.

Place, publisher, year, edition, pages
2026. , p. 43
Keywords [en]
software architecture recovery, C4 model, static analysis, large language models, LLM non-determinism, output consistency, architectural views, PlantUML, Spoon, empirical evaluation
National Category
Software Engineering
Identifiers
URN: urn:nbn:se:mdh:diva-79405OAI: oai:DiVA.org:mdh-79405DiVA, id: diva2:2115043
Supervisors
Examiners
Available from: 2026-11-04 Created: 2026-11-03 Last updated: 2026-11-04Bibliographically approved

Open Access in DiVA

Automated C4 Diagram Generation from Source Code: Static-Analysis Grounding and the Consistency of Large Language Model Output(1268 kB)39 downloads
File information
File name FULLTEXT01.pdfFile size 1268 kBChecksum SHA-512
bd83f720aaedd1ce398a7966da9eb851b17dfa67256a7309f544d4199ebc490df47e5f76697f9c062cbb7857d5be4e72db23090290b3d6ba28edc304c6deeeab
Type fulltextMimetype application/pdf

Search in DiVA

By author/editor
Dokovic, ArbenRakocevic, Balsa
By organisation
Department of Computer Science & Engineering
Software Engineering

Search outside of DiVA

GoogleGoogle Scholar
Total: 39 downloads
The number of downloads is the sum of all downloads of full texts. It may include eg previous versions that are now no longer available

urn-nbn

Altmetric score

urn-nbn
Total: 14534 hits
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf