Metadata-Version: 2.4
Name: drf-inspector
Version: 0.1.1
Summary: A comprehensive Django app that provides visualization and analysis of your DRF backend.
Author-email: DRF Inspector Contributors <your.email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/codewithubaid1/drf-inspector
Keywords: django,djangorestframework,drf,api,inspector,visualizer,architecture,backend,django-rest-framework,drfvisualizer,drf_inspector,drf-visualizer
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2
Requires-Dist: djangorestframework>=3.12
Dynamic: license-file

# DRF Inspector

DRF Inspector is a powerful developer tool for analyzing, visualizing, and understanding Django REST Framework (DRF) backends.

It automatically inspects your project architecture and provides interactive visualizations for:
- API endpoints
- serializers
- models
- relationships
- views
- query optimization
- security analysis
- architecture exporting

DRF Inspector helps developers debug, document, optimize, and better understand complex DRF projects.

---

# Features

## API & URL Analysis
- Inspect all DRF endpoints automatically
- Detect HTTP methods (`GET`, `POST`, `PATCH`, etc.)
- View connected views and serializers
- Search and filter endpoints

## Model Visualization
- Auto-generate model relationship graphs
- Visualize:
  - `ForeignKey`
  - `ManyToManyField`
  - `OneToOneField`
- Interactive relationship mapping

## Serializer Inspection
- Detect serializers used in views
- Inspect serializer fields
- Detect nested serializers
- Show serializer → model mappings

## View Analysis
- Analyze:
  - authentication classes
  - permission classes
  - pagination
  - throttling
  - filtering
- Supports DRF class-based views and ViewSets

## Security Audit
- Detect endpoints missing:
  - authentication
  - permissions
  - throttling
- Helps identify insecure API routes

## Query Optimization Detection
- Detect possible N+1 query issues
- Suggest:
  - `select_related`
  - `prefetch_related`
- Analyze queryset optimization opportunities

## Exporting
Export project architecture as:
- JSON
- Markdown

Useful for:
- documentation
- architecture reviews
- team sharing
- AI context sharing

## Interactive Frontend
Built-in dashboard directly served from Django:
- No React setup required
- No separate frontend server
- Works directly inside your Django project

---

# Screenshots

## Dashboard
![Dashboard](screenshots/dashboard.png)

## URL Explorer
![URLs](screenshots/urls.png)

## Model Relationships
![Models](screenshots/models.png)

## Serializer Inspector
![Serializers](screenshots/serializers.png)

## Query Optimization
![Optimization](screenshots/optimization.png)

---

# Installation

Install the package:

```bash
pip install drf-inspector
```

---

# Quick Start

## 1. Add to Installed Apps

```python
INSTALLED_APPS = [
    ...
    "drf_inspector",
]
```

---

## 2. Include URLs

```python
from django.urls import path, include

urlpatterns = [
    ...
    path(
        "drf-inspector/",
        include("drf_inspector.urls")
    ),
]
```

---

## 3. Run Server

```bash
python manage.py runserver
```

---

## 4. Open Dashboard

Visit:

```text
http://127.0.0.1:8000/drf-inspector/
```

---

# Supported Features

| Feature | Supported |
|---|---|
| APIView | ✅ |
| GenericAPIView | ✅ |
| ViewSets | ✅ |
| ModelViewSet | ✅ |
| ReadOnlyModelViewSet | ✅ |
| Nested Serializers | ✅ |
| Model Relationship Graphs | ✅ |
| JSON Export | ✅ |
| Markdown Export | ✅ |

---

# Current Limitations

## Function-Based Views (FBV)
DRF Inspector currently focuses primarily on DRF class-based views.

Basic FBV detection may work, but:
- serializer analysis
- queryset analysis
- optimization analysis

may not be fully supported for function-based views.

---

## Dynamic Serializers
Views using highly dynamic serializer selection may not always be fully analyzable.

Example:

```python
def get_serializer_class(self):
    ...
```

---

## Runtime Query Tracking
Current query optimization analysis is static.

Runtime SQL monitoring and live query profiling are planned for future releases.

---

# Roadmap

Planned future features:

- Runtime request monitoring
- SQL query timeline
- WebSocket inspector
- OpenAPI visualization
- Middleware analysis
- Live API analytics
- Permission dependency graph
- API testing utilities
- Performance profiling
- Docker deployment support

---

# Why DRF Inspector?

Modern DRF projects become difficult to understand as they grow.

DRF Inspector helps developers:
- understand backend architecture faster
- onboard team members easier
- debug APIs visually
- optimize database queries
- document projects automatically

---

# Contributing

Contributions, issues, and feature requests are welcome.

Feel free to open issues or submit pull requests.

---

# License

MIT License
