Skip to content

Repository files navigation

CI/CD pipeline

Code Architecture Analyzer

Code Architecture Analyzer is a static analysis tool designed to automatically evaluate the architectural and high-level design quality of large-scale software projects. Developed as a Bachelor's thesis project at ELTE, the software transforms source code into a unified, language-agnostic component graph and applies network theory algorithms, architectural rules, and LLM to detect design flaws.

Key Features

The analyzer processes source code written in C, C++, C#, Java, JavaScript, TypeScript, and Python.

The analysis pipeline consists of the following steps:

  • AST Parsing: Uses tree-sitter to parse the source code into an AST.
  • Graph Construction: Maps the AST into a directed, labeled multigraph. Nodes represent logical units (modules, classes, interfaces, functions, methods, attributes). Edges represent dependencies (contains, imports, inherits, implements, calls, references).
  • Network Analysis: Utilizes the igraph library to calculate complex graph metrics.
  • AI Integration: Optionally integrates Gemini LLM to assist in semantic analysis, discovering hidden entry points, and detecting complex anti-patterns that static analysis alone cannot catch.
  • Interactive UI: Features a local web-based interface (built with Flask, pywebview, and Cytoscape.js) to visually filter and explore the dependency graph.
depedency_graph
Filtered modular dependency graph

Calculated Metrics & Anti-Patterns

The tool evaluates the codebase across multiple dimensions, scores to provide quality groupings (Modularity, Structural Complexity, Object-Oriented Design, Resilience).

Metrics

  • Modularity: Q-modularity, Modularization Quality, Clustered Cost.
  • Structural Complexity: Propagation Cost, Clustering Coefficient, NodeRank (PageRank-like importance for functions/modules), Betweenness Centrality.
  • OO Metrics: Tight Class Cohesion, Lack of Cohesion (LCOM4), Coupling Between Objects, Distance from the Main Sequence.
  • Resilience Degeneracy, Propagation Cost.

Antipattern detection

  • Code Smells: The Blob (God Object), Spaghetti Code, Swiss Army Knife, Cut-and-paste programming (Duplication).
  • AI-Assisted Smells: Lava Flow (Dead Code) and Functional Decomposition.
  • SOLID/Design Rules: Acyclic Dependencies Principle, Stable Dependencies Principle, Dependency Inversion Principle, Interface Segregation Principle.
redis_cycle
Depedency cycle found in Redis open-source codebase

Installation

Running the project requires Python 3.10 or higher.

  1. Download the latest .whl installer file from the Releases page.
  2. Open your terminal in the download folder.
  3. Install the package using pip (replace with the current version):
    pip install code_arch_analyzer-<version>-py3-none-any.whl
    
    

Start the application by running the following command in your terminal:

analyzer-start

The graphical user interface will open automatically.

About

A static analysis tool that transforms source code from 7 languages into a component graph to evaluate architectural quality, detect anti-patterns, and calculate network metrics using graph theory and LLM support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages