Chapter 2 — Website Architecture Patterns

Before choosing where to host, you need to understand what you're hosting. The architecture pattern determines your infrastructure requirements.

Static Sites

Pre-built HTML/CSS/JS files served as-is. No server-side processing per request.

# Example: Build and deploy a Hugo static site
hugo build                          # Generates ./public/ directory
aws s3 sync ./public s3://my-bucket --delete
aws cloudfront create-invalidation --distribution-id EXXX --paths "/*"

Server-Side Rendering (SSR)

Server generates HTML on every request. The traditional model (PHP, Rails, Django, Express with templates).

Single-Page Applications (SPA)

One HTML file + JavaScript bundle. All rendering happens in the browser. Backend is a separate API.

JAMstack (JavaScript, APIs, Markup)

Pre-rendered static pages enhanced with JavaScript calling APIs at runtime. Best of both worlds.

Monolithic Architecture

Single deployable unit containing all functionality. Frontend, backend, and data access in one codebase.

Service-Oriented Architecture (SOA) / Microservices

Application split into independent services communicating over network (HTTP/gRPC/message queues).

Don't start with microservices. Start monolithic, split when you have clear bounded contexts and the team/traffic justifies the operational complexity. Premature microservices is the #1 architecture mistake in startups.

Comparison Table

PatternServer NeededScalabilityComplexitySEOBest For
StaticNo (CDN)★★★★★★☆☆☆☆★★★★★Content sites, docs
SSRYes★★★☆☆★★★☆☆★★★★★Dynamic content + SEO
SPAAPI only★★★★☆★★★☆☆★★☆☆☆App-like experiences
JAMstackPartial★★★★★★★★☆☆★★★★★Content + interactivity
MonolithYes★★★☆☆★★☆☆☆VariesMVPs, small-medium apps
MicroservicesYes (many)★★★★★★★★★★VariesLarge teams, high scale
How to choose:
• Content-heavy, rarely changes? → Static / JAMstack
• Need SEO + dynamic data? → SSR
• Rich interactive app (logged-in users)? → SPA + API
• Small team, getting started? → Monolith
• Large team, proven bounded contexts, high scale? → Microservices