DEV Community

Ishaan
Ishaan

Posted on

I got tired of getting lost in 10,000-file codebases, so I built a 3D visualization engine.

Whenever I join a new project, reading the codebase top-to-bottom feels impossible. Code isn't linear. It's a massive, tangled web of hundreds of files, circular dependencies, and hidden logic.

I wanted a way to just "fly through" an architecture to see how everything connects.

So over the last few weeks, I built Software MRI β€” an open-source, 100% local Electron app that parses directories using Abstract Syntax Trees (ASTs) and renders a massive 3D force-directed graph.

Here is how I built it, and the technical hurdles I had to overcome.


πŸ—οΈ The Architecture (Under the Hood)

Software MRI uses a chunked, multi-layered static analysis pipeline.

Because I built this in Electron, I was able to split the workload between the Node.js backend and the Chromium frontend.

  1. The Parser (Main Process):
    I use tree-sitter (compiled to WebAssembly) to parse the code of over 300+ programming languages locally. It rips through the codebase, extracting every import, export, and function definition without ever sending your proprietary code to a cloud server.

  2. The Disease Analyzer:
    Once the AST is built, I run basic graph traversal algorithms (like Tarjan’s strongly connected components) to detect "diseases"β€”things like circular dependencies or massive cyclomatic complexity spikes.

  3. The Physics Engine (Renderer Process):
    This is where things got tricky.


🏎️ Overcoming the UI Freeze

The biggest challenge I faced was the UI freezing when analyzing massive monolithic repos (like VS Code or the Linux Kernel).

If you try to run a d3-force-3d simulation on 10,000 nodes on the main thread, the browser window will completely lock up.

To solve this, I had to push the entire physics simulation into a background WebWorker. The WebWorker calculates the coordinate ticks in the background and streams the updated [x, y, z] positions back to the main thread in chunks.

🌌 Aggressive Level-of-Detail (LOD)

Even with WebWorkers handling the physics, rendering 10,000 text labels and 50,000 connecting lines in Three.js will melt your GPU.

I implemented an aggressive custom LOD (Level of Detail) camera system:

  • Zoomed Out: Files render as single instanced points (handling 10K+ nodes at a buttery smooth 60fps).
  • Flying In: As the camera gets closer, the points resolve into 3D spheres.
  • Close Up: Text labels appear, and the actual code reveals itself.

On top of this, the "diseased" files (the ones with circular dependencies) are given a custom glowing red WebGL shader so you can spot architectural flaws visually from a mile away.


πŸš€ Try it yourself!

I open-sourced the entire project today. You can download the Windows .exe directly from the Releases page, drag-and-drop your biggest local repository into it, and watch it come alive!

πŸ’» GitHub Repo & Download: Ishaan-Sharma-tech/software-mri
🌐 Live Website: Software MRI Landing Page

I would absolutely love to hear your feedback on the architecture, or if you have any ideas on how I can optimize the AST parsing even further! Drop a comment below. πŸ‘‡

Top comments (0)