›bobbyencoded_
/posts/newsletter/courses/about
/posts/newsletter/courses/about

The Decode

The week's AI & software news, decoded.

Subscribe →

// © 2026 BobbyEncoded Inc. — A Canadian corporation

← Back to Blog

Architecture Patterns in Practice

The Architecture Patterns Worth Knowing in 2026, Plus the AI Ones

November 4, 2026 · 12 min read

Software Architecture, Design Patterns, Distributed Systems, AI, App Development

Pattern lists usually come sorted by seniority: learn these first, those later. I find it more useful to sort them by the question they answer. Nobody reaches for a circuit breaker because they're now "mid-level". They reach for it because a dependency started failing and took their app down with it.

So here's my map: five questions every system eventually asks, the patterns that answer each one, and when each is worth its cost. Then a bonus section on the patterns AI features add, because if you build full stack in 2026, there's a good chance an LLM sits somewhere in your request path.

This is a map, not a deep dive. Every pattern here gets a full post with runnable C# and Python in one of two series. The Pattern Map covers the Gang of Four and the cloud patterns (resilience, messaging, caching, strangler fig, sidecar). Architecture Patterns in Practice covers the rest, one group per post:

  1. Organizing the code: modular monolith, layered and clean, vertical slice
  2. Screen and app architecture: MVVM, unidirectional data flow, offline-first
  3. How services talk: API gateway, BFF, pub/sub, event-driven, rate limiting
  4. Data at scale: CQRS, read replicas, sharding
  5. Changing live systems: anti-corruption layer, expand and contract, feature flags
  6. AI: reliable output: structured output, RAG, context engineering, evals
  7. AI: workflows and agents: chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer, agent loop
  8. AI in production: MCP, model gateway, guardrails, human in the loop, caching, streaming, durable execution

1. How is the code organized?

This is the first question and the one that's most expensive to get wrong late.

PatternWhat it isReach for it when
MonolithOne deployable unitAlmost always, to start. Martin Fowler's "monolith first" advice still holds
Modular monolithOne deployable, strict internal module boundariesThe codebase grows and teams start stepping on each other, but you don't want a network between them yet
Layered / Clean architectureUI, business logic and data access separated, dependencies pointing inwardBusiness rules need to outlive the framework or the database
Vertical sliceOrganize by feature (one folder per use case) instead of by layerMost changes touch one feature end to end, and layers make you edit five folders
Client-server / request-responseA client asks, a server answersThe default for nearly everything; know it well before you leave it

For app developers, three more belong here:

PatternWhat it isReach for it when
MVVMA view model holds screen state; the view just renders itAny non-trivial screen in SwiftUI, Jetpack Compose or .NET MAUI
Unidirectional data flowState flows down, events flow up, one source of truthScreens with lots of interacting state. It's the default shape of modern declarative UI, and Android's own architecture guide recommends it
Offline-first / local-firstThe app reads and writes a local store and syncs in the backgroundMobile apps on unreliable networks, which is all of them

My rule of thumb: a well-structured monolith beats a badly split set of services every time. The modular monolith is the pattern I wish more teams tried before microservices.

2. How do the parts talk to each other?

PatternWhat it isReach for it when
API gatewayOne front door for many servicesClients shouldn't know your internal topology
Backend for Frontend (BFF)One small backend per client type (iOS, Android, web)Clients need very different shapes of the same data
Publish/subscribePublishers emit events; any number of subscribers reactOne thing happening should trigger several independent reactions
Point-to-point queueOne message, one consumerWork must be done exactly by one worker, at its own pace
Event-driven architectureServices react to facts ("OrderPlaced") instead of calling each otherYou want services to change independently. Costs you: harder debugging and eventual consistency

The trade here is always the same: synchronous calls are simple and couple services together in time; messages decouple them and make the system harder to follow. Pick deliberately.

3. How does it survive failure?

Every network call will eventually fail. These patterns decide whether that failure stays small.

PatternWhat it isReach for it when
TimeoutGive up after a deadlineAlways. A call without a timeout can hang a whole thread pool
Retry with backoff and jitterTry again, waiting longer each time, with randomnessTransient failures. The jitter stops every client retrying at the same instant
Circuit breakerStop calling a dependency that keeps failing, try again laterA failing dependency would otherwise drag you down with it
BulkheadSeparate resource pools, so one leak can't sink everythingOne slow dependency shouldn't starve the others
Rate limitingCap how fast callers can hit youProtecting your service (and your bill) from bursts and abuse
IdempotencyThe same request twice has the same effect as onceAnything retried, which, given the row above, is everything that writes

If you learn only one row, learn the last one. Retries without idempotency turn "the network blipped" into "we charged the customer twice."

4. How does data stay correct and fast?

PatternWhat it isReach for it when
Cache-asideRead from cache; on a miss, load from the database and fill the cacheRead-heavy data that can be slightly stale
Read replicasCopies of the database that serve readsReads vastly outnumber writes
CQRSSeparate models for writing and for readingReads and writes have very different shapes or scale. Overkill for plain CRUD
Transactional outboxSave the data and the "event to publish" in one transaction; publish afterYou must update a database and send a message, and can't lose either
SagaA long transaction as steps, each with a compensating undoA business process spans several services with no shared transaction
Event sourcingStore every change as an event; rebuild state from themYou need a full audit history or time travel. High cost; use sparingly
ShardingSplit data across databases by a keyOne database can no longer hold or serve it all. Late, and hard to undo

