Skip to main content

Visualize FastAPI application's routing tree and dependencies

Project description

pypi Python Versions PyPI Downloads

Visualize your FastAPI endpoints, and explore them interactively.

This repo is still in early stage, it supports pydantic v2 only

live demo of project: composition oriented development pattern

image

with configuration:

app.mount('/voyager', 
          create_voyager(
            app, 
            module_color={'src.services': 'tomato'}, 
            module_prefix='src.services', 
            swagger_url="/docs",
            ga_id="G-XXXXXXXXVL",
            initial_page_policy='first',
            online_repo_url='https://github.com/allmonday/composition-oriented-development-pattern/blob/master'))

https://github.com/allmonday/composition-oriented-development-pattern/blob/master/src/main.py#L48

Plan & Raodmap

Installation

pip install fastapi-voyager
# or
uv add fastapi-voyager
voyager -m path.to.your.app.module --server

Sub-Application mounts are not supported yet, but you can specify the name of the FastAPI application used with --app. Only a single application (default: 'app') can be selected, but in a scenario where api is attached through app.mount("/api", api), you can select api like this:

voyager -m path.to.your.app.module --server --app api

Mount into project

from fastapi import FastAPI
from fastapi_voyager import create_voyager
from tests.demo import app

app.mount('/voyager', create_voyager(
    app, 
    module_color={"tests.service": "red"}, 
    module_prefix="tests.service"),
    swagger_url="/docs")

Features

For scenarios of using FastAPI as internal API integration endpoints, fastapi-voyager helps to visualize the dependencies.

It is also an architecture inspection tool that can identify issues in data relationships during design phase before turly implemtatioin.

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

highlight nodes and links

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.

image

focus on nodes

Double click a node, and then toggle focus to hide irrelevant nodes.

image

view source code

double click a node or route to show source code or open file in vscode.

image image

Command Line Usage

open in browser

# open in browser
voyager -m tests.demo --server  

voyager -m tests.demo --server --port=8002

generate the dot file

# generate .dot file
voyager -m tests.demo  

voyager -m tests.demo --app my_app

voyager -m tests.demo --schema Task

voyager -m tests.demo --show_fields all

voyager -m tests.demo --module_color=tests.demo:red --module_color=tests.service:tomato

voyager -m tests.demo -o my_visualization.dot

voyager --version

voyager --help

About pydantic-resolve

pydantic-resolve's @ensure_subset decorator helps safely pick fields from the 'source class' while indicating the reference from the current class to the base class.

pydantic-resolve is a lightweight tool designed to build complex, nested data in a simple, declarative way. In version 2.0.0alpha, it will introduce an important feature: ER Diagram, and fastapi-voyager will support this feature, allowing for a clearer understanding of the business relationships between the data.

Developers can use fastapi-voyager without needing to know anything about pydantic-resolve, but I still highly recommend everyone to give it a try.

Dependencies

Credits

How to develop & contribute?

fork, clone.

install uv.

uv venv
source .venv/bin/activate
uv pip install ".[dev]"
uvicorn tests.programatic:app  --reload

open localhost:8000/voyager

frontend:

  • src/web/vue-main.js: main js

backend:

  • voyager.py: main entry
  • render.py: generate dot file
  • server.py: serve mode

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_voyager-0.12.11.tar.gz (584.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_voyager-0.12.11-py3-none-any.whl (528.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_voyager-0.12.11.tar.gz.

File metadata

  • Download URL: fastapi_voyager-0.12.11.tar.gz
  • Upload date:
  • Size: 584.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fastapi_voyager-0.12.11.tar.gz
Algorithm Hash digest
SHA256 63a00790fff4d4f1725dafd8062c13db629e356273fc507a863a4d41e9a99286
MD5 64c08f46e7d0f129cf56306ceae5db1c
BLAKE2b-256 abdcf765f2b4f4616cb7bf154fd00c8301ff4dd5eff2a78323ae945cf724a55d

See more details on using hashes here.

File details

Details for the file fastapi_voyager-0.12.11-py3-none-any.whl.

File metadata

  • Download URL: fastapi_voyager-0.12.11-py3-none-any.whl
  • Upload date:
  • Size: 528.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fastapi_voyager-0.12.11-py3-none-any.whl
Algorithm Hash digest
SHA256 cb2fc8e111772b33d0b2010b0af7e7e44fac1f159a40bd758290502c7e833398
MD5 3b504ad94b51f427b115ad7d39ebb7ef
BLAKE2b-256 fbd4e0447b25ab4ddf2b7d5ff5465f1c9fb750c201b724b72ca3889bc6add80b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page