https://github.com/dotcs/fastapi-di-viz
A CLI tool to visualize the FastAPI dependency chain
https://github.com/dotcs/fastapi-di-viz
Last synced: 12 months ago
JSON representation
A CLI tool to visualize the FastAPI dependency chain
- Host: GitHub
- URL: https://github.com/dotcs/fastapi-di-viz
- Owner: dotcs
- Created: 2024-11-19T20:48:39.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2024-12-10T20:05:21.000Z (over 1 year ago)
- Last Synced: 2024-12-10T21:20:52.467Z (over 1 year ago)
- Language: Python
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://pypi.org/project/fastapi-di-viz/)

# FastAPI Dependency Injection Visualizer
This is a simple tool to visualize the dependency injection tree of a FastAPI application.
It works by inspecting the FastAPI application and generating a graph of the dependencies from walking the dependency injection tree starting from the application's endpoints.
It automatically detects the endpoints and the dependencies of the application and generates a graph of the dependencies.
## Usage
Install the package in the environment where your FastAPI application is installed.
```bash
pip install fastapi-di-viz
```
Then run the following command to generate the graph:
```bash
fastapi-di-viz your_app.main:app
```
A sample graph for the application in [fastapi_di_viz/sample](./fastapi_di_viz/sample/) looks like this:
```mermaid
---
title: FastAPI dependency chain
---
graph TD;
root --> get_settings
a --> get_serviceA
get_serviceA --> get_repo
get_serviceA --> get_settings
b --> get_serviceB
get_serviceB --> get_repo
```
The tool supports graphs in the following formats:
- Graphviz DOT format
- Mermaid flowchart format