The Four Phases
You MUST complete each phase before proceeding to the next.
Phase 1: Constraints & Trade-offs (The "No")
BEFORE designing the system:
Identify Non-Functional Requirements (NFRs)
- Scalability: 1k users or 10M users?
- Latency: Real-time (Gaming) or Batch (Reporting)?
- Compliance: HIPAA? GDPR? PCI-DSS?
- Rule: These constraints dictate the tech stack, not your personal preference.
The "Buy vs. Build" Decision
- Should we build a Chat system or use Stream.io?
- Should we build Auth or use Auth0?
- Rule: Only build your "Core Differentiator." Buy everything else.
Define the Boundaries
- Where does the Mobile App end and the Backend begin?
- Monolith or Microservices? (Hint: Start with Monolith).
- Output: A high-level context diagram showing system interactions.
Phase 1.5: Modern Architecture Patterns (2026)
Emerging patterns that change the game:
Edge Compute Strategies
- Cloudflare Workers / Vercel Edge: Run code closest to users (sub-50ms latency)
- Use Cases: A/B testing, personalization, auth checks, rate limiting
- Trade-off: Limited runtime (no filesystem, max 50ms CPU time)
- When: Global apps needing <100ms response times
WebAssembly (WASM) Backends
- Compile Rust/Go to WASM: Run in serverless with near-native performance
- Benefits: 10x faster cold starts vs containers, tiny bundles
- Tools: wasmtime, Spin (Fermyon), WASI
- When: CPU-intensive serverless functions (image processing, crypto)
Local-First Architecture
- CRDTs: Conflict-free Replicated Data Types (eventual consistency)
- Offline-First: App works without network, syncs when available
- Tools: Replicache, Electric SQL, PowerSync
- When: Collaborative apps (Figma, Notion patterns)
AI Integration Points
- Where to embed LLMs: Content generation, search, recommendations
- Vector Databases: pgvector (Postgres), Pinecone, Weaviate
- Cost Management: Cache embeddings, batch requests, use smaller models
- Latency: Stream responses (SSE/WebSockets), don't block UI
Phase 2: Technical Consensus
Aligning the experts:
Write the RFC (Request for Comments)
- Don't dictate. Write a design doc proposing the solution.
- List "Alternatives Considered" and why they were rejected.
- Review: Get sign-off from the Lead Backend, Lead Mobile, and DevOps.
Data Flow & Consistency
- Source of Truth: Which database owns the "User Profile"?
- Consistency Model: Strong (Banking) or Eventual (Social Feed)?
- Data Gravity: Don't move massive data to the compute; move compute to the data.
Failure Mode Analysis
- "What happens if the Payment Gateway is down?"
- "What happens if the Redis Cache is flushed?"
- Design for resilience, not perfection.
Phase 2.5: Observability-Driven Development
Build systems you can actually debug:
Think in Traces, Not Logs
- OpenTelemetry Standard: Unified traces, metrics, logs
- Trace ID Propagation: Follow a request across 10 microservices
- Span Attributes: Enrich with context (user_id, feature_flag, A/B test)
- Tools: Jaeger, Tempo, Honeycomb, Datadog APM
Structured Events Over Text Logs
{
"trace_id": "abc123",
"span_id": "xyz789",
"service": "payment-api",
"event": "charge_created",
"user_id": 42,
"amount_cents": 1999,
"duration_ms": 234
}
- Benefits: Query like a database, not grep
- Anti-Pattern:
"User 42 charged $19.99 in 234ms" (unparseable)
Define SLOs Before SLAs
- SLO: Internal target (99.9% = 43min downtime/month)
- SLA: External commitment to customers
- Error Budgets: If SLO is 99.9%, you have 0.1% to "spend" on deploys/experiments
- Rule: If you burn 50% of error budget, freeze risky changes
Phase 3: Governance & Standards
Setting the rules of the road:
Tech Radar
- Adopt: TypeScript, Terraform, Postgres. (Safe to use).
- Trial: Go, Rust. (Use with caution/permission).
- Hold: MongoDB, PHP. (Do not use for new services).
Standardize Interfaces
- "All APIs must return standard HTTP error codes."
- "All logs must be JSON."
- "All services must expose a /metrics endpoint."
- "MANDATORY: All code changes must undergo a deep-dive 'fine-toothed comb' review before git deployment."
Cost Governance
- Review the architecture for hidden costs (e.g., Cross-AZ data transfer).
- Set the budget ceiling per active user.
Phase 4: Evolution & Modernization
Managing the rot:
Tech Debt Management
- Treat debt like a financial loan. Pay interest (refactoring) regularly.
- Identify "Load Bearing" legacy code that needs replacement.
The Strangler Fig Pattern
- Don't rewrite the old system from scratch (The "Big Bang" fails).
- Build new features on the new stack and slowly route traffic away from the old one.
Mentorship
- Your job is to make Senior Engineers into Architects.
- Explain why you made a decision, don't just give orders.
Red Flags - STOP and Follow Process
If you catch yourself thinking:
- "Let's use Kubernetes because Google uses it." (You are not Google).
- "Microservices will solve our spaghetti code." (Now you have distributed spaghetti).
- "I don't need to write this down, it's in my head." (Bus factor risk).
- "We'll figure out how to migrate the data later." (Data gravity is real).
- "I'll let every team choose their own language." (Operational nightmare).
- Pushing to deployment without a 'fine-toothed comb' code review.
ALL of these mean: STOP. Return to Phase 1.
Quick Reference
| Phase |
Key Activities |
Success Criteria |
| 1. Constraints |
Buy vs Build, NFRs |
Tech stack aligned with Biz |
| 2. Consensus |
RFCs, Design Review |
Team buy-in, clear boundaries |
| 3. Governance |
Tech Radar, Standards |
Consistent ecosystem |
| 4. Evolution |
Refactoring, Mentoring |
System survives > 5 years |
📐 Architecture Decision Record (ADR) Template
Use this for every significant technical decision:
# ADR-###: [Title]
**Status:** Proposed | Accepted | Deprecated | Superseded
**Date:** 2026-01-29
**Deciders:** [Names]
## Context
What forces are at play? Business constraints, technical debt, team skillsets.
## Decision
We will [decision]. We chose [option A] over [option B].
## Consequences
### Positive
- What becomes easier?
- What performance/cost benefits?
### Negative
- What becomes harder?
- What new risks?
### Neutral
- What stays the same?
## Alternatives Considered
| Option | Pros | Cons | Why Rejected |
|--------|------|------|---------------|
| Option A (chosen) | ... | ... | N/A |
| Option B | ... | ... | ... |
| Option C | ... | ... | ... |
## References
- [Link to RFC]
- [Link to prototype]
🛠️ Modern Architecture Stack (2026)
Compute Patterns
- Serverless: AWS Lambda, Cloud Run, Cloudflare Workers
- Containers: ECS/Fargate, Cloud Run, Fly.io
- Edge: Cloudflare Workers, Vercel Edge, Fastly Compute
- WASM: Spin (Fermyon), wasmCloud
Data Patterns
- OLTP: Postgres 17, Neon (serverless), Supabase
- OLAP: ClickHouse, BigQuery, DuckDB
- Caching: Redis 7, Valkey, Dragonfly
- Vector: pgvector, Pinecone, Weaviate
- Local-First: Replicache, ElectricSQL, PowerSync
Observability
- Standard: OpenTelemetry
- APM: Datadog, New Relic, Honeycomb
- Logs: Grafana Loki, CloudWatch, Mezmo
- Metrics: Prometheus, Grafana, Datadog
Cost Optimization
- FinOps: Spot instances, reserved capacity
- Auto-scaling: KEDA, AWS Auto Scaling
- Budget Alerts: CloudWatch billing, Infracost
1---2name: principal-engineer3description: Principal Engineer Skill4---5## The Four Phases67You MUST complete each phase before proceeding to the next.89### Phase 1: Constraints & Trade-offs (The "No")1011**BEFORE designing the system:**12131. **Identify Non-Functional Requirements (NFRs)**14 - Scalability: 1k users or 10M users?15 - Latency: Real-time (Gaming) or Batch (Reporting)?16 - Compliance: HIPAA? GDPR? PCI-DSS?17 - **Rule:** These constraints dictate the tech stack, not your personal preference.18192. **The "Buy vs. Build" Decision**20 - Should we build a Chat system or use Stream.io?21 - Should we build Auth or use Auth0?22 - **Rule:** Only build your "Core Differentiator." Buy everything else.23243. **Define the Boundaries**25 - Where does the Mobile App end and the Backend begin?26 - Monolith or Microservices? (Hint: Start with Monolith).27 - **Output:** A high-level context diagram showing system interactions.2829### Phase 1.5: Modern Architecture Patterns (2026)3031**Emerging patterns that change the game:**32331. **Edge Compute Strategies**34 - **Cloudflare Workers / Vercel Edge:** Run code closest to users (sub-50ms latency)35 - **Use Cases:** A/B testing, personalization, auth checks, rate limiting36 - **Trade-off:** Limited runtime (no filesystem, max 50ms CPU time)37 - **When:** Global apps needing <100ms response times38392. **WebAssembly (WASM) Backends**40 - **Compile Rust/Go to WASM:** Run in serverless with near-native performance41 - **Benefits:** 10x faster cold starts vs containers, tiny bundles42 - **Tools:** wasmtime, Spin (Fermyon), WASI43 - **When:** CPU-intensive serverless functions (image processing, crypto)44453. **Local-First Architecture**46 - **CRDTs:** Conflict-free Replicated Data Types (eventual consistency)47 - **Offline-First:** App works without network, syncs when available48 - **Tools:** Replicache, Electric SQL, PowerSync49 - **When:** Collaborative apps (Figma, Notion patterns)50514. **AI Integration Points**52 - **Where to embed LLMs:** Content generation, search, recommendations53 - **Vector Databases:** pgvector (Postgres), Pinecone, Weaviate54 - **Cost Management:** Cache embeddings, batch requests, use smaller models55 - **Latency:** Stream responses (SSE/WebSockets), don't block UI5657### Phase 2: Technical Consensus5859**Aligning the experts:**60611. **Write the RFC (Request for Comments)**62 - Don't dictate. Write a design doc proposing the solution.63 - List "Alternatives Considered" and why they were rejected.64 - **Review:** Get sign-off from the Lead Backend, Lead Mobile, and DevOps.65662. **Data Flow & Consistency**67 - **Source of Truth:** Which database owns the "User Profile"?68 - **Consistency Model:** Strong (Banking) or Eventual (Social Feed)?69 - **Data Gravity:** Don't move massive data to the compute; move compute to the data.70713. **Failure Mode Analysis**72 - "What happens if the Payment Gateway is down?"73 - "What happens if the Redis Cache is flushed?"74 - Design for resilience, not perfection.7576### Phase 2.5: Observability-Driven Development7778**Build systems you can actually debug:**79801. **Think in Traces, Not Logs**81 - **OpenTelemetry Standard:** Unified traces, metrics, logs82 - **Trace ID Propagation:** Follow a request across 10 microservices83 - **Span Attributes:** Enrich with context (user_id, feature_flag, A/B test)84 - **Tools:** Jaeger, Tempo, Honeycomb, Datadog APM85862. **Structured Events Over Text Logs**87 ```json88 {89 "trace_id": "abc123",90 "span_id": "xyz789",91 "service": "payment-api",92 "event": "charge_created",93 "user_id": 42,94 "amount_cents": 1999,95 "duration_ms": 23496 }97 ```98 - **Benefits:** Query like a database, not grep99 - **Anti-Pattern:** `"User 42 charged $19.99 in 234ms"` (unparseable)1001013. **Define SLOs Before SLAs**102 - **SLO:** Internal target (99.9% = 43min downtime/month)103 - **SLA:** External commitment to customers104 - **Error Budgets:** If SLO is 99.9%, you have 0.1% to "spend" on deploys/experiments105 - **Rule:** If you burn 50% of error budget, freeze risky changes106107### Phase 3: Governance & Standards108109**Setting the rules of the road:**1101111. **Tech Radar**112 - **Adopt:** TypeScript, Terraform, Postgres. (Safe to use).113 - **Trial:** Go, Rust. (Use with caution/permission).114 - **Hold:** MongoDB, PHP. (Do not use for new services).1151162. **Standardize Interfaces**117 - "All APIs must return standard HTTP error codes."118 - "All logs must be JSON."119 - "All services must expose a /metrics endpoint."120 - "MANDATORY: All code changes must undergo a deep-dive 'fine-toothed comb' review before git deployment."1211223. **Cost Governance**123 - Review the architecture for hidden costs (e.g., Cross-AZ data transfer).124 - Set the budget ceiling per active user.125126### Phase 4: Evolution & Modernization127128**Managing the rot:**1291301. **Tech Debt Management**131 - Treat debt like a financial loan. Pay interest (refactoring) regularly.132 - Identify "Load Bearing" legacy code that needs replacement.1331342. **The Strangler Fig Pattern**135 - Don't rewrite the old system from scratch (The "Big Bang" fails).136 - Build new features on the new stack and slowly route traffic away from the old one.1371383. **Mentorship**139 - Your job is to make Senior Engineers into Architects.140 - Explain *why* you made a decision, don't just give orders.141142## Red Flags - STOP and Follow Process143144If you catch yourself thinking:145- "Let's use Kubernetes because Google uses it." (You are not Google).146- "Microservices will solve our spaghetti code." (Now you have distributed spaghetti).147- "I don't need to write this down, it's in my head." (Bus factor risk).148- "We'll figure out how to migrate the data later." (Data gravity is real).149- "I'll let every team choose their own language." (Operational nightmare).150- **Pushing to deployment without a 'fine-toothed comb' code review.**151152**ALL of these mean: STOP. Return to Phase 1.**153154## Quick Reference155156| Phase | Key Activities | Success Criteria |157|-------|---------------|------------------|158| **1. Constraints** | Buy vs Build, NFRs | Tech stack aligned with Biz |159| **2. Consensus** | RFCs, Design Review | Team buy-in, clear boundaries |160| **3. Governance** | Tech Radar, Standards | Consistent ecosystem |161| **4. Evolution** | Refactoring, Mentoring | System survives > 5 years |162163## 📐 Architecture Decision Record (ADR) Template164165Use this for every significant technical decision:166167```markdown168# ADR-###: [Title]169170**Status:** Proposed | Accepted | Deprecated | Superseded 171**Date:** 2026-01-29 172**Deciders:** [Names] 173174## Context175176What forces are at play? Business constraints, technical debt, team skillsets.177178## Decision179180We will [decision]. We chose [option A] over [option B].181182## Consequences183184### Positive185- What becomes easier?186- What performance/cost benefits?187188### Negative189- What becomes harder?190- What new risks?191192### Neutral193- What stays the same?194195## Alternatives Considered196197| Option | Pros | Cons | Why Rejected |198|--------|------|------|---------------|199| Option A (chosen) | ... | ... | N/A |200| Option B | ... | ... | ... |201| Option C | ... | ... | ... |202203## References204205- [Link to RFC]206- [Link to prototype]207```208209## 🛠️ Modern Architecture Stack (2026)210211### Compute Patterns212- **Serverless:** AWS Lambda, Cloud Run, Cloudflare Workers213- **Containers:** ECS/Fargate, Cloud Run, Fly.io214- **Edge:** Cloudflare Workers, Vercel Edge, Fastly Compute215- **WASM:** Spin (Fermyon), wasmCloud216217### Data Patterns218- **OLTP:** Postgres 17, Neon (serverless), Supabase219- **OLAP:** ClickHouse, BigQuery, DuckDB220- **Caching:** Redis 7, Valkey, Dragonfly221- **Vector:** pgvector, Pinecone, Weaviate222- **Local-First:** Replicache, ElectricSQL, PowerSync223224### Observability225- **Standard:** OpenTelemetry226- **APM:** Datadog, New Relic, Honeycomb227- **Logs:** Grafana Loki, CloudWatch, Mezmo228- **Metrics:** Prometheus, Grafana, Datadog229230### Cost Optimization231- **FinOps:** Spot instances, reserved capacity232- **Auto-scaling:** KEDA, AWS Auto Scaling233- **Budget Alerts:** CloudWatch billing, Infracost