CodeFlow is a Python + React tool for exploring Python codebases as call graphs and readable execution flows.
It scans a project, finds functions and classes, maps call relationships, and renders the result in a visual graph UI. A lightweight CLI is also included for generating JSON analysis from the terminal.
- Analyze a local Python project and build a project-level call graph.
- Inspect a single function as an expandable flow tree.
- Browse folders and Python files from the web UI.
- Render the analysis in an interactive React Flow canvas.
- Optionally generate short natural-language summaries with OpenAI.
- Python 3.10 or newer
- Node.js 18 or newer
pipnpm
main.py- CLI entry point that prints analysis as JSON.analysis.py- Static analysis and call graph collection.flow.py- Builds readable flow trees and optional LLM summaries.backend/- FastAPI API used by the frontend.frontend/- Vite + React application for browsing and visualizing code.
git clone https://github.com/sabare/codeflow.git
cd codeflowpython3 -m venv .venv
source .venv/bin/activateThe backend needs FastAPI, Uvicorn, and python-dotenv. If you want optional AI summaries, install openai too.
pip install fastapi "uvicorn[standard]" python-dotenv openaiIf you prefer to install from the provided requirements file first, you can do that and then add the missing utilities:
pip install -r backend/requirements.txt
pip install python-dotenv openaicd frontend
npm install
cd ..Open two terminals, one for the backend and one for the frontend.
From the repository root:
source .venv/bin/activate
uvicorn backend.main:app --reload --port 8000From the frontend/ directory:
npm run devIf you want the frontend to talk to a backend running somewhere other than http://localhost:8000, set VITE_API_URL before starting Vite:
VITE_API_URL=http://localhost:8000 npm run devYou can also run the analyzer directly from the command line.
python main.py /path/to/projectTo analyze one function and print a flow tree:
python main.py /path/to/project --function package.module.function_nameTo limit expansion depth:
python main.py /path/to/project --function package.module.function_name --depth 2The FastAPI backend exposes these endpoints:
GET /browse?path=...- list subdirectories and Python files.GET /functions?path=...- list functions in a Python file.GET /analyze?path=...- analyze a project folder.GET /analyze?path=...&function=...- analyze a specific function and return a flow tree.
Function and flow summaries can use OpenAI when the following environment variables are set:
OPENAI_API_KEY- required to enable LLM summariesOPENAI_MODEL- optional, defaults togpt-5-nano
You can store these in a local .env file at the repository root.
Example:
OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-5-nanoIf no API key is present, CodeFlow still works. It just falls back to generated summaries.
- Analysis results may be cached in
.cache/function_summaries.json. - The frontend expects the backend to be running when you load a project.
- Only
.pyfiles are shown in the browser view.
Contributions are welcome. A good starting point is to:
- Open an issue or discussion describing the change.
- Keep edits focused and small where possible.
- Add or update tests if you change analysis behavior.