Skip to content

allmonday/fastapi-router-viz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pypi Python Versions

fastapi-router-viz

Visualize FastAPI application's routes and inner dependencies inside response_models.

It can help identify the potential impact of data on interfaces and pages

This repo is still in early stage.

router-viz -m tests.demo --app app --server
image

youtube:

IMAGE ALT TEXT

Installation

pip install fastapi-router-viz
# or
uv add fastapi-router-viz

Command Line Usage

# Basic usage - assumes your FastAPI app is named 'app' in app.py
router-viz tests/demo.py

# Specify custom app variable name
router-viz tests/demo.py --app app

# filter tag name
router-viz tests/demo.py --app app --tags page

# filter schema name, display related nodes
router-viz tests/demo.py --app app --schema Task

# show fields
router-viz tests/demo.py --app app --show_fields all

# highlight module
router-viz tests/demo.py --app app --module_color=tests.demo:red

# Custom output file
router-viz tests/demo.py -o my_visualization.dot

# server mode
router-viz tests/demo.py --app app --server --show_fields --module_color=tests.demo:red 

# Show help
router-viz --help

# Show version
router-viz --version

The tool will generate a DOT file that you can render using Graphviz:

# Install graphviz
brew install graphviz  # macOS
apt-get install graphviz  # Ubuntu/Debian

# Render the graph
dot -Tpng router_viz.dot -o router_viz.png

# Or view online at: https://dreampuf.github.io/GraphvizOnline/

or you can open router_viz.dot with vscode extension graphviz interactive preview

Next

  • group schemas by module hierarchy
  • module-based coloring via Analytics(module_color={...})
  • view in web browser
    • config params
    • make a explorer dashboard, provide list of routes, schemas, to make it easy to switch and search
  • support programmatic usage
  • better schema /router node appearance
  • refactor the frontend to vue, and tweak the build process
  • user can generate nodes/edges manually and connect to generated ones
  • add configuration for highlight (optional)
  • support dataclass
  • integration with pydantic-resolve
    • show difference between resolve, post fields
    • strikethrough for excluded fields
    • display loader as edges

Credits

About

visualize your fastapi routes and inner dependencies between models

Topics

Resources

License

Stars

Watchers

Forks