Phase 4
Architecture
How components communicate and how to structure systems at scale.
Pause & reflect
Before you read on, answer this in your head — or on paper:
Two services need to talk. One does user auth, the other sends emails.
Synchronous or asynchronous? What if the email service is slow or down? What happens to the user request?
Start with a monolith. Split when teams block each other, deploy cycles slow down, or scaling needs differ per component. Microservices solve organizational problems; if you don't have them, you may not need microservices.
When to split
Split by business capability, not technical layer. Each service owns its data (database per service). Loose coupling, high cohesion. Model around the business domain. Fail fast with circuit breakers. Keep APIs backward compatible.
Distributed monolith
Looks like microservices but tightly coupled: low-latency sync calls, shared databases, services that don't scale independently. Loses microservice benefits. Avoid shared resources and rigid protocols.
N-tier Architecture
Presentation → Business logic → Data. Layers separate responsibilities; tiers are physical. 3-tier: web, app, DB. Closed-layer: a layer only calls the next down. Open-layer: can skip tiers. Improves availability and security; adds network latency and complexity.