Collapse/expand UI with Stimulus that survives Turbo swaps

Simple disclosure components are everywhere: FAQ, details panels, advanced filters. I keep them as progressive enhancement: the HTML is valid and readable, and Stimulus adds toggling behavior. The controller toggles a hidden class and updates aria-exp

Speed up perceived performance with Turbo preload links

Turbo can preload pages on hover (or on touchstart) which makes navigation feel instantaneous. I use data-turbo-preload on links that are likely to be clicked (like list item titles). The server still controls caching and ETags, so it remains safe and

Django REST Framework permissions and authorization

DRF permissions control access to API endpoints. I use built-in permissions like IsAuthenticated, IsAdminUser, or IsAuthenticatedOrReadOnly. For custom logic, I create permission classes implementing has_permission() and has_object_permission(). I com

Cache-Friendly “Top N” with Materialized View Refresh

If you have a “top list” that’s expensive to compute, a materialized view is a clean approach. Refresh concurrently on a schedule to keep reads fast without blocking.

Turbo Frames: “details” panel that lazy-loads on click

For pages with expensive secondary data (audit trail, related entities), keep initial render fast and lazy-load a details frame only when the user asks. This is a clean performance pattern for admin pages.

Next.js bundle analyzer for targeted performance work

Performance work is hard when you’re guessing what’s in your bundle. The bundle analyzer turns it into a visual diff: you can see which dependencies are big and whether code splitting is working. I gate it behind an env var like ANALYZE=true so it’s o

Django model save override for custom logic

Overriding the save() method allows custom behavior before or after saving. I call super().save() to preserve default behavior. Common use cases include auto-generating slugs, updating related objects, or validating business rules. I use created check

Background Job Dead Letter Queue (DLQ) Table

Retries can become infinite noise. For certain failure classes, record the payload + error in a DLQ table and alert/triage. This keeps queues healthy and makes failures actionable.

Response compression (only when it helps)

Compression can dramatically reduce payload sizes for JSON and HTML, but it also costs CPU. I enable it with sane defaults and avoid compressing already-compressed content (like images). Compression can also hurt streaming responses and SSE, so I disa

N+1 Proof Serialization with preloaded associations

When rendering JSON, the serializer layer can silently trigger extra queries. Force “preload then serialize” so your JSON rendering path is deterministic. This pattern scales well in Rails APIs.

Safe Raw SQL with exec_query + Binds

Sometimes raw SQL is the cleanest approach—just keep it safe. Use exec_query with bind params instead of interpolating values. You get both safety and correctness with types.

Action Text comment form that works inside a Turbo Frame

Action Text is great, but you need to be deliberate about how you render it in a Turbo-powered UI. I keep the comment form inside a turbo_frame_tag so it can be replaced on validation errors (still 422). On success, I clear the form by replacing the f