DEV Community

Cover image for Visualizing Web Architecture: Why I Spent 2 Years Building an Interactive Graph Tool for Angular
Dmitry Kostyuk
Dmitry Kostyuk

Posted on

Visualizing Web Architecture: Why I Spent 2 Years Building an Interactive Graph Tool for Angular

This is the first part of a series on visualizing Web architecture and building **GraphLens* – a local static analysis tool for Angular. In the upcoming parts, I will cover the source code exploration algorithm, the custom parser design, working with the TypeScript Language Server, and the concept of Code Liquidity.*

Six Steps Just to Find Where the Data Comes From

Imagine a routine task in a large Angular application consisting of hundreds of files: you need to determine which parent component passes data into a specific @Input / input() property and trace it a couple of levels up the tree. Previously, my workflow looked like this:

  1. Copy the current component's selector
  2. Run a global search for that selector across the entire workspace
  3. Filter the results to find the parent component templates relevant to the current task
  4. Open the matched component's template
  5. Locate its corresponding component class in the file explorer
  6. Find the bound property and match it back to the original @Input / input()

A single pass does not take long, yet it drains your cognitive resources. Add a few more hops up the tree, verify component availability across imported modules, and layer Injectable services on top – and a developer's "working memory" quickly overflows. The details you were just holding in your head start to lose clarity.

The first practical need for a tool that could show how a project is structured – not as a wall of source code or even a text explanation (as AI tools provide today), but as a clear visual graph – arose even earlier, while I was learning the Angular Router. Back then, I simply wanted to observe how my changes in wiring and configuring root and lazy-loaded modules affected the resulting route map.

Later, this need solidified through systematic work across different business domains within the same application. Each time, I had to reconstruct a mental map of component relationships and module visibility almost from scratch, and hold that picture clearly for the duration of a task – assuming an ideal world with no context switching. At the time, NgModule was used everywhere, which added its own layer of complexity. Although I remain a fan of Angular modules for their strict separation of a project into business domains and feature boundaries, the framework is actively moving toward the Standalone API today – and the fundamental challenge of understanding a project's real structure remains just as relevant.

From Simulink to Clean Architecture

Shortly before that, I already had experience with graphical modeling and programming environments such as Simulink and LabVIEW – tools where the structure of a system is immediately visible. However, a real shift in understanding happened when I translated one of my Simulink models into text-based MATLAB code (you can see examples here and here). At that moment, the relationship between the textual and graphical representations of the exact same system became literally tangible.

This perspective was later reinforced by the introduction to Robert C. Martin's Clean Architecture, where architecture is described as something intangible and difficult to visualize, yet objectively real – something that directly shapes the fate of thousands of projects and determines whether they can continue to evolve.

Looking at today's complex software systems – video games, operating systems, industrial control software – it is tempting to ask: how is it even possible to build them while operating with something as intangible as software architecture? That is a hyperbolic form of the question, of course, since this software clearly exists. A more realistic question is: at the cost of what resources is this achieved?

As humans, developers operate within hard biological limits: finite cognitive bandwidth for absorbing, understanding, and contributing to a codebase, a narrow focus of working memory (around 7 ± 2 items at once according to Miller's classic law, or closer to 4 ± 1 in Cowan's more recent research), and a rapidly fading short-term context. Add business constraints on top of that (more on this another time), and the conclusion is clear: we should not overestimate our internal resources. It is far better to approach them realistically, pragmatically, and proactively.

Engineering has always solved this challenge with tools that make the invisible visible: architectural blueprints, circuit schematics, oscilloscopes, and profilers. They do not replace an engineer's thinking – they extend our capabilities and the scale of systems we are able to manage.

A One-Month Plan That Took Two Years

I decided to take the same proactive approach. Initially, I envisioned a small tool to accelerate my own workflow: quickly tracing component and directive chains and clearly visualizing navigation flows in Angular projects.

The original working name was TopView (mentioned publicly here for the first time) – representing a way to step beyond the wall of source code and view the project from above. I estimated a laughable 1 month to build it. In reality, reaching the first public release that met my standards took 2 years, and I am still actively developing it today.

Eventually, the project was named GraphLens – by analogy with an optical lens that focuses an Angular codebase and projects its architecture into a set of interactive graphs.

What GraphLens Is and How It Works Under the Hood

GraphLens is a static source code analyzer and an interactive architecture visualizer for Angular projects, supporting both NgModule-based and Standalone architectures. It runs completely locally and privately – no AI, no code leaving your local machine – always returning a deterministic result within seconds to a couple of minutes, depending on workspace size. It is built as a VS Code extension so developers can stay in their familiar workspace without switching contexts or relying on external utilities.

Here is how the analyzer explores a workspace under the hood:

  • Automatic startup and graph traversal: When you open a workspace, the extension detects angular.json and starts analyzing its projects (currently applications are supported, with library support coming up next). Starting from each application's entry file, connections are expanded using Breadth-First Search (BFS) based on a formal classification of Angular software entities and the ways they connect.
  • TypeScript Language Server integration: To locate related entities, GraphLens relies on built-in VS Code commands – vscode.executeDefinitionProvider and vscode.executeReferenceProvider. Tuning them to work reliably during a TypeScript Language Server cold start became a dedicated engineering task.
  • A custom "shallow" parser: Static code analysis is performed by a custom-built parser that accounted for roughly 40% of the total development time. It parses source code only to the minimum depth required without constructing unnecessary AST details, which resulted in significant performance gains.

In the next part of this series, I will dive deeper into the architecture of this parser and how I addressed the TypeScript Language Server cold start.

How It Solves This in Practice

To address the original challenge of navigating relationships and architectural layers, GraphLens presents your project structure through three synchronized views:

  1. An interactive graph in the GraphView panel right within the editor area.
  2. A Structure Tree in the VS Code sidebar.
  3. A list of related entities directly in the Command Palette.

Here is what a complex relationship involving content projection between TitleComponent, TitleContainerComponent, and AppComponent looks like in the open demo project, which you can clone and test yourself:

  1. Interactive Component Tree graph in GraphView
    Interactive Component Tree graph in GraphView

  2. Structure Tree in the sidebar
    Structure Tree in the sidebar

  3. Relations list in the Command Palette
    Relations list in the Command Palette

Finding parent components and tracing relationships now become trivial tasks. You no longer need to keep the entire chain in your head while reading code – it is always right there, just a couple of clicks or keystrokes away.

The Boundary of the Unknown

Did this solve all of my practical needs? No – but it covered the foundational ones. It works much like the circle of knowledge: the more its area expands, the longer its circumference – the boundary with the unknown – becomes. The basic needs are addressed, and more complex layers are next in line: library support, visualizing the Dependency Injection map and injector hierarchy (that picture promises to be quite impressive!), and further ahead, Code Liquidity metrics reflecting a codebase's ability to absorb changes driven by new business requirements quickly and safely.

You can try the extension and explore the full list of features and limitations on the VS Code Marketplace, Open VSX Registry, and in the public repository.

I firmly believe that any source code is, first and foremost, a set of interconnected elements – though only real-world, day-to-day usage can prove how much value visualizing them brings. How do you currently navigate an unfamiliar or overgrown codebase: global search, mental maps, AI summaries, or visual graphs? I would be happy to hear your experience and thoughts on architecture visualization in the comments.

Top comments (0)