litestar-debug-toolbar 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. litestar_debug_toolbar-1.0.0/PKG-INFO +345 -0
  2. litestar_debug_toolbar-1.0.0/README.md +291 -0
  3. litestar_debug_toolbar-1.0.0/pyproject.toml +362 -0
  4. litestar_debug_toolbar-1.0.0/src/debug_toolbar/__init__.py +37 -0
  5. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/__init__.py +20 -0
  6. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/config.py +100 -0
  7. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/context.py +104 -0
  8. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panel.py +147 -0
  9. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/__init__.py +35 -0
  10. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/alerts.py +379 -0
  11. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/__init__.py +7 -0
  12. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/base.py +59 -0
  13. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/detector.py +307 -0
  14. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/models.py +57 -0
  15. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/panel.py +287 -0
  16. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/taskfactory.py +253 -0
  17. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/async_profiler/timeline.py +168 -0
  18. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/cache.py +425 -0
  19. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/flamegraph.py +125 -0
  20. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/headers.py +373 -0
  21. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/logging.py +95 -0
  22. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/memory/__init__.py +7 -0
  23. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/memory/base.py +57 -0
  24. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/memory/memray.py +224 -0
  25. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/memory/panel.py +184 -0
  26. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/memory/tracemalloc.py +142 -0
  27. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/profiling.py +389 -0
  28. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/request.py +50 -0
  29. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/response.py +43 -0
  30. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/settings.py +230 -0
  31. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/templates.py +250 -0
  32. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/timer.py +73 -0
  33. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/versions.py +62 -0
  34. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/panels/websocket.py +500 -0
  35. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/storage.py +164 -0
  36. litestar_debug_toolbar-1.0.0/src/debug_toolbar/core/toolbar.py +225 -0
  37. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/__init__.py +5 -0
  38. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/advanced_alchemy/__init__.py +10 -0
  39. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/advanced_alchemy/panel.py +587 -0
  40. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/strawberry/__init__.py +40 -0
  41. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/strawberry/analyzers.py +153 -0
  42. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/strawberry/extension.py +267 -0
  43. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/strawberry/models.py +111 -0
  44. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/strawberry/panel.py +191 -0
  45. litestar_debug_toolbar-1.0.0/src/debug_toolbar/extras/strawberry/utils.py +115 -0
  46. litestar_debug_toolbar-1.0.0/src/debug_toolbar/fastapi/__init__.py +27 -0
  47. litestar_debug_toolbar-1.0.0/src/debug_toolbar/fastapi/config.py +53 -0
  48. litestar_debug_toolbar-1.0.0/src/debug_toolbar/fastapi/middleware.py +173 -0
  49. litestar_debug_toolbar-1.0.0/src/debug_toolbar/fastapi/panels/__init__.py +7 -0
  50. litestar_debug_toolbar-1.0.0/src/debug_toolbar/fastapi/panels/dependencies.py +166 -0
  51. litestar_debug_toolbar-1.0.0/src/debug_toolbar/fastapi/setup.py +55 -0
  52. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/__init__.py +15 -0
  53. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/config.py +87 -0
  54. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/middleware.py +623 -0
  55. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/panels/__init__.py +9 -0
  56. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/panels/events.py +210 -0
  57. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/panels/routes.py +41 -0
  58. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/panels/static_files.py +87 -0
  59. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/plugin.py +163 -0
  60. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/routes/__init__.py +7 -0
  61. litestar_debug_toolbar-1.0.0/src/debug_toolbar/litestar/routes/handlers.py +3886 -0
  62. litestar_debug_toolbar-1.0.0/src/debug_toolbar/mcp/__init__.py +32 -0
  63. litestar_debug_toolbar-1.0.0/src/debug_toolbar/mcp/__main__.py +118 -0
  64. litestar_debug_toolbar-1.0.0/src/debug_toolbar/mcp/resources.py +325 -0
  65. litestar_debug_toolbar-1.0.0/src/debug_toolbar/mcp/security.py +113 -0
  66. litestar_debug_toolbar-1.0.0/src/debug_toolbar/mcp/server.py +106 -0
  67. litestar_debug_toolbar-1.0.0/src/debug_toolbar/mcp/tools.py +750 -0
  68. litestar_debug_toolbar-1.0.0/src/debug_toolbar/py.typed +1 -0
  69. litestar_debug_toolbar-1.0.0/src/debug_toolbar/starlette/__init__.py +40 -0
  70. litestar_debug_toolbar-1.0.0/src/debug_toolbar/starlette/config.py +81 -0
  71. litestar_debug_toolbar-1.0.0/src/debug_toolbar/starlette/middleware.py +470 -0
  72. litestar_debug_toolbar-1.0.0/src/debug_toolbar/starlette/panels/__init__.py +7 -0
  73. litestar_debug_toolbar-1.0.0/src/debug_toolbar/starlette/panels/routes.py +48 -0
  74. litestar_debug_toolbar-1.0.0/src/debug_toolbar/starlette/routes.py +227 -0
  75. litestar_debug_toolbar-1.0.0/src/debug_toolbar/templates/panels/websocket.html +539 -0
