How Stuff Works

Ville Laitila on March 27, 2019

This page explains how Softagram (the product) works. Automated production of code change visualization is the core focus of Softagram, so this article covers that process in detail.

Analyzers

The first phase is the source code analysis. The analysis is performed on a server instance (inside Docker container), on-premises or cloud (https://private.softagram.com or https://opensource.softagram.com). The analysis is multi-stage phase of running multiple code measurement analyzers such as dependency analyzers, LOC analyzers, Git history analyzers, technical debt analyzer etc. Shortly, it is about static analysis for source code of the most popular mainstream languages. The process gets triggered by pull request webhook event (originating from the service that hosts the Git repository such as Github). There is also a scheduler that supports polling the branches of Git repositories and adding an analysis job to the queue whenever new commits appear.

Model handling

The output of the analysis is a model. The model does not contain the source code, but a generalization of the source code, using hierarchical graph data model. A software entity (e.g. a file or a class) is represented as a node with attributes and links to other nodes. The system is thus capable of handling software entities of any programming languages, given that the suitable analyzer exists. In automated code review case, the handling is not based on one model but two, head and base models, in order to successfully find out the actual impact of a pull request.

Code change visualization

With help of a built-in query language, model filtering and comparison functionality, the differences between two models are searched and filtered. This is especially important in automated code review case, where the system needs to highlight architectural changes (such as new dependencies) introduced by the pull request author. Other refinery actions such as dependency rule verification will refine the nodes of the model with additional attributes, such as rule violation attributes in the case of rule verification.

The visualization engine of Softagram has been finetuned for building fitting visualizations (with suitable dimensions for humans) with help of generalization and layout algorithms.

Sending the results as a comment

Markdown/HTML content is created to embed the visualizations and integrate them into the PR comment feed. If the same pull request is re-analyzed (after a new commit), Softagram keeps sure that the original comment is edited to have the latest pictures instead of creating more and more comments.

The building blocks of Softagram

Indeed, Softagram uses same core model engineering and visualization engine in both code review automation and Softagram Desktop use cases. The application (Softagram Desktop) is a cross-platform viewer app that authenticates with the given server instance and acts as a model viewer for advanced use cases such as doing software audits, getting familiar with new code bases and finding architectural bottlenecks.

Softagram Desktop: softagram.com/desktop

Installer for Softagram on-premises installation: ask support AT softagram.com

Ville, Softagram

If you got interested in Softagram, it is easy to try out for private projects in the cloud.

 

 

Read more