Codegraph – static code analyzator / code diagramer
github.com
github.com
Other posts in this thread are touching on it, but graph layout and layer segmentations are where you could improve.
Screen real-estate is the biggest challenge when visualizing large amounts of code.
Similar to maps show different detail levels based on aspect ratio and zoom, you can decompose your "features" (mapping terminology) based on level, i.e. packages->modules->functions->code
OP, have you ever used Gephi? I used to build static analysis tools for viz of large-scale codebases. Taking a bit of time to export analysis data into a Gephi format (GEXF in my case) really helped.
In Gephi, you can play around with different layout algorithms (peep the plugins). This may help you select a layout algo or combination thereof to help render tons of data in a human-friendly form.
[1] is a TypeScript database with ~250K LoC. A fairly advanced product that would benefit from what you're building. The colors represent different architectural layers. Each node is a folder with files in it. Edges represent inbound/outbound dependencies. There's simply no way for it to be labelled effectively.
[2] is the same codebase, but instead of inter-module dependencies, it's showing function/method calls.
One takeaway after working in this space for a while was that visualizing spatial relationships of anything sufficiently complex is extremely hard on a monitor. These representations benefit tremendously from being interactive.
[1] https://i.imgur.com/IdY5ghC.jpg [2] https://i.imgur.com/rv4OYun.jpg
Digging around a bit found a 'cg' command, which seems to be codegraph (based on the --help output). Didn't show anything interesting for a Django app, though... I'm guessing it couldn't really follow what manage.py was doing?
Anyhow, if 'cg' is the command, might want to update the docs.
Current approach is following “xrefs” in JADX and hooking methods with dynamic instrumentation with Frida (displaying backtraces etc). Got to be a quicker way while chipping away renaming classes and methods and mapping out source/sinks.
Although in my case it'd ideally be language-agnostic and hook into LSP so that I can click on nodes and jump to various files/modules/functions.
Still a cool project though!
[0] : https://www.masteringemacs.org/article/tree-sitter-complicat...
It seems like you would only really have need for visualisation if your codebase is complex enough. And if it is complex enough, visualising it is generally something of a mess.
What actionable insights can be generated? Has anyone changed anything as a result of such a visualisation?
It always feels to me like you're better off figuring out which modules you have shouldn't depend on certain other modules and finding only those links. Which is often best done with a simple ripgrep, no?
The HN title matches the repo's README, which was authored by someone whose English language skills are questionable.
Cool tool nonetheless, have built similar things to visualize code architecture and create doc artifacts in CI, usually the biggest challenge is to scope the pieces that will be included and what layout algo to use, maybe a feature to implement?
I built something similar for working with Java code, but it could be extended to other languages.
I've seen engineers find it hard to work out if their code is organised well together. So I built this tool to show them visually.
Like, a reasonably complex program is going to have a call graph with tens or even hundreds of thousands of nodes. Graphviz won't save you. Collapsing sccs won't save you. It won't actually be useful to navigate.
This needs more sophistication to be useful is what I'm saying.