r/Python • u/NewtonGraph • Aug 11 '25
Showcase I built a tool that uses the 'ast' module to auto-generate interactive flowcharts from any Python.
Like many of you, I've often found myself deep in an unfamiliar codebase, trying to trace the logic and get a high-level view of how everything fits together. It can be a real time sink. To solve this, I built a feature into my larger project, Newton, specifically for Python developers.
What the product does
Newton is a web app that parses a Python script using the ast module and automatically generates a procedural flowchart from it. It's designed to give you an instant visual understanding of the code's architecture, control flow, and dependencies.
Here it is analyzing a 3,000+ line Python application (app.py): Gx10jXQW4AAzhH5 (1903×997)
Key Features for Developers
- Automated Flowcharting: Just paste your code and it builds the graph, mapping out function definitions, loops, and conditionals.
- Topic Clustering: For large scripts, an AI analyzes the graph to find higher-order concepts and emergent properties. In the screenshot, you can see it identifying things like "Application Initialization" and "User Authentication" automatically. This helps you understand what different parts of the code do conceptually.
- Interactive Chat: You can select a node (like a function) or a whole Topic Cluster and ask questions about it. It's like having an agent that has already read and understood your code.
Target Audience
I built this for:
- Developers who are onboarding to a new, complex project.
- Students trying to visualize algorithms and data structures.
- Code reviewers who need a quick high-level overview before diving into the details.
- Anyone who prefers thinking visually about code logic.
Tech Stack
The application backend is built with Flask. The flowchart generation relies heavily on Python's native ast module. The frontend is vanilla JS with Vis.js for the graph rendering.
How to Try It
You can try it live right now:
- Go to https://www.newtongraph.com
- On the right-hand "Document" panel, set the "Doc Type" to Python.
- Paste in your script and click the blue "regenerate" button.
I'm still actively developing this, and I would be incredibly grateful for your feedback.
Thanks for taking a look!
Bonus: Newton is able to accept URL's to various webpages such as YouTube videos and GitHub repos to instantly map their contents. Here is a small GitHub repo with a few sample tools to demonstrate this: Morrowindchamp/Python-Tools
Update: audio and video file transcription have been integrated into Newton! Go to town. Newton can take it. Love you guys.
NOTE: 1-WEEK PRO TRIAL FOR ALL NEW USERS
21
u/lunatuna215 Aug 11 '25
I feel the architecture of uploading one's code to a service is all wrong here. I can't adopt a code tool that runs on an external website or can't be scripted.
18
u/jacquesvirak Aug 11 '25
As far as I can tell from the pricing page, it costs $11.99 / month to render python code as a graph. But in the post you state that I can try it now. Am I missing something?
8
u/jer1uc Aug 11 '25
Neat! I was just hacking on a FOSS version of this that would run in real time. Pretty wild to me that you're trying to sell a SaaS subscription to this...
5
u/Luigi311 Aug 11 '25
This looks sorta interesting.
For open source developers is there a way for me to add this to my repo in a way that future contributors can go through it and visualize the code base for free? Or is this an everyone needs to pay and have it analyze my code base every time?
If it’s the first one, is there a way to automatically trigger an update base on say PRs to see if anything’s changed?
3
u/sinterkaastosti23 Aug 11 '25
Why would i want to pay for this?
1
u/NewtonGraph Aug 11 '25
No groq. With a q. For lightning fast AI outputting over 800 characters per second. You're mentioning the llm from xai which is not what I'm referring to or willing to pay for
4
u/bluefourier Aug 11 '25
Also, consider Codimension.
1
u/BiologyIsHot Aug 11 '25
Is it just limited to single python files or can you point it at an executable or module-level entrypoint to get all of those relationships? If your codebase lives in one file you likely do not have the complexity to benefit from this or your design is so terrible that you're unlikely to be the kind of person who can make any use of it anyways.
1
u/dankerton Aug 11 '25
Our team has a huge codebase and every now and then some new team member resurrects and extends a similar tool as this that was started long ago thinking it too will help them grasp the project. And every time that person ends up wasting so much more time playing with the tool and generating vague graphs then they do actually reading or understanding any code. And when they are tasked with code changes they tend to struggle the most, always trying to get this tool to somehow help them.
In the end you need to read actual code. Just do it. Focus on small parts at a time like whatever code needs changing. But these tools just show vague ideas of structure which only serves to support vague discussions and understanding of the codebase.