The engineering notebook
RSS feedBackend
Articles, practical guides, and engineering notes on Backend.
By Ashish Bhakhand 108 published articles
Explore the articles
42 articles
Reset filtersProduction FastAPI Middleware: Order Matters
Build request context, body limits, host checks, CORS, compression, and logging in an order that preserves reliable behavior.
Deterministic Tests by Injecting Time and IDs
Replace hidden calls to the clock and random UUID generator with tiny dependencies that make Jest tests exact and repeatable.
Designing a Stable API Envelope in FastAPI
Give mobile and web clients one predictable success, error, retry, and request-correlation contract.
Zod Beyond Basic Parsing: Strict Objects, Defaults, Coercion, and Inferred Types
Practical Zod patterns for safer query strings, configuration, discriminated inputs, and TypeScript contracts without duplicate types.
Who Owns the Transaction in a FastAPI Application?
Place transaction boundaries around complete business operations without pushing orchestration into routes or hiding it inside unrelated queries.
Building Event-Driven Features Without Losing Consistency
Use ownership, durable events, idempotent consumers, and rebuildable projections to keep asynchronous features understandable.
Direct SQL with asyncpg: Why I Do Not Add an ORM Automatically
Direct PostgreSQL access can make queries, constraints, and atomic behavior clearer when the team is willing to own the SQL.
Multi-Tenant Authorization Requires More Than Checking a JWT
Authentication proves identity. Safe multi-tenant APIs must also scope every resource query and action to the caller's organization.
FastAPI Lifespan: Managing Databases, Schedulers, and Shared Clients
Give long-lived resources clear startup and shutdown ownership instead of constructing them inside requests.