|$ curl https://forge-ai.dev/api/markdown?path=docs/architecture/best-practices
$cat docs/architecture-&-sdlc-best-practices.md
updated Today·22-30 min read·published

Architecture & SDLC Best Practices

ArchitectureBest PracticesADRIntermediate🎯Free Tools
Introduction

Best practices here are habits that keep architecture honest under change: write decisions down, draw only useful diagrams, evolve with feedback, enforce rules with tests, and keep documentation close to code. They complement pattern pages — practices make patterns survivable.

Architecture Decision Records (ADRs)

An ADR captures a single significant decision: context, options, choice, consequences. Store ADRs in the repo (docs/adr/) so they version with code.

  • Write when the decision is costly to reverse, contested, or constrains others.
  • Include at least two alternatives — a decision without alternatives is a decree.
  • Link requirement IDs that justified the choice.
  • Mark status: Proposed, Accepted, Deprecated, Superseded.
  • Supersede instead of silently editing history when choices change.
ADR-0007-modular-monolith.md
Markdown
1# ADR-0007: Modular monolith first
2
3## Status
4Accepted
5
6## Context
7Team of 8; domain boundaries still moving; Must: weekly releases (NFR-12).
8
9## Options
101. Microservices by team 2. Modular monolith 3. Classic layered big ball
11
12## Decision
13Modular monolith with package boundaries + dependency cruiser in CI.
14
15## Consequences
16+ Fast iteration, simple txs
17- Must revisit if independent deploy becomes Must
18See revisit triggers in ADR-0007 appendix.

best practice

Keep ADRs short enough to read in five minutes. Link out to spikes/C4 for detail.
C4 Diagrams

The C4 model offers zoom levels: Context (system in environment), Container (deployables/data stores), Component (inside a container), Code (optional). Most teams need Context + Container living docs; Component for complex containers; Code rarely as permanent docs.

LevelAudienceRefresh when
ContextEveryoneActors/systems change
ContainerEng + opsDeployables/stores change
ComponentTeam owning containerModule structure changes
CodeImplementersPrefer generated views

Prefer diagrams-as-code (Structurizr, Mermaid) near the repo. A stale PNG in a wiki is worse than no diagram — it lies confidently.

Evolutionary Architecture

Evolutionary architecture assumes change: make decisions reversible where possible, protect fitness with automated checks, and migrate incrementally (strangler) instead of big-bang rewrites.

  • Delay irreversible choices until evidence exists.
  • Prefer modularity before distribution.
  • Define fitness functions for critical architectural characteristics.
  • Budget continuous refactoring — evolution is not free.
Fitness Functions

A fitness function is an automated check that the architecture still has a desired characteristic: dependency rules, latency budgets, security baselines, schema compatibility.

CharacteristicExample fitness check
ModularityDependency cruiser / ArchUnit fails on illegal imports
Performancek6 budget in CI for critical API
SecuritySAST + dependency CVE gate
OperabilityService must expose /health and metrics endpoint
CompatibilityContract tests between provider/consumer
ci-architecture-gates.sh
Bash
1npx depcruise --validate .dependency-cruiser.js src
2npm run test:contract
3npm run test:perf:budget
4# fail build on violations
🔥

pro tip

Put fitness functions in the Definition of Done so architecture does not rot between "big redesigns."
Documentation Practices
  • Docs that ship with PRs beat wiki novels.
  • README per module: purpose, public API, ownership, runbook links.
  • OpenAPI/AsyncAPI as living contracts.
  • Runbooks for on-call next to services.
  • Keep a glossary for ubiquitous language (DDD).
SDLC Practices Checklist
sdlc-best-practices.txt
TEXT
1[ ] Requirements: FR + measurable NFRs + AC
2[ ] Design: ADRs for significant choices; C4 updated
3[ ] Implementation: small batches; reviews; flags
4[ ] Testing: risk-based pyramid + contracts
5[ ] Deployment: automated, progressive, rollback known
6[ ] Maintenance: SLOs, postmortems → backlog
7[ ] Process: WIP limited; DoD enforced; feedback real
Security as Architecture

Threat model early; define trust boundaries on C4 Container diagrams; make authn/z a cross-cutting architectural concern with clear ownership. Security fitness functions belong in CI — not only annual audits.

Master Checklist
architecture-craft-checklist.txt
TEXT
1[ ] Drivers (requirements) written before pattern choice
2[ ] ADR accepted with alternatives
3[ ] C4 Context + Container current
4[ ] Fitness functions in CI for critical rules
5[ ] Evolution/revisit triggers listed
6[ ] Team topology aligned with boundaries
7[ ] Observability standards applied
8[ ] Rollback / migration strategy exists
9[ ] Docs updated in the same PR as structural change
Architecture Reviews

Lightweight reviews beat ceremonial boards that become bottlenecks. A practical pattern: author drafts ADR + C4 delta; two peers review within 48 hours; record decision; fitness checks enforce ongoing compliance. Escalate only irreversible, cross-team, or high-risk security decisions to a wider group.

  • Review for requirement alignment first — not personal taste.
  • Ask "what happens if we are wrong?" and require a rollback/migration story.
  • Check team topology impact (who gets paged? who can deploy?).
  • Reject speculative complexity without Must drivers.
Working with Quality Attributes

Pick the top 3–5 quality attributes for the system this quarter. Make them visible on the team board. Attach fitness functions and SLOs. Revisit quarterly — architecture focus should track product strategy.

AttributePractice
PerformanceBudgets in CI; flamegraphs on regressions
SecurityThreat model per major feature; scan gates
EvolvabilityDependency rules; ADR revisit triggers
ReliabilitySLO, error budgets, game days
Anti-Practices
  • Architecture powerpoint with no ADRs and no code impact.
  • Updating C4 once a year "for compliance" while systems diverge.
  • Fitness functions that everyone ignores (skipped CI jobs).
  • Separate architecture team that never ships — advice without feedback.
  • Documenting everything except the decisions that matter.
📝

note

Return to Choosing when practices reveal that the original style no longer fits measured reality.
Notes for AI Agents

When proposing architecture, always emit: (1) restated requirements, (2) options ≥ 3, (3) recommendation, (4) risks, (5) fitness checks to add, (6) ADR draft. Refuse to recommend microservices or event sourcing without explicit drivers in the user problem statement.

Delivery Hygiene

Architecture practices fail when delivery is chaotic. Keep batches small, protect mainline, automate releases, and make rollbacks boring. Pair ADRs with feature flags when releasing structural change gradually.

  • Trunk-based or short-lived branches with mandatory CI.
  • Migrations expand/contract compatible.
  • Observability for new paths before traffic increases.
  • Post-deploy verification scripts as part of the pipeline.
Starter Template Pack
starter-pack.txt
TEXT
1docs/adr/0000-template.md
2docs/c4/context.md
3docs/c4/container.md
4docs/quality-attributes.md
5.dependency-cruiser.js (or ArchUnit)
6CODEOWNERS
7runbooks/README.md

info

Use Mastery checkpoints to verify humans and agents can produce these artifacts.

Community

Get help on Slack, Discord or VIP

Stuck on a guide? Join the community and ask.