Each of these has a deep dive with runnable C# and Python:

  • Caching: Part 1, every caching strategy and when to use which and Part 2, frontend or backend, every layer
  • CQRS and read replicas: Data at scale
  • Transactional outbox: dual writes, relays, inboxes and ordering
  • Saga: pivots, compensations, isolation and the failure modes nobody draws, plus saga orchestration and sagas with Durable Functions
  • Event sourcing: the deep dive (event store, projections, snapshots, versioning), plus the 2025 series starting with the honest truth
  • Sharding: shard keys, consistent hashing, resharding and hot partitions

Notice how far down the list sharding and event sourcing are. Both are powerful and both are hard to walk back, so they belong at the end of the road, not the start.

5. How do you change it without breaking it?

The patterns people learn last and need most, because real systems are never built from scratch.

PatternWhat it isReach for it when
Strangler figPut a router in front of the old system and move features to the new one piece by pieceReplacing a legacy system without a big-bang rewrite
Anti-corruption layerA translation layer so a legacy model doesn't leak into new codeIntegrating with a system whose concepts you don't want to inherit
Expand and contractAdd the new shape, migrate, then remove the old shapeDatabase and API changes that must not break running clients. Essential for mobile, where old app versions live for months
Feature flagsShip code dark, turn it on separatelyDecoupling deploy from release; gradual rollouts
SidecarA helper process beside the app adds behaviour (proxying, telemetry)Cross-cutting concerns you don't want in every codebase

When not to use a pattern

Every pattern in this post costs something: more moving parts, more to learn, more ways to fail. The question isn't "is this a good pattern?" but "is the problem it solves one I actually have?" CQRS on a to-do app, microservices for a team of three and event sourcing for a settings screen all sound reasonable in a design meeting and cost far more than they return. Knowing a pattern includes knowing when it's the wrong answer.

Bonus: the patterns AI adds for full-stack developers

If you put an LLM behind a feature, a new set of patterns shows up. Most are old ideas in new clothes: a tool call is a Command, a model router is a Strategy, a guardrail pipeline is a Chain of Responsibility. Here's the map I'm working from as I learn this space.

Getting reliable output

PatternWhat it isOld idea underneath
Structured outputConstrain the model to a JSON schema instead of parsing free textA typed contract at the boundary
Retrieval-augmented generation (RAG)Fetch relevant documents and put them in the promptA cache-aside for knowledge the model doesn't have
Context engineeringDeliberately choose what goes into the context window (instructions, tools, history, retrieved data)Managing a scarce resource, like memory
EvalsAutomated test sets that score model outputUnit and regression tests for non-deterministic code

Workflows and agents

Anthropic's "Building effective agents" names the workflow patterns most teams end up using. Learn these names; they're becoming the shared vocabulary.

PatternWhat it is
Prompt chainingSplit a task into fixed steps, each model call feeding the next
RoutingClassify the input, then send it to a specialised prompt or model
ParallelizationRun subtasks at once, or the same task several times and vote
Orchestrator-workersOne model breaks the task down and delegates to workers
Evaluator-optimizerOne model generates, another critiques, loop until good enough
Agent loopThe model picks tools in a loop until done. Always give it a stop condition and a budget

The advice I find most useful from that piece: start with the simplest pattern that works, and only reach for a full agent when a fixed workflow can't do the job. It's the AI version of "monolith first".

Running it in production

PatternWhat it isOld idea underneath
Tool calling via MCPExpose your app's actions to models through a standard protocolAdapter
Model gatewayOne place to route between models, with fallbacks, quotas and loggingAPI gateway + Strategy
GuardrailsChecks on input and output (injection, PII, policy) before and after the modelChain of Responsibility
Human in the loopAn agent proposes; a person approves anything destructive or expensiveApproval workflow
Prompt and semantic cachingReuse expensive context or answers to similar questionsCache-aside
Streaming responsesSend tokens to the UI as they're generatedServer-sent events, progressive rendering
Durable executionCheckpoint long agent runs so a crash resumes instead of restartingSaga + Memento

Look at the right-hand column again. The systems knowledge from the first five sections is exactly what makes the AI section manageable. Retries, idempotency, gateways and caches don't go away because a model is involved; agents make them matter more, because an agent will happily retry a tool call that charges a card.

Further reading

  • Microsoft, Cloud design patterns (the catalog most of sections 2–5 come from)
  • Martin Fowler, Monolith First, Strangler Fig Application, CQRS, Parallel Change (expand and contract)
  • Jimmy Bogard, Vertical Slice Architecture
  • Sam Newman, Backends for Frontends
  • Android Developers, Guide to app architecture
  • Ink & Switch, Local-first software
  • AWS Builders' Library, Timeouts, retries and backoff with jitter
  • Anthropic, Building effective agents and Effective context engineering for AI agents
  • Model Context Protocol
  • My earlier posts: Design patterns every developer should master and the patterns I keep coming back to
← Previous

Agents Broke OpenAI's Git Server. The Fix Was a Consistency Model.

Next →

More Code, Not More Software

Thoughts on this?

Tell me on X: @bobbyencoded · Share this post on X

Want more like this? Subscribe to The Decode, a weekly email on the AI and developer news worth your time.