AI-Written Code and Tests: The Shared Blind Spots Trap

You ask your AI coding agent to implement a FastAPI endpoint, then ask it to write the unit tests. pytest turns green. pytest --cov reports 100% line coverage. The diff looks clean, the assertions are readable, and the PR is ready to merge. Three days later, a client sends a slightly malformed payload and your endpoint returns a 500 error or silently applies a negative discount. This is not a freak incident. With AI-written tests generated in the same session as the implementation, both artifacts share the exact same implicit assumptions. The tests do not prove that the code survives reality: they only prove that the code matches what the model had in mind when it wrote it. ...

November 28, 2026 · 5 min · Anthony
AI-Written Code and Tests: The Shared Blind Spots Trap

Redis Pub/Sub vs Streams: Which to Choose in Python?

Redis Pub/Sub and Redis Streams seem to meet the same need: a producer emits, consumers receive. Both take a few lines to set up, and in a development environment they produce the same result. The difference shows up with a single question: what happens if the consumer isn’t there when the message is sent? A deployment, a network drop or a crashed worker is enough to raise it. The answer actually separates three models: Pub/Sub broadcast, reading a log with XREAD, and sharing work with consumer groups. ...

November 4, 2026 · 8 min · Anthony
Redis Pub/Sub vs Streams: Which to Choose in Python?

Polling, Long Polling or SSE: What to Choose in Python?

An order changes status, an export finishes, a message arrives. The server knows, the browser doesn’t. Polling, long polling and Server-Sent Events (SSE) all answer that same question, and they often get mixed up because the result on screen looks alike. What separates them is who triggers the delivery and what silence costs, when nothing changes. Let’s look at how each one works, what it really costs, and why the simplest solution is often the right one. ...

October 5, 2026 · 7 min · Anthony
Polling, Long Polling or SSE: What to Choose in Python?

Server-Sent Events vs WebSocket: Which to Choose in Python?

As soon as a screen has to update without a page reload, WebSocket enters the conversation. Order tracking, export progress, notifications, an LLM answer appearing token by token: the reflex is to open a bidirectional channel. Yet in all of these cases, the client has nothing to say to the server once the connection is established. The Server-Sent Events (SSE) pattern meets exactly this need with a plain HTTP response that never ends. The choice goes beyond protocol preference. It determines what you get for free (reconnection, resumption, HTTP authentication) and what you will have to build yourself. Let’s compare the two in Python, with FastAPI and Django, all the way to the problems that only show up in production. ...

September 15, 2026 · 11 min · Anthony
Server-Sent Events vs WebSocket: Which to Choose in Python?

Django 6.1 fetch modes and DB_CASCADE: what to watch for

Django 6.1 adds two ORM changes with a shared goal: let the database do useful work without making the application opaque. Fetch modes change what happens when a field is loaded on demand. DB_CASCADE moves a cascade delete from Python to an SQL constraint. Both can remove a great deal of work, but enabling them without examining their side effects is risky. The Django 6.1 release notes frame these APIs as optimizations. In practice, they change where the work happens. That is the key point to understand before upgrading. ...

August 8, 2026 · 6 min · Anthony
Django 6.1 fetch modes and DB_CASCADE: what to watch for

Django select_related() vs prefetch_related(): SQL Explained

Django select_related() or prefetch_related()? Both methods eliminate N+1 queries in Django, but they produce very different SQL. The first adds a join to the main query. The second runs multiple queries, then connects the objects in Python. The right choice depends less on data volume than on the type of relationship being traversed. To understand why, let’s start with a deliberately simple model: python from django.conf import settings from django.db import models class Post(models.Model): title = models.CharField(max_length=200) author = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="posts", ) tags = models.ManyToManyField("Tag", related_name="posts") class Comment(models.Model): post = models.ForeignKey( Post, on_delete=models.CASCADE, related_name="comments", ) body = models.TextField() is_public = models.BooleanField(default=True) author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) class Tag(models.Model): name = models.CharField(max_length=50) From a Post, author refers to at most one user. By contrast, comments and tags can contain multiple objects. This difference in cardinality almost always determines which method to use. ...

July 20, 2026 · 8 min · Anthony
Django select_related() vs prefetch_related(): SQL explained

GitOps Without Kubernetes: Django with doco-cd, SOPS and age

GitOps is almost always presented with Kubernetes in the background: ArgoCD, Flux, manifests by the hundreds. As a result, many teams deploying on a plain VPS with Docker Compose assume the model does not apply to them. They keep deploying over SSH: git pull, docker compose up -d, crossing their fingers that nobody skips a step. That is a shame, because the core of GitOps has nothing to do with Kubernetes. And for some time now, one tool has been filling exactly this gap: doco-cd, a continuous deployment engine for Docker Compose. Combined with SOPS and age to encrypt secrets directly in the repo, you get GitOps without Kubernetes: a complete pipeline where deploying boils down to git push. This article explains the principle, then walks through the setup on a Django project with several compose files. ...

June 29, 2026 · 10 min · Anthony
GitOps Without Kubernetes: Django with doco-cd, SOPS and age

TDD: Red-Green-Refactor, Baby Steps, and the FIRST Principles

TDD draws two extreme reactions. The first: “I already write tests, so I do TDD.” The second: “writing tests first just reverses the effort without buying much.” Both miss what TDD really is. It is neither a coverage question nor a simple ordering trick. It is a design discipline that forces you to make an intention explicit before writing the code that satisfies it. This article opens a series on TDD. Before comparing the schools (Chicago, London, ATDD double loop, strict TDD), the shared trunk has to be laid down: the Red-Green-Refactor cycle, the practice of baby steps, and the FIRST properties that define a test that deserves the name. The next articles will build on this foundation to make the trade-offs tangible with concrete examples. ...

June 8, 2026 · 8 min · Anthony
TDD: Red-Green-Refactor, Baby Steps, and the FIRST Principles

CQRS in Django: a denormalized read model without Event Sourcing

The four previous articles in the series laid the building blocks for a distributed system to stay consistent: Saga to orchestrate workflows, Outbox to publish reliable events, Inbox to consume them without duplicates, Idempotency Keys to protect the API. One question is left: what do you do with events once they are published? The most common answer: you use them to build read views. That is exactly what the CQRS pattern (Command Query Responsibility Segregation) proposes: separate the write model from the read model when both diverge enough that forcing them into a single structure costs more than splitting them. ...

June 5, 2026 · 7 min · Anthony
CQRS in Django: a denormalized read model without Event Sourcing

Idempotency Keys: stopping a client from paying twice

The previous two articles tackled idempotency on the event side: the Outbox pattern guarantees a message is published at least once, and the Inbox pattern guarantees it is consumed only once. One last place where the same problem shows up sits further upstream: the HTTP API itself. When a client fires a POST /api/payments and the connection drops before the response comes back, the client has no way to know whether the payment was created. If it retries, it risks paying twice. If it does not retry, it risks not paying at all. The Idempotency Key pattern, popularized by Stripe and adopted since by most payment APIs, solves that dilemma by putting retry control in the client’s hands. ...

June 4, 2026 · 7 min · Anthony
Idempotency Keys: stopping a client from paying twice

Newsletter

Get new articles delivered straight to your inbox.