Automatic Transaction Rollback
SQLAlchemy rolls back the entire transaction automatically when an exception occurs mid-request — no partial writes, no corrupt state.
Buraq brings Django's developer experience — ORM, admin, forms, CBVs — to the modern async ecosystem, built on FastAPI and SQLAlchemy 2.0.
from buraq import Buraq
from buraq import models
from buraq.shortcuts import render
app = Buraq(settings_module="config.settings")
class Post(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
is_published = models.BooleanField(default=False)
created = models.DateTimeField(auto_now_add=True)
@app.get("/posts/")
async def post_list(request):
posts = await Post.objects.filter(is_published=True).order_by("-created")
return await render(request, "posts/list.html", {"posts": posts})Built on foundations you already trust
Why Buraq
Stop choosing between developer ergonomics and async performance. Buraq gives you both without compromise.
SQLAlchemy rolls back the entire transaction automatically when an exception occurs mid-request — no partial writes, no corrupt state.
Every view, ORM call, form validator, and signal handler is natively async. No sync_to_async(), no asyncio.run() hacks. One event loop.
A rich browser-based debug page — source context, local variables per frame, full request headers — shown automatically when DEBUG = True.
Model.objects.filter(), Q objects, F expressions, select_related, signals, and get_or_404 — powered by SQLAlchemy 2.0 async.
A full CRUD admin at /admin — list, filter, search, create, edit, delete — bundled inside Buraq. No sqladmin dependency.
Auto-generate forms from model columns with field-level and cross-field async validation. CSRF protection built in.
ListView, DetailView, CreateView, UpdateView, DeleteView — the same CBV patterns developers already know.
Automatic OpenAPI docs at /api/docs, Pydantic integration, dependency injection, and full Starlette middleware compatibility.
Ships with Granian — a Rust-based ASGI server that outperforms uvicorn and hypercorn in benchmarks. buraq runserver just works.
Built-in user model, login_required, permission_required, groups, and session-based auth — no extra packages.
Django-style internationalization with gettext, translatable model fields, and per-request locale switching.
startproject, startapp, migrate, makemigrations, createsuperuser, collectstatic — everything you expect from a batteries-included framework.
Comparison
The best of two worlds, without the tradeoffs of either.
| Feature | Django | FastAPI | Buraq |
|---|---|---|---|
| True async queries† | ✕ | ✕ | ✓ |
| Auto transaction rollback | opt-in | ✕ | ✓ |
| ORM API | ✓ | ✕ | ✓ |
| Admin panel | ✓ | ✕ | ✓ |
| ModelForm & validation | ✓ | ✕ | ✓ |
| Class-based views | ✓ | ✕ | ✓ |
| Auto OpenAPI docs | ✕ | ✓ | ✓ |
| Type safety | partial | ✓ | ✓ |
| No sync wrappers needed | ✕ | ✓ | ✓ |
| Built-in debug error page | ✓ | ✕ | ✓ |
| manage.py CLI | ✓ | ✕ | ✓ |
Django ships async query methods, but they wrap the synchronous ORM and run on one shared thread —see the measurement.
Architecture
Django's ORM is synchronous. Its async methods wrap the sync implementation, so concurrent queries queue behind one another. Buraq's ORM is async all the way down — concurrency is bounded by your connection pool, not by a shared thread.
# django/db/models/query.py
async def aget(self, *args, **kwargs):
return await sync_to_async(self.get)(*args, **kwargs)sync_to_async defaults to thread_sensitive=True, which runs every call on one shared thread.
# asyncpg / aiosqlite driver, awaited directly
post = await Post.objects.get(id=1)Real non-blocking I/O. Thousands of in-flight queries on a single thread, limited only by the pool.
8 concurrent queries, 100 ms each
aget()0.81sMeasured with asgiref.sync_to_async at Django's default settings — the same call path aget() uses. Serialised through one thread versus running concurrently.
AI-Ready
Buraq's async-first design means every part of your stack — API calls, database writes, background jobs — runs concurrently without blocking.
Await OpenAI, Anthropic, or any async AI SDK directly in your views. The event loop stays free while the model thinks.
FastAPI underneath gives you typed request/response schemas and live docs at /api/docs — perfect for AI microservices.
Bundled Rust-based ASGI server handles hundreds of concurrent AI requests with lower latency than gunicorn or uvicorn.
Store chat history, embeddings, and model outputs via the async ORM. Works with SQLite, PostgreSQL, and MySQL.
Offload slow inference or embedding generation to buraq worker background tasks — results written to the DB when ready.
Built-in user sessions, login_required, and rate limiting — everything needed to secure a multi-user AI assistant.
from buraq import Buraq
from buraq.contrib.auth.decorators import login_required
from fastapi.responses import StreamingResponse
from anthropic import AsyncAnthropic
app = Buraq(settings_module="config.settings")
llm = AsyncAnthropic()
@app.post("/chat/")
@login_required
async def chat(request):
body = await request.json()
prompt = body["message"]
async def token_stream():
async with llm.messages.stream(
model="claude-opus-5",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}],
) as stream:
async for text in stream.text_stream:
yield text
return StreamingResponse(token_stream(), media_type="text/plain")One command sets up a full project with database, admin, and auth ready to go.