Recipes¶
Bite-sized "I want to wire X" walkthroughs. Each page starts with what problem it solves, when to reach for it, and a complete code example you can copy verbatim.
When to read what
- Just need to look up a signature? Jump to Reference ».
- Building a brand-new service? Follow the linear Tutorial » first.
- Wiring a specific SDK piece? You're in the right place — pick the recipe below.
| Theme | Covers |
|---|---|
| Database » | BaseRepository, BaseModel, AuditMixin / SoftDeleteMixin, cursor pagination, Alembic helper |
| HTTP layer » | apply_cors, RequestIDMiddleware, RateLimitMiddleware, make_health_router, JWT / role / permission dependencies, webhook signature verifier, pagination Link headers, tool-spec router |
| Cache » | AsyncRedisManager, @cached decorator |
| Real-time » | Server-Sent Events (EventStream), Web Push (WebPushDispatcher) |
| Queue & Tasks » | FastStream (AsyncBrokerManager), TaskIQ (AsyncTaskBrokerManager), AsyncTaskScheduler, transactional outbox |
| Logging » | LogUtils, structured JSON logging, request-ID propagation |
| Metrics » | MetricsUtils — CPU / RAM / disk / GPU snapshots |
| Admin site » | AdminSite, AdminModel, make_admin_router, BaseUserModel |
| Testing » | test_session, test_database, in-memory SQLite, pytest fixtures |
| CLI » | tempest new / lint / fix / format / type / test / check |
| Security » | AttemptThrottle, opaque-token helpers, HardenedStaticFiles, security headers |
| Brazilian helpers » | CPF / CNPJ / CEP / phone validation + normalization |
Anatomy of a recipe¶
Every recipe follows the same four-section shape so you can skim:
- What it solves — one paragraph in plain language.
- When to use it — bullet list of situations + when not to.
- The code — complete, runnable, with
# 1. setup/# 2. wire/# 3. testannotations. - Gotchas — production caveats, security defaults, scaling notes.
If you spot a recipe that doesn't follow this shape, open an issue — we treat docs regressions like code regressions.