This simple web application helps you visualize the structure of your Python code and understand its call relationships. Upload a .py
file, and it will generate an interactive force-graph showing classes and functions. Clicking on a function or method node not only displays its code but also highlights where it's called from within the analyzed file.
- File Upload: Accepts Python (
.py
) files. - Structure Visualization: Displays a hierarchical tree view of classes, methods, and top-level functions using D3.js.
- Call Relationship Visualization: Interactively see which functions or methods call a selected function/method. Clicking a node highlights incoming calls, making it easy to trace execution flow.
- Code Snippet Display: Click on any class or function node in the tree to view its source code directly on the page.
- Simple Web Interface: Built with Flask for the backend and basic HTML/CSS/JavaScript for the frontend.
To get this running on your local machine, follow these steps:
- Prerequisites: Make sure you have Python 3.x and pip installed.
- Clone the Repository:
git clone https://github.com/nuhyamin1/CallGraphAnalyzer.git
- Navigate to Directory: Open your terminal or command prompt and change into the newly cloned
CallGraphAnalyzer
directory. - Virtual Environment (Recommended):
python -m venv venv # On Windows .\venv\Scripts\activate # On macOS/Linux source venv/bin/activate
- Install Dependencies: The only external library needed is Flask.
pip install Flask
- Make sure you are in the project directory in your terminal and your virtual environment (if used) is activated.
- Run the Flask development server:
python app.py
- Flask will start the server, usually at
http://127.0.0.1:5000
. Open this URL in your web browser.
- Once the application is running in your browser, you'll see a file input field.
- Click "Choose File" and select a Python (
.py
) file from your computer. - Click the "Analyze File" button.
- An interactive tree diagram representing the code structure will appear.
- Click on any class or function node in the diagram.
- The corresponding source code for that node will be displayed in the box below the diagram. If you click on a function or method, arrows will also appear on the diagram showing which other functions/methods call the selected one.