fastapi-voyager 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastapi_voyager-0.4.1/.gitignore +209 -0
- fastapi_voyager-0.4.1/LICENSE +21 -0
- fastapi_voyager-0.4.1/PKG-INFO +175 -0
- fastapi_voyager-0.4.1/README.md +148 -0
- fastapi_voyager-0.4.1/pyproject.toml +49 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/__init__.py +5 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/cli.py +289 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/filter.py +105 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/graph.py +396 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/module.py +44 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/server.py +107 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/type.py +48 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/type_helper.py +232 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/version.py +2 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/component/route-code-display.js +73 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/component/schema-code-display.js +152 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/component/schema-field-filter.js +189 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/graph-ui.js +137 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/graphviz.svg.css +42 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/graphviz.svg.js +580 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/index.html +224 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/quasar.min.css +1 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/quasar.min.js +127 -0
- fastapi_voyager-0.4.1/src/fastapi_voyager/web/vue-main.js +213 -0
- fastapi_voyager-0.4.1/tests/__init__.py +0 -0
- fastapi_voyager-0.4.1/tests/demo.py +63 -0
- fastapi_voyager-0.4.1/tests/service/__init__.py +0 -0
- fastapi_voyager-0.4.1/tests/service/schema.py +25 -0
- fastapi_voyager-0.4.1/tests/test_analysis.py +36 -0
- fastapi_voyager-0.4.1/tests/test_import.py +3 -0
- fastapi_voyager-0.4.1/tests/test_module.py +85 -0
- fastapi_voyager-0.4.1/tests/test_type_alias.py +30 -0
- fastapi_voyager-0.4.1/uv.lock +419 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
*.dot
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 tangkikodo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastapi-voyager
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Visualize FastAPI application's routing tree and dependencies
|
|
5
|
+
Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
|
|
6
|
+
Project-URL: Source, https://github.com/allmonday/fastapi-voyager
|
|
7
|
+
Author-email: Tangkikodo <allmonday@126.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: fastapi,openapi,routing,visualization
|
|
11
|
+
Classifier: Framework :: FastAPI
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: fastapi>=0.110
|
|
21
|
+
Requires-Dist: pydantic-resolve>=1.13.2
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
24
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
25
|
+
Requires-Dist: uvicorn; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
[](https://pypi.python.org/pypi/fastapi-voyager)
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
> This repo is still in early stage, currently it support pydantic v2 only, previous name: fastapi-router-viz
|
|
32
|
+
|
|
33
|
+
Inspect your API interactively
|
|
34
|
+
|
|
35
|
+
<img width="1480" height="648" alt="image" src="https://github.com/user-attachments/assets/a6ccc9f1-cf06-493a-b99b-eb07767564bd" />
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install fastapi-voyager
|
|
41
|
+
# or
|
|
42
|
+
uv add fastapi-voyager
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Dependencies
|
|
47
|
+
|
|
48
|
+
- FastAPI
|
|
49
|
+
- [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Feature
|
|
53
|
+
|
|
54
|
+
For scenarios of using FastAPI as internal API integration endpoints, `fastapi-voyager` helps to visualize the dependencies.
|
|
55
|
+
|
|
56
|
+
It is also an architecture inspection tool that can identify issues in data relationships through visualization during the design phase.
|
|
57
|
+
|
|
58
|
+
If the process of building the view model follows the ER model, the full potential of fastapi-voyager can be realized. It allows for quick identification of APIs that use entities, as well as which entities are used by a specific API
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
git clone https://github.com/allmonday/fastapi-voyager.git
|
|
64
|
+
cd fastapi-voyager
|
|
65
|
+
|
|
66
|
+
voyager -m tests.demo
|
|
67
|
+
--server --port=8001
|
|
68
|
+
--module_color=tests.service:blue
|
|
69
|
+
--module_color=tests.demo:tomato
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
pick tag, rotue (optional) and click `generate`.
|
|
73
|
+
|
|
74
|
+
<img width="1919" height="898" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/05e321d0-49f3-4af6-a7c7-f4c9c6b1dbfd" />
|
|
75
|
+
|
|
76
|
+
click a node to highlight it's upperstream and downstream nodes. figure out the related models of one page, or homw many pages are related with one model.
|
|
77
|
+
|
|
78
|
+
<img width="1485" height="616" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/70c4095f-86c7-45da-a6f0-fd41ac645813" />
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
`shift` click a node to check related nodes.
|
|
82
|
+
|
|
83
|
+
pick a field to narrow the result.
|
|
84
|
+
|
|
85
|
+
<img width="1917" height="800" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/e770dc70-f293-49e1-bcd7-d8dffa15d9ea" />
|
|
86
|
+
|
|
87
|
+
`alt` click a node to show source code or open file in vscode.
|
|
88
|
+
|
|
89
|
+
<img width="497" height="402" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/ac81711a-d9c2-4fb1-8b3a-0f4bd1f02572" />
|
|
90
|
+
|
|
91
|
+
more in video:
|
|
92
|
+
|
|
93
|
+
[](https://www.youtube.com/watch?v=msYsB9Cc3CA "Unity Snake Game")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Command Line Usage
|
|
97
|
+
|
|
98
|
+
### open in browser
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# open in browser
|
|
102
|
+
voyager -m tests.demo --server
|
|
103
|
+
|
|
104
|
+
voyager -m tests.demo --server --port=8002
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### generate the dot file
|
|
108
|
+
```bash
|
|
109
|
+
# generate .dot file
|
|
110
|
+
voyager -m tests.demo
|
|
111
|
+
|
|
112
|
+
voyager -m tests.demo --app my_app
|
|
113
|
+
|
|
114
|
+
voyager -m tests.demo --schema Task
|
|
115
|
+
|
|
116
|
+
voyager -m tests.demo --show_fields all
|
|
117
|
+
|
|
118
|
+
voyager -m tests.demo --module_color=tests.demo:red --module_color=tests.service:tomato
|
|
119
|
+
|
|
120
|
+
voyager -m tests.demo -o my_visualization.dot
|
|
121
|
+
|
|
122
|
+
voyager --version
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The tool will generate a DOT file that you can render using Graphviz:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Install graphviz
|
|
129
|
+
brew install graphviz # macOS
|
|
130
|
+
apt-get install graphviz # Ubuntu/Debian
|
|
131
|
+
|
|
132
|
+
# Render the graph
|
|
133
|
+
dot -Tpng router_viz.dot -o router_viz.png
|
|
134
|
+
|
|
135
|
+
# Or view online at: https://dreampuf.github.io/GraphvizOnline/
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
or you can open router_viz.dot with vscode extension `graphviz interactive preview`
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## Plan
|
|
142
|
+
|
|
143
|
+
features:
|
|
144
|
+
- [x] group schemas by module hierarchy
|
|
145
|
+
- [x] module-based coloring via Analytics(module_color={...})
|
|
146
|
+
- [x] view in web browser
|
|
147
|
+
- [x] config params
|
|
148
|
+
- [x] make a explorer dashboard, provide list of routes, schemas, to make it easy to switch and search
|
|
149
|
+
- [x] support programmatic usage
|
|
150
|
+
- [x] better schema /router node appearance
|
|
151
|
+
- [x] hide fields duplicated with parent's (show `parent fields` instead)
|
|
152
|
+
- [x] refactor the frontend to vue, and tweak the build process
|
|
153
|
+
- [x] find dependency based on picked schema and it's field.
|
|
154
|
+
- [x] optimize static resource (cdn -> local)
|
|
155
|
+
- [x] add configuration for highlight (optional)
|
|
156
|
+
- [x] alt+click to show field details
|
|
157
|
+
- [x] display source code of routes (including response_model)
|
|
158
|
+
- [x] handle excluded field
|
|
159
|
+
- [ ] user can generate nodes/edges manually and connect to generated ones
|
|
160
|
+
- [ ] support dataclass
|
|
161
|
+
- [ ] group routes by module hierarchy
|
|
162
|
+
- [ ] integration with pydantic-resolve
|
|
163
|
+
- [ ] show difference between resolve, post fields
|
|
164
|
+
- [x] strikethrough for excluded fields
|
|
165
|
+
- [ ] display loader as edges
|
|
166
|
+
- [ ] test cases
|
|
167
|
+
|
|
168
|
+
bugs:
|
|
169
|
+
- [ ] fix duplicated link from class and parent class, it also break clicking highlight
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Credits
|
|
173
|
+
|
|
174
|
+
- https://apis.guru/graphql-voyager/, for inspiration.
|
|
175
|
+
- https://github.com/tintinweb/vscode-interactive-graphviz, for web visualization.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
[](https://pypi.python.org/pypi/fastapi-voyager)
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
> This repo is still in early stage, currently it support pydantic v2 only, previous name: fastapi-router-viz
|
|
5
|
+
|
|
6
|
+
Inspect your API interactively
|
|
7
|
+
|
|
8
|
+
<img width="1480" height="648" alt="image" src="https://github.com/user-attachments/assets/a6ccc9f1-cf06-493a-b99b-eb07767564bd" />
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install fastapi-voyager
|
|
14
|
+
# or
|
|
15
|
+
uv add fastapi-voyager
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Dependencies
|
|
20
|
+
|
|
21
|
+
- FastAPI
|
|
22
|
+
- [pydantic-resolve](https://github.com/allmonday/pydantic-resolve)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Feature
|
|
26
|
+
|
|
27
|
+
For scenarios of using FastAPI as internal API integration endpoints, `fastapi-voyager` helps to visualize the dependencies.
|
|
28
|
+
|
|
29
|
+
It is also an architecture inspection tool that can identify issues in data relationships through visualization during the design phase.
|
|
30
|
+
|
|
31
|
+
If the process of building the view model follows the ER model, the full potential of fastapi-voyager can be realized. It allows for quick identification of APIs that use entities, as well as which entities are used by a specific API
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
git clone https://github.com/allmonday/fastapi-voyager.git
|
|
37
|
+
cd fastapi-voyager
|
|
38
|
+
|
|
39
|
+
voyager -m tests.demo
|
|
40
|
+
--server --port=8001
|
|
41
|
+
--module_color=tests.service:blue
|
|
42
|
+
--module_color=tests.demo:tomato
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
pick tag, rotue (optional) and click `generate`.
|
|
46
|
+
|
|
47
|
+
<img width="1919" height="898" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/05e321d0-49f3-4af6-a7c7-f4c9c6b1dbfd" />
|
|
48
|
+
|
|
49
|
+
click a node to highlight it's upperstream and downstream nodes. figure out the related models of one page, or homw many pages are related with one model.
|
|
50
|
+
|
|
51
|
+
<img width="1485" height="616" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/70c4095f-86c7-45da-a6f0-fd41ac645813" />
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
`shift` click a node to check related nodes.
|
|
55
|
+
|
|
56
|
+
pick a field to narrow the result.
|
|
57
|
+
|
|
58
|
+
<img width="1917" height="800" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/e770dc70-f293-49e1-bcd7-d8dffa15d9ea" />
|
|
59
|
+
|
|
60
|
+
`alt` click a node to show source code or open file in vscode.
|
|
61
|
+
|
|
62
|
+
<img width="497" height="402" alt="image" style="border: 1px solid #aaa" src="https://github.com/user-attachments/assets/ac81711a-d9c2-4fb1-8b3a-0f4bd1f02572" />
|
|
63
|
+
|
|
64
|
+
more in video:
|
|
65
|
+
|
|
66
|
+
[](https://www.youtube.com/watch?v=msYsB9Cc3CA "Unity Snake Game")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Command Line Usage
|
|
70
|
+
|
|
71
|
+
### open in browser
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# open in browser
|
|
75
|
+
voyager -m tests.demo --server
|
|
76
|
+
|
|
77
|
+
voyager -m tests.demo --server --port=8002
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### generate the dot file
|
|
81
|
+
```bash
|
|
82
|
+
# generate .dot file
|
|
83
|
+
voyager -m tests.demo
|
|
84
|
+
|
|
85
|
+
voyager -m tests.demo --app my_app
|
|
86
|
+
|
|
87
|
+
voyager -m tests.demo --schema Task
|
|
88
|
+
|
|
89
|
+
voyager -m tests.demo --show_fields all
|
|
90
|
+
|
|
91
|
+
voyager -m tests.demo --module_color=tests.demo:red --module_color=tests.service:tomato
|
|
92
|
+
|
|
93
|
+
voyager -m tests.demo -o my_visualization.dot
|
|
94
|
+
|
|
95
|
+
voyager --version
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The tool will generate a DOT file that you can render using Graphviz:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Install graphviz
|
|
102
|
+
brew install graphviz # macOS
|
|
103
|
+
apt-get install graphviz # Ubuntu/Debian
|
|
104
|
+
|
|
105
|
+
# Render the graph
|
|
106
|
+
dot -Tpng router_viz.dot -o router_viz.png
|
|
107
|
+
|
|
108
|
+
# Or view online at: https://dreampuf.github.io/GraphvizOnline/
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
or you can open router_viz.dot with vscode extension `graphviz interactive preview`
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## Plan
|
|
115
|
+
|
|
116
|
+
features:
|
|
117
|
+
- [x] group schemas by module hierarchy
|
|
118
|
+
- [x] module-based coloring via Analytics(module_color={...})
|
|
119
|
+
- [x] view in web browser
|
|
120
|
+
- [x] config params
|
|
121
|
+
- [x] make a explorer dashboard, provide list of routes, schemas, to make it easy to switch and search
|
|
122
|
+
- [x] support programmatic usage
|
|
123
|
+
- [x] better schema /router node appearance
|
|
124
|
+
- [x] hide fields duplicated with parent's (show `parent fields` instead)
|
|
125
|
+
- [x] refactor the frontend to vue, and tweak the build process
|
|
126
|
+
- [x] find dependency based on picked schema and it's field.
|
|
127
|
+
- [x] optimize static resource (cdn -> local)
|
|
128
|
+
- [x] add configuration for highlight (optional)
|
|
129
|
+
- [x] alt+click to show field details
|
|
130
|
+
- [x] display source code of routes (including response_model)
|
|
131
|
+
- [x] handle excluded field
|
|
132
|
+
- [ ] user can generate nodes/edges manually and connect to generated ones
|
|
133
|
+
- [ ] support dataclass
|
|
134
|
+
- [ ] group routes by module hierarchy
|
|
135
|
+
- [ ] integration with pydantic-resolve
|
|
136
|
+
- [ ] show difference between resolve, post fields
|
|
137
|
+
- [x] strikethrough for excluded fields
|
|
138
|
+
- [ ] display loader as edges
|
|
139
|
+
- [ ] test cases
|
|
140
|
+
|
|
141
|
+
bugs:
|
|
142
|
+
- [ ] fix duplicated link from class and parent class, it also break clicking highlight
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
## Credits
|
|
146
|
+
|
|
147
|
+
- https://apis.guru/graphql-voyager/, for inspiration.
|
|
148
|
+
- https://github.com/tintinweb/vscode-interactive-graphviz, for web visualization.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "fastapi-voyager"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Visualize FastAPI application's routing tree and dependencies"
|
|
5
|
+
authors = [ { name = "Tangkikodo", email = "allmonday@126.com" } ]
|
|
6
|
+
license = { text = "MIT" }
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
keywords = ["fastapi", "visualization", "routing", "openapi"]
|
|
10
|
+
dependencies = [
|
|
11
|
+
"fastapi>=0.110",
|
|
12
|
+
"pydantic-resolve>=1.13.2"
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.9",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Framework :: FastAPI",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"License :: OSI Approved :: MIT License"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
voyager = "fastapi_voyager.cli:main"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/allmonday/fastapi-voyager"
|
|
30
|
+
Source = "https://github.com/allmonday/fastapi-voyager"
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = ["uvicorn", "ruff", "pytest"]
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["hatchling"]
|
|
37
|
+
build-backend = "hatchling.build"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.version]
|
|
40
|
+
path = "src/fastapi_voyager/version.py"
|
|
41
|
+
|
|
42
|
+
[tool.uv]
|
|
43
|
+
# You can pin resolution or indexes here later.
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 100
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = ["E", "F", "I", "UP", "B"]
|