tlarsson commited on
Commit
763a717
Β·
verified Β·
1 Parent(s): 1f4b5de

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +85 -1
README.md CHANGED
@@ -7,4 +7,88 @@ sdk: docker
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  ---
9
 
10
+
11
+
12
+
13
+ # πŸ’» Code Graph
14
+
15
+ **Code Graph** is a visual tool that analyzes and displays function dependencies in Python code using AST-based static parsing.
16
+
17
+ It’s ideal for developers, data scientists, and Streamlit users who want to understand how their functions interact β€” without needing to execute any code.
18
+
19
+ ---
20
+
21
+ ## πŸ“Œ What It Does
22
+
23
+ Upload one or more `.py` files, and this tool will:
24
+
25
+ - Parse the source code using Python’s built-in `ast` module
26
+ - Identify function definitions and their relationships
27
+ - Show which functions:
28
+ - Are called from others
29
+ - Read or write to `st.session_state`
30
+ - Take specific arguments and return specific values
31
+ - Display all this in a **fully interactive graph** and table
32
+
33
+ ---
34
+
35
+ ## 🧠 What is AST?
36
+
37
+ AST stands for **Abstract Syntax Tree** β€” a structured representation of your source code as a tree. Each node represents a language construct like a function, loop, or assignment.
38
+
39
+ Code Graph uses ASTs to analyze code structure **without running the code**, making it safe and fast to use.
40
+
41
+ ---
42
+
43
+ ## πŸš€ Features
44
+
45
+ βœ… Upload one or more Python files
46
+ βœ… Auto-detect function calls and dependencies
47
+ βœ… Highlights:
48
+
49
+ - Function **arguments** and **return values** with inferred types (e.g. `df: pd.DataFrame`)
50
+ - Streamlit `session_state` **reads/writes**
51
+ - **Call order labels** on edges (`1`, `2`, `3`, …)
52
+ - **Thicker edges** for functions called multiple times
53
+
54
+ βœ… Export the graph as downloadable JSON
55
+ βœ… View everything in an interactive graph and sortable table
56
+
57
+ ---
58
+
59
+ ## πŸ“‚ How to Use
60
+
61
+ 1. Launch the app or clone this repo
62
+ 2. Upload one or more `.py` files
63
+ 3. Select the "main" or top-level function to explore
64
+ 4. Interact with the graph and table to trace logic
65
+
66
+ ---
67
+
68
+ ## πŸ›  Tech Stack
69
+
70
+ - 🐍 Python
71
+ - πŸ“¦ Dash & Plotly
72
+ - 🧠 `ast` module (for static code parsing)
73
+ - 🌐 Cytoscape.js (for interactive graph rendering)
74
+
75
+ ---
76
+
77
+ ## πŸ™‹β€β™‚οΈ About the Author
78
+
79
+ Created by **Tomas Larsson**, a data scientist and creator of
80
+ [**my.moneytoolbox.com**](https://my.moneytoolbox.com) β€” a blog covering:
81
+
82
+ - Tax-optimized investing
83
+ - Retirement modeling
84
+ - Financial tools for DIY investors
85
+
86
+ ---
87
+
88
+ ## πŸ“€ Deployment (Docker-based)
89
+
90
+ If you're running locally:
91
+
92
+ ```bash
93
+ docker build -t code-graph .
94
+ docker run -p 7860:7860 code-graph