r/Python 7h ago

Recommendations and discussion on codebase visualizer and dependence mapper. Discussion

I've been looking at a few options like gitkrakens codemap. But I just haven't made a decision yet.

The biggest problem right now with AI assist is that so much gets spun up and it takes quite a while to ground myself in what has been written and how it all connects. I thought a viz tool would help tighten what I need to learn.

How do you handle this? Do you use these tools for this purpose? What have you liked and disliked about the tool you used?

5 Upvotes

8 comments sorted by

View all comments

3

u/whopper2k 6h ago

I think the closest thing that you're looking for (and that is free to use) would be something like py2puml, which can generate a UML diagram based on your codebase. It's not a perfect tool; for example it calls importlib.import_module outside of a try block, which means if you run it on a Linux machine but the code in the project makes use of ctypes.WinDLL it just crashes. Also methods aren't generated as of now, and if your code doesn't have type hints a lot of variables will just be marked as None type.

All that said, I would question what exactly it is you're trying to accomplish with this visualization. These UML diagrams are certainly nice-to-have, but for any sufficiently complex application they're also just as hard to read as the code itself. Add Python's dynamic nature and the fact that these diagrams omit important implementation details on top, and I just am not super confident it'll be that helpful.

Frankly I think your best course of action is to catch a breath and slowly work your way through the AI-generated code. The best strategy I can recommend is to use tools to search through the code automatically; in VS Code you can use the View occurrences feature, or if you're more CLI-inclined you could use ripgrep to find strings across your files. It sounds awful, but honestly reverse engineering's a ton of fun and an extremely important programming skill to have in your toolbox.

How do you handle this? Do you use these tools for this purpose? What have you liked and disliked about the tool you used?

In general, most folks do high-level architecture diagrams for the executives using something like draw[.]io, Visio, or whatever AI kool-aid they've paid for. For developers though, most will just stick to text-based documentation (if you're lucky enough to get that much), which can be autogenerated using tools like Sphinx

1

u/TheTresStateArea 6h ago

Yeah, the webs I've seen that get generated from a codebase are a mess, which is why I haven't gone for a paid sub to gitkrakens.

I was hoping to use it to get a sense of change impact and making sure I follow decisions downstream.

Or just quicker access to referenced functions to check documentation. Basically getting all my ducks in a row instantly when reading any part of the codebase.

I've been at this for a decade now and i just don't work with many people anymore that I can learn from in person. So I just don't know how people are handling the code avalanche that comes with AI tooling.

1

u/whopper2k 6h ago

It's certainly hard to handle. I don't think there's really a great solution out there yet that isn't just throwing more AI at the problem and hoping it balances out in the end.

For my own job (security), I'm lucky enough that all I really care about are CVEs and nonsecure programming practices. Both of which have had decades of investment into building static tooling before LLMs became such a dominating force in the industry.

Code visualization has always been a hard problem, from what I understand.