DEV Community

raoubaid-12
raoubaid-12

Posted on

I built a tool to visualize Django REST Framework architecture (URLs, Serializers, Models, and more)

I built a tool to visualize Django REST Framework architecture (URLs, serializers, models, and more)

As Django REST Framework projects grow, one of the biggest challenges is understanding how everything is connected.

In my recent projects, I kept running into the same problem:

  • Which view is using which serializer?
  • How are models connected across the system?
  • Where are potential N+1 or optimization issues?
  • How does the API structure actually look as a whole?

I found myself constantly jumping between:

  • urls.py
  • views.py
  • serializers.py
  • models.py

At some point, it becomes hard to mentally map the entire architecture.

So I decided to experiment with building something to make DRF structure more visual and explorable.


🧠 What I built

I created a Django package called:

DRF Inspector

It automatically analyzes a Django REST Framework project and provides a visual dashboard inside Django.


✨ Features

🌐 API Structure Visualization

  • Lists all API endpoints
  • Maps URLs β†’ views
  • Shows HTTP methods (GET, POST, etc.)

🧠 Model Relationship Graph

  • Visual graph of:
    • ForeignKey
    • ManyToManyField
    • OneToOneField
  • Helps understand DB structure instantly

πŸ” Serializer Inspection

  • Detects serializers used in views
  • Shows nested serializer relationships
  • Maps serializer β†’ model relationships

🧭 View Analysis

  • Authentication classes
  • Permissions
  • Pagination
  • Throttling

⚑ Query Optimization Hints

  • Detects potential N+1 query issues
  • Suggests select_related / prefetch_related

πŸ“¦ Export Options

  • JSON export
  • Markdown export

πŸ”— Links

- PyPI: https://pypi.org/project/drf-inspector/

πŸ–₯️ How it works

After installing, it adds a dashboard inside your Django project.

⚑ Installation

Step 1: Install the package

pip install drf-inspector==0.1.4
Enter fullscreen mode Exit fullscreen mode

Step 2: Add in settings.py:

installed_apps = [
  drf_inspector,
   ....
]
Enter fullscreen mode Exit fullscreen mode

Step 3: Add in project urls.py:

from django.urls import path, include
urlpatterns = [
  ...,
  path("drf-inspector/",include("drf_inspector.urls")),
]
Enter fullscreen mode Exit fullscreen mode

Final Step : Go to the url and that's it:

   http://127.0.0.1:8000/drf-inspector/
Enter fullscreen mode Exit fullscreen mode

Top comments (0)