@@ -0,0 +1,345 @@
1
+ Metadata-Version: 2.3
2
+ Name: litestar-debug-toolbar
3
+ Version: 1.0.0
4
+ Summary: Async-native debug toolbar for Python ASGI frameworks with optional Litestar integration
5
+ Keywords: async,asgi,debug,toolbar,profiling,litestar,fastapi,starlette
6
+ Author: Jacob Coffee
7
+ Author-email: Jacob Coffee <jacob@z7x.org>
8
+ License: MIT
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Framework :: AsyncIO
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Debuggers
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Typing :: Typed
28
+ Requires-Dist: jinja2>=3.1.0
29
+ Requires-Dist: markupsafe>=2.1.0
30
+ Requires-Dist: advanced-alchemy>=0.10.0 ; extra == 'advanced-alchemy'
31
+ Requires-Dist: aiosqlite>=0.19.0 ; extra == 'advanced-alchemy'
32
+ Requires-Dist: sqlalchemy>=2.0.0 ; extra == 'advanced-alchemy'
33
+ Requires-Dist: litestar-debug-toolbar[litestar,starlette,fastapi,advanced-alchemy,strawberry,mcp] ; extra == 'all'
34
+ Requires-Dist: fastapi>=0.100.0 ; extra == 'fastapi'
35
+ Requires-Dist: litestar>=2.0.0 ; extra == 'litestar'
36
+ Requires-Dist: mcp>=1.0.0 ; extra == 'mcp'
37
+ Requires-Dist: starlette>=0.27.0 ; extra == 'starlette'
38
+ Requires-Dist: strawberry-graphql>=0.240.0 ; extra == 'strawberry'
39
+ Requires-Python: >=3.10
40
+ Project-URL: Changelog, https://github.com/JacobCoffee/debug-toolbar/releases/
41
+ Project-URL: Discord, https://discord.gg/litestar-919193495116337154
42
+ Project-URL: Documentation, https://jacobcoffee.github.io/debug-toolbar
43
+ Project-URL: Homepage, https://github.com/JacobCoffee/debug-toolbar
44
+ Project-URL: Issue Tracker, https://github.com/JacobCoffee/debug-toolbar/issues
45
+ Project-URL: Repository, https://github.com/JacobCoffee/debug-toolbar
46
+ Provides-Extra: advanced-alchemy
47
+ Provides-Extra: all
48
+ Provides-Extra: fastapi
49
+ Provides-Extra: litestar
50
+ Provides-Extra: mcp
51
+ Provides-Extra: starlette
52
+ Provides-Extra: strawberry
53
+ Description-Content-Type: text/markdown
54
+
55
+ # debug-toolbar
56
+
57
+ <p align="center">
58
+ <em>Async-native debug toolbar for Python ASGI frameworks with first-class Litestar support.</em>
59
+ </p>
60
+
61
+ <p align="center">
62
+ <a href="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/ci.yml">
63
+ <img src="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/ci.yml/badge.svg" alt="Tests And Linting">
64
+ </a>
65
+ <a href="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/publish.yml">
66
+ <img src="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/publish.yml/badge.svg" alt="Latest Release">
67
+ </a>
68
+ <a href="https://pypi.org/project/litestar-debug-toolbar/">
69
+ <img src="https://img.shields.io/pypi/v/litestar-debug-toolbar.svg" alt="PyPI Version">
70
+ </a>
71
+ <a href="https://pypi.org/project/litestar-debug-toolbar/">
72
+ <img src="https://img.shields.io/pypi/pyversions/litestar-debug-toolbar.svg" alt="Python Versions">
73
+ </a>
74
+ <a href="https://github.com/JacobCoffee/debug-toolbar/blob/main/LICENSE">
75
+ <img src="https://img.shields.io/github/license/JacobCoffee/debug-toolbar.svg" alt="License">
76
+ </a>
77
+ </p>
78
+
79
+ ---
80
+
81
+ **Documentation**: [https://jacobcoffee.github.io/debug-toolbar](https://jacobcoffee.github.io/debug-toolbar)
82
+
83
+ **Source Code**: [https://github.com/JacobCoffee/debug-toolbar](https://github.com/JacobCoffee/debug-toolbar)
84
+
85
+ ---
86
+
87
+ ## Screenshots
88
+
89
+ <p align="center">
90
+ <img src="assets/toolbar-right-position.png" alt="Debug Toolbar - Right Position" width="100%">
91
+ </p>
92
+
93
+ <details>
94
+ <summary>More Screenshots</summary>
95
+
96
+ ### Full-Width Top Position
97
+ <img src="assets/toolbar-top-position.png" alt="Debug Toolbar - Top Position" width="100%">
98
+
99
+ ### SQL Queries with EXPLAIN
100
+ <img src="assets/toolbar-users-queries.png" alt="Debug Toolbar - SQL Queries" width="100%">
101
+
102
+ ### EXPLAIN Query Plan Modal
103
+ <img src="assets/toolbar-explain-modal.png" alt="Debug Toolbar - EXPLAIN Modal" width="100%">
104
+
105
+ ### Light Theme
106
+ <img src="assets/toolbar-light-theme.png" alt="Debug Toolbar - Light Theme" width="100%">
107
+
108
+ ### Request History
109
+ <img src="assets/toolbar-request-history.png" alt="Debug Toolbar - Request History" width="100%">
110
+
111
+ ### Events Panel (Lifecycle Hooks)
112
+ <img src="assets/toolbar-events-panel.png" alt="Debug Toolbar - Events Panel" width="100%">
113
+
114
+ ### N+1 Query Detection
115
+ <img src="assets/toolbar-n-plus-one-detection.png" alt="Debug Toolbar - N+1 Detection" width="100%">
116
+
117
+ ### Alerts Panel (Proactive Issue Detection)
118
+ <img src="assets/panel-alerts-expanded.png" alt="Debug Toolbar - Alerts Panel" width="100%">
119
+
120
+ ### MCP Integration (Claude Code)
121
+ <img src="assets/mcp-integration-example.png" alt="Debug Toolbar - MCP Integration with Claude Code" width="100%">
122
+
123
+ ### Memory Panel
124
+ <img src="assets/panel-memory-expanded.png" alt="Debug Toolbar - Memory Panel" width="100%">
125
+
126
+ ### SQL Panel with Query Analysis
127
+ <img src="assets/panel-sql-expanded.png" alt="Debug Toolbar - SQL Panel" width="100%">
128
+
129
+ ### Profiling Panel
130
+ <img src="assets/panel-profiling-expanded.png" alt="Debug Toolbar - Profiling Panel" width="100%">
131
+
132
+ ### WebSocket Panel (Live Updates)
133
+ <img src="assets/toolbar-websocket-panel.png" alt="Debug Toolbar - WebSocket Panel" width="100%">
134
+
135
+ </details>
136
+
137
+ ## Features
138
+
139
+ - **Async-Native**: Built from the ground up for async/await patterns
140
+ - **Framework-Agnostic Core**: Core package works with any ASGI framework
141
+ - **Litestar Integration**: First-class plugin support for Litestar applications
142
+ - **Pluggable Panels**: Easy to add, remove, or customize debug panels
143
+ - **Minimal Overhead**: Negligible performance impact when disabled
144
+ - **Type-Safe**: Full type annotations with strict type checking
145
+ - **Dark/Light Themes**: Toggle between dark and light themes
146
+ - **Flexible Positioning**: Place toolbar on any edge (left, right, top, bottom)
147
+ - **SQL Query Analysis**: EXPLAIN query plans for PostgreSQL, SQLite, MySQL, MariaDB
148
+ - **N+1 Detection**: Automatic detection of N+1 query patterns with fix suggestions
149
+ - **Flame Graphs**: Interactive profiling visualization in speedscope format
150
+ - **Memory Profiling**: Multi-backend support (tracemalloc, memray)
151
+ - **Proactive Alerts**: Automatic detection of security, performance, and database issues
152
+ - **MCP Integration**: AI assistant integration for automated debugging with Claude Code
153
+ - **WebSocket Debugging**: Real-time connection tracking with live updates and message inspection
154
+
155
+ ## Installation
156
+
157
+ ```bash
158
+ # Core package only
159
+ pip install litestar-debug-toolbar
160
+
161
+ # With Litestar integration
162
+ pip install litestar-debug-toolbar[litestar]
163
+
164
+ # With Advanced-Alchemy SQLAlchemy panel
165
+ pip install litestar-debug-toolbar[advanced-alchemy]
166
+
167
+ # All extras
168
+ pip install litestar-debug-toolbar[all]
169
+ ```
170
+
171
+ Or with [uv](https://github.com/astral-sh/uv):
172
+
173
+ ```bash
174
+ uv add litestar-debug-toolbar[litestar]
175
+ ```
176
+
177
+ ## Quick Start
178
+
179
+ ### Litestar
180
+
181
+ ```python
182
+ from litestar import Litestar, get
183
+ from debug_toolbar.litestar import DebugToolbarPlugin, LitestarDebugToolbarConfig
184
+
185
+ @get("/")
186
+ async def index() -> dict[str, str]:
187
+ return {"message": "Hello, World!"}
188
+
189
+ config = LitestarDebugToolbarConfig(enabled=True)
190
+ app = Litestar(
191
+ route_handlers=[index],
192
+ plugins=[DebugToolbarPlugin(config)],
193
+ )
194
+ ```
195
+
196
+ ### With SQLAlchemy (Advanced-Alchemy)
197
+
198
+ ```python
199
+ from litestar import Litestar
200
+ from advanced_alchemy.extensions.litestar import SQLAlchemyPlugin, SQLAlchemyAsyncConfig
201
+ from debug_toolbar.litestar import DebugToolbarPlugin, LitestarDebugToolbarConfig
202
+
203
+ db_config = SQLAlchemyAsyncConfig(connection_string="sqlite+aiosqlite:///app.db")
204
+ toolbar_config = LitestarDebugToolbarConfig(
205
+ enabled=True,
206
+ extra_panels=["debug_toolbar.extras.advanced_alchemy.SQLAlchemyPanel"],
207
+ )
208
+
209
+ app = Litestar(
210
+ plugins=[
211
+ SQLAlchemyPlugin(config=db_config),
212
+ DebugToolbarPlugin(toolbar_config),
213
+ ],
214
+ )
215
+ ```
216
+
217
+ ### Generic ASGI
218
+
219
+ ```python
220
+ from debug_toolbar import DebugToolbar, DebugToolbarConfig
221
+
222
+ config = DebugToolbarConfig(enabled=True)
223
+ toolbar = DebugToolbar(config)
224
+
225
+ # Wrap your ASGI app
226
+ app = toolbar.wrap(your_asgi_app)
227
+ ```
228
+
229
+ ## Built-in Panels
230
+
231
+ | Panel | Description |
232
+ |-------|-------------|
233
+ | **Timer** | Request timing and CPU time |
234
+ | **Request** | HTTP method, path, headers, cookies |
235
+ | **Response** | Status code, response headers |
236
+ | **Logging** | Log records captured during request |
237
+ | **Versions** | Python and package versions |
238
+ | **Headers** | Categorized headers with security analysis |
239
+ | **Settings** | Application configuration viewer |
240
+ | **Templates** | Jinja2/Mako render tracking |
241
+ | **Profiling** | cProfile/pyinstrument with flame graphs |
242
+ | **Alerts** | Proactive security/performance issue detection |
243
+ | **Memory** | Memory profiling (tracemalloc/memray) |
244
+ | **Cache** | Redis/memcached operation tracking |
245
+ | **Routes** | Application routes (Litestar-specific) |
246
+ | **Events** | Lifecycle hooks and exception handlers (Litestar-specific) |
247
+ | **WebSocket** | Real-time connection tracking, message inspection, live updates |
248
+ | **SQLAlchemy** | Query tracking with N+1 detection (requires `advanced-alchemy` extra) |
249
+
250
+ ## Configuration
251
+
252
+ ```python
253
+ from debug_toolbar.litestar import LitestarDebugToolbarConfig
254
+
255
+ config = LitestarDebugToolbarConfig(
256
+ enabled=True,
257
+ exclude_paths=["/_debug_toolbar", "/static", "/health"],
258
+ max_request_history=50,
259
+ intercept_redirects=False,
260
+ show_toolbar_callback=lambda request: request.app.debug,
261
+ extra_panels=["myapp.panels.CustomPanel"],
262
+ exclude_panels=["VersionsPanel"],
263
+ )
264
+ ```
265
+
266
+ ## Creating Custom Panels
267
+
268
+ ```python
269
+ from typing import Any, ClassVar
270
+ from debug_toolbar.core import Panel, RequestContext
271
+
272
+ class MyCustomPanel(Panel):
273
+ panel_id: ClassVar[str] = "MyCustomPanel"
274
+ title: ClassVar[str] = "My Panel"
275
+ template: ClassVar[str] = "panels/my_panel.html"
276
+ has_content: ClassVar[bool] = True
277
+
278
+ async def generate_stats(self, context: RequestContext) -> dict[str, Any]:
279
+ return {"custom_data": "Your debug information here"}
280
+ ```
281
+
282
+ ## Development
283
+
284
+ ```bash
285
+ # Clone the repository
286
+ git clone https://github.com/JacobCoffee/debug-toolbar.git
287
+ cd debug-toolbar
288
+
289
+ # Install dependencies
290
+ make dev
291
+
292
+ # Run tests
293
+ make test
294
+
295
+ # Run all CI checks
296
+ make ci
297
+ ```
298
+
299
+ ## Package Structure
300
+
301
+ ```
302
+ debug_toolbar/
303
+ ├── core/ # Framework-agnostic core
304
+ │ ├── panels/ # Built-in panels
305
+ │ │ ├── timer.py, request.py, response.py # Default panels
306
+ │ │ ├── headers.py, settings.py # Optional panels
307
+ │ │ ├── profiling.py, memory/, alerts.py # Advanced panels
308
+ │ │ ├── templates.py, cache.py # Integration panels
309
+ │ │ └── websocket.py # WebSocket debugging
310
+ │ ├── config.py # DebugToolbarConfig
311
+ │ ├── context.py # RequestContext (contextvars-based)
312
+ │ ├── panel.py # Panel base class
313
+ │ ├── storage.py # LRU request history storage
314
+ │ └── toolbar.py # DebugToolbar manager
315
+ ├── litestar/ # Litestar integration
316
+ │ ├── panels/ # Litestar-specific panels (routes, events)
317
+ │ ├── config.py # LitestarDebugToolbarConfig
318
+ │ ├── middleware.py
319
+ │ └── plugin.py # DebugToolbarPlugin
320
+ └── extras/ # Optional integrations
321
+ └── advanced_alchemy/ # SQLAlchemy panel with N+1 detection
322
+ ```
323
+
324
+ ## Versioning
325
+
326
+ This project uses [Semantic Versioning](https://semver.org/).
327
+
328
+ - Major versions introduce breaking changes
329
+ - Major versions support currently supported Litestar versions
330
+ - See the [Litestar Versioning Policy](https://litestar.dev/about/litestar-releases#version-numbering) for details
331
+
332
+ ## Contributing
333
+
334
+ Contributions are welcome! Please see [CONTRIBUTING.rst](CONTRIBUTING.rst) for guidelines.
335
+
336
+ ## License
337
+
338
+ MIT License - see [LICENSE](LICENSE) for details.
339
+
340
+ ## Acknowledgements
341
+
342
+ Inspired by:
343
+ - [django-debug-toolbar](https://github.com/django-commons/django-debug-toolbar)
344
+ - [flask-debugtoolbar](https://github.com/pallets-eco/flask-debugtoolbar)
345
+ - [fastapi-debug-toolbar](https://github.com/mongkok/fastapi-debug-toolbar)
@@ -0,0 +1,291 @@
1
+ # debug-toolbar
2
+
3
+ <p align="center">
4
+ <em>Async-native debug toolbar for Python ASGI frameworks with first-class Litestar support.</em>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/ci.yml">
9
+ <img src="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/ci.yml/badge.svg" alt="Tests And Linting">
10
+ </a>
11
+ <a href="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/publish.yml">
12
+ <img src="https://github.com/JacobCoffee/debug-toolbar/actions/workflows/publish.yml/badge.svg" alt="Latest Release">
13
+ </a>
14
+ <a href="https://pypi.org/project/litestar-debug-toolbar/">
15
+ <img src="https://img.shields.io/pypi/v/litestar-debug-toolbar.svg" alt="PyPI Version">
16
+ </a>
17
+ <a href="https://pypi.org/project/litestar-debug-toolbar/">
18
+ <img src="https://img.shields.io/pypi/pyversions/litestar-debug-toolbar.svg" alt="Python Versions">
19
+ </a>
20
+ <a href="https://github.com/JacobCoffee/debug-toolbar/blob/main/LICENSE">
21
+ <img src="https://img.shields.io/github/license/JacobCoffee/debug-toolbar.svg" alt="License">
22
+ </a>
23
+ </p>
24
+
25
+ ---
26
+
27
+ **Documentation**: [https://jacobcoffee.github.io/debug-toolbar](https://jacobcoffee.github.io/debug-toolbar)
28
+
29
+ **Source Code**: [https://github.com/JacobCoffee/debug-toolbar](https://github.com/JacobCoffee/debug-toolbar)
30
+
31
+ ---
32
+
33
+ ## Screenshots
34
+
35
+ <p align="center">
36
+ <img src="assets/toolbar-right-position.png" alt="Debug Toolbar - Right Position" width="100%">
37
+ </p>
38
+
39
+ <details>
40
+ <summary>More Screenshots</summary>
41
+
42
+ ### Full-Width Top Position
43
+ <img src="assets/toolbar-top-position.png" alt="Debug Toolbar - Top Position" width="100%">
44
+
45
+ ### SQL Queries with EXPLAIN
46
+ <img src="assets/toolbar-users-queries.png" alt="Debug Toolbar - SQL Queries" width="100%">
47
+
48
+ ### EXPLAIN Query Plan Modal
49
+ <img src="assets/toolbar-explain-modal.png" alt="Debug Toolbar - EXPLAIN Modal" width="100%">
50
+
51
+ ### Light Theme
52
+ <img src="assets/toolbar-light-theme.png" alt="Debug Toolbar - Light Theme" width="100%">
53
+
54
+ ### Request History
55
+ <img src="assets/toolbar-request-history.png" alt="Debug Toolbar - Request History" width="100%">
56
+
57
+ ### Events Panel (Lifecycle Hooks)
58
+ <img src="assets/toolbar-events-panel.png" alt="Debug Toolbar - Events Panel" width="100%">
59
+
60
+ ### N+1 Query Detection
61
+ <img src="assets/toolbar-n-plus-one-detection.png" alt="Debug Toolbar - N+1 Detection" width="100%">
62
+
63
+ ### Alerts Panel (Proactive Issue Detection)
64
+ <img src="assets/panel-alerts-expanded.png" alt="Debug Toolbar - Alerts Panel" width="100%">
65
+
66
+ ### MCP Integration (Claude Code)
67
+ <img src="assets/mcp-integration-example.png" alt="Debug Toolbar - MCP Integration with Claude Code" width="100%">
68
+
69
+ ### Memory Panel
70
+ <img src="assets/panel-memory-expanded.png" alt="Debug Toolbar - Memory Panel" width="100%">
71
+
72
+ ### SQL Panel with Query Analysis
73
+ <img src="assets/panel-sql-expanded.png" alt="Debug Toolbar - SQL Panel" width="100%">
74
+
75
+ ### Profiling Panel
76
+ <img src="assets/panel-profiling-expanded.png" alt="Debug Toolbar - Profiling Panel" width="100%">
77
+
78
+ ### WebSocket Panel (Live Updates)
79
+ <img src="assets/toolbar-websocket-panel.png" alt="Debug Toolbar - WebSocket Panel" width="100%">
80
+
81
+ </details>
82
+
83
+ ## Features
84
+
85
+ - **Async-Native**: Built from the ground up for async/await patterns
86
+ - **Framework-Agnostic Core**: Core package works with any ASGI framework
87
+ - **Litestar Integration**: First-class plugin support for Litestar applications
88
+ - **Pluggable Panels**: Easy to add, remove, or customize debug panels
89
+ - **Minimal Overhead**: Negligible performance impact when disabled
90
+ - **Type-Safe**: Full type annotations with strict type checking
91
+ - **Dark/Light Themes**: Toggle between dark and light themes
92
+ - **Flexible Positioning**: Place toolbar on any edge (left, right, top, bottom)
93
+ - **SQL Query Analysis**: EXPLAIN query plans for PostgreSQL, SQLite, MySQL, MariaDB
94
+ - **N+1 Detection**: Automatic detection of N+1 query patterns with fix suggestions
95
+ - **Flame Graphs**: Interactive profiling visualization in speedscope format
96
+ - **Memory Profiling**: Multi-backend support (tracemalloc, memray)
97
+ - **Proactive Alerts**: Automatic detection of security, performance, and database issues
98
+ - **MCP Integration**: AI assistant integration for automated debugging with Claude Code
99
+ - **WebSocket Debugging**: Real-time connection tracking with live updates and message inspection
100
+
101
+ ## Installation
102
+
103
+ ```bash
104
+ # Core package only
105
+ pip install litestar-debug-toolbar
106
+
107
+ # With Litestar integration
108
+ pip install litestar-debug-toolbar[litestar]
109
+
110
+ # With Advanced-Alchemy SQLAlchemy panel
111
+ pip install litestar-debug-toolbar[advanced-alchemy]
112
+
113
+ # All extras
114
+ pip install litestar-debug-toolbar[all]
115
+ ```
116
+
117
+ Or with [uv](https://github.com/astral-sh/uv):
118
+
119
+ ```bash
120
+ uv add litestar-debug-toolbar[litestar]
121
+ ```
122
+
123
+ ## Quick Start
124
+
125
+ ### Litestar
126
+
127
+ ```python
128
+ from litestar import Litestar, get
129
+ from debug_toolbar.litestar import DebugToolbarPlugin, LitestarDebugToolbarConfig
130
+
131
+ @get("/")
132
+ async def index() -> dict[str, str]:
133
+ return {"message": "Hello, World!"}
134
+
135
+ config = LitestarDebugToolbarConfig(enabled=True)
136
+ app = Litestar(
137
+ route_handlers=[index],
138
+ plugins=[DebugToolbarPlugin(config)],
139
+ )
140
+ ```
141
+
142
+ ### With SQLAlchemy (Advanced-Alchemy)
143
+
144
+ ```python
145
+ from litestar import Litestar
146
+ from advanced_alchemy.extensions.litestar import SQLAlchemyPlugin, SQLAlchemyAsyncConfig
147
+ from debug_toolbar.litestar import DebugToolbarPlugin, LitestarDebugToolbarConfig
148
+
149
+ db_config = SQLAlchemyAsyncConfig(connection_string="sqlite+aiosqlite:///app.db")
150
+ toolbar_config = LitestarDebugToolbarConfig(
151
+ enabled=True,
152
+ extra_panels=["debug_toolbar.extras.advanced_alchemy.SQLAlchemyPanel"],
153
+ )
154
+
155
+ app = Litestar(
156
+ plugins=[
157
+ SQLAlchemyPlugin(config=db_config),
158
+ DebugToolbarPlugin(toolbar_config),
159
+ ],
160
+ )
161
+ ```
162
+
163
+ ### Generic ASGI
164
+
165
+ ```python
166
+ from debug_toolbar import DebugToolbar, DebugToolbarConfig
167
+
168
+ config = DebugToolbarConfig(enabled=True)
169
+ toolbar = DebugToolbar(config)
170
+
171
+ # Wrap your ASGI app
172
+ app = toolbar.wrap(your_asgi_app)
173
+ ```
174
+
175
+ ## Built-in Panels
176
+
177
+ | Panel | Description |
178
+ |-------|-------------|
179
+ | **Timer** | Request timing and CPU time |
180
+ | **Request** | HTTP method, path, headers, cookies |
181
+ | **Response** | Status code, response headers |
182
+ | **Logging** | Log records captured during request |
183
+ | **Versions** | Python and package versions |
184
+ | **Headers** | Categorized headers with security analysis |
185
+ | **Settings** | Application configuration viewer |
186
+ | **Templates** | Jinja2/Mako render tracking |
187
+ | **Profiling** | cProfile/pyinstrument with flame graphs |
188
+ | **Alerts** | Proactive security/performance issue detection |
189
+ | **Memory** | Memory profiling (tracemalloc/memray) |
190
+ | **Cache** | Redis/memcached operation tracking |
191
+ | **Routes** | Application routes (Litestar-specific) |
192
+ | **Events** | Lifecycle hooks and exception handlers (Litestar-specific) |
193
+ | **WebSocket** | Real-time connection tracking, message inspection, live updates |
194
+ | **SQLAlchemy** | Query tracking with N+1 detection (requires `advanced-alchemy` extra) |
195
+
196
+ ## Configuration
197
+
198
+ ```python
199
+ from debug_toolbar.litestar import LitestarDebugToolbarConfig
200
+
201
+ config = LitestarDebugToolbarConfig(
202
+ enabled=True,
203
+ exclude_paths=["/_debug_toolbar", "/static", "/health"],
204
+ max_request_history=50,
205
+ intercept_redirects=False,
206
+ show_toolbar_callback=lambda request: request.app.debug,
207
+ extra_panels=["myapp.panels.CustomPanel"],
208
+ exclude_panels=["VersionsPanel"],
209
+ )
210
+ ```
211
+
212
+ ## Creating Custom Panels
213
+
214
+ ```python
215
+ from typing import Any, ClassVar
216
+ from debug_toolbar.core import Panel, RequestContext
217
+
218
+ class MyCustomPanel(Panel):
219
+ panel_id: ClassVar[str] = "MyCustomPanel"
220
+ title: ClassVar[str] = "My Panel"
221
+ template: ClassVar[str] = "panels/my_panel.html"
222
+ has_content: ClassVar[bool] = True
223
+
224
+ async def generate_stats(self, context: RequestContext) -> dict[str, Any]:
225
+ return {"custom_data": "Your debug information here"}
226
+ ```
227
+
228
+ ## Development
229
+
230
+ ```bash
231
+ # Clone the repository
232
+ git clone https://github.com/JacobCoffee/debug-toolbar.git
233
+ cd debug-toolbar
234
+
235
+ # Install dependencies
236
+ make dev
237
+
238
+ # Run tests
239
+ make test
240
+
241
+ # Run all CI checks
242
+ make ci
243
+ ```
244
+
245
+ ## Package Structure
246
+
247
+ ```
248
+ debug_toolbar/
249
+ ├── core/ # Framework-agnostic core
250
+ │ ├── panels/ # Built-in panels
251
+ │ │ ├── timer.py, request.py, response.py # Default panels
252
+ │ │ ├── headers.py, settings.py # Optional panels
253
+ │ │ ├── profiling.py, memory/, alerts.py # Advanced panels
254
+ │ │ ├── templates.py, cache.py # Integration panels
255
+ │ │ └── websocket.py # WebSocket debugging
256
+ │ ├── config.py # DebugToolbarConfig
257
+ │ ├── context.py # RequestContext (contextvars-based)
258
+ │ ├── panel.py # Panel base class
259
+ │ ├── storage.py # LRU request history storage
260
+ │ └── toolbar.py # DebugToolbar manager
261
+ ├── litestar/ # Litestar integration
262
+ │ ├── panels/ # Litestar-specific panels (routes, events)
263
+ │ ├── config.py # LitestarDebugToolbarConfig
264
+ │ ├── middleware.py
265
+ │ └── plugin.py # DebugToolbarPlugin
266
+ └── extras/ # Optional integrations
267
+ └── advanced_alchemy/ # SQLAlchemy panel with N+1 detection
268
+ ```
269
+
270
+ ## Versioning
271
+
272
+ This project uses [Semantic Versioning](https://semver.org/).
273
+
274
+ - Major versions introduce breaking changes
275
+ - Major versions support currently supported Litestar versions
276
+ - See the [Litestar Versioning Policy](https://litestar.dev/about/litestar-releases#version-numbering) for details
277
+
278
+ ## Contributing
279
+
280
+ Contributions are welcome! Please see [CONTRIBUTING.rst](CONTRIBUTING.rst) for guidelines.
281
+
282
+ ## License
283
+
284
+ MIT License - see [LICENSE](LICENSE) for details.
285
+
286
+ ## Acknowledgements
287
+
288
+ Inspired by:
289
+ - [django-debug-toolbar](https://github.com/django-commons/django-debug-toolbar)
290
+ - [flask-debugtoolbar](https://github.com/pallets-eco/flask-debugtoolbar)
291
+ - [fastapi-debug-toolbar](https://github.com/mongkok/fastapi-debug-toolbar)