Real-time variable dumper for FastAPI — inspired by Laradumps
Project description
⚡ SmartDebugger
Real-time variable dump viewer for FastAPI — inspired by Laradumps.
Call sd(variable) anywhere in your FastAPI app and see it appear instantly in the browser.
Quick start
1. Install dependencies
pip install fastapi uvicorn requests
2. Start the debugger server
python run.py
Open http://localhost:8765 in your browser.
3. Use sd() in your FastAPI app
from client import ds
@app.get("/users/{user_id}")
async def get_user(user_id: int):
user = db.get_user(user_id)
sd(user, label="user from DB") # dumps to the UI, non-blocking
return user
Project structure
smart_debugger/
├── client/ # Python client library (the sd() function)
│ ├── __init__.py
│ └── ds.py
├── server/ # FastAPI dump server
│ ├── __init__.py
│ ├── app.py # Routes: POST /dump, GET /dumps, WS /ws
│ └── manager.py # WebSocket connection manager
├── static/ # Web UI (vanilla JS, no build step)
│ ├── index.html
│ ├── styles.css
│ └── app.js
├── example/
│ └── app.py # Demo FastAPI app
├── run.py # Server launcher
└── pyproject.toml
sd() reference
sd(data, label=None, level="info")
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
any | — | Any Python value to inspect |
label |
str | None |
Human-readable name shown in the UI |
level |
str | "info" |
One of info, debug, warning, error |
Returns data unchanged, so you can inline the call:
return sd(result, "final result")
Configuration
from client import configure
configure(
server_url="http://localhost:8765", # default
timeout=1.0, # seconds — kept short
enabled=True, # set False in production
)
UI features
- Real-time WebSocket feed
- Collapsible JSON tree viewer (auto-collapses at depth 3)
- Level badges:
info/debug/warning/error - Filter by level and free-text search (label, file, value)
- Sort newest / oldest
- Copy-to-clipboard button
- File + line number + function name for every dump
- Dark mode by default
Example routes (demo app)
# Start server
python run.py
# Start demo app in another terminal
uvicorn example.app:app --port 8000 --reload
# Hit the routes and watch the UI
curl http://localhost:8000/
curl http://localhost:8000/users/42
curl http://localhost:8000/error
curl -X POST http://localhost:8000/items \
-H "Content-Type: application/json" \
-d '{"name": "widget", "price": 9.99}'
curl http://localhost:8000/products
How it works
FastAPI app SmartDebugger server Browser
│ │ │
│ sd(data) │ │
│─── POST /dump ────────>│ │
│ (daemon thread) │── WS broadcast ─────>│
│ │ │ (live update)
│ (request continues) │ │
sd()captures the caller's file/line/function viainspect.- It serialises the value and fires a POST request on a daemon thread — completely non-blocking.
- The server stores the dump in a
deque(maxlen=200)and broadcasts it to all connected WebSocket clients. - The browser receives the payload and renders it as a collapsible JSON tree.
If the server is not running, sd() silently does nothing — it never crashes your app.
Disabling in production
import os
from client import configure
configure(enabled=os.getenv("DEBUG", "false").lower() == "true")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smartdump-0.1.0.tar.gz.
File metadata
- Download URL: smartdump-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3ef4307f3b178f4c7b7eb0ae4604f5ebe41990c151fb1c9d015bc4a2c742c27
|
|
| MD5 |
ef738b08f95fc7a5f46b5d96ea6eabfa
|
|
| BLAKE2b-256 |
d1cc0151ef0c3fc3626f24a0b635e5ab3ff9fc5402be8bf45aaa395212494048
|
File details
Details for the file smartdump-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smartdump-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b77050981611c37d71ab9e041795f217f24b800b54a49209cec81902964777b1
|
|
| MD5 |
531626cc7c1a3499728af9f8c7573691
|
|
| BLAKE2b-256 |
4a6defc90ade924914e0c4d4272ec4bed3f5743c66c21813c5f9108d2a2221e5
|