Agent Wranglers

DOC-40Recommended

Keep one architecture overview with a context view and a container view

Keep one architecture overview page in the repository. It shows the system in its context, with its users and outside systems, and every deployable part with the data stores it owns.

How to do it

A new developer, an auditor and a coding agent all ask the same first question, which is what talks to what. Draw two views at most, a context view and a container view, as the C4 model names them. Code-level detail goes stale too fast to draw. Label every arrow with what it carries and how, such as "orders, HTTPS". Keep the diagrams as text, such as Structurizr DSL, Mermaid or PlantUML, as Draw diagrams as code says. They then change in the same pull request as the code. Update the views in the change that adds or removes a container or an outside system. List each part with its owner, its language and where it runs. Link the decision records behind the shape, as Link each decision record from the code it governs says. Link the page from the README section in Give the README a fixed set of sections.

Examples

JavaScript example

// Every deployable part is on the architecture page, and nothing extra
import { readFileSync, readdirSync } from 'node:fs';
const services = readdirSync('services', { withFileTypes: true }).filter(entry => entry.isDirectory()).map(entry => entry.name);
const overview = readFileSync('docs/architecture.md', 'utf8');
const missing = services.filter(name => !overview.includes(`\`${name}\``));
missing.forEach(name => console.log(`FAIL ${name} is not on the architecture page`));
process.exit(missing.length ? 1 : 0);

Python example

# The same check in Python
import pathlib, sys
services = [p.name for p in pathlib.Path("services").iterdir() if p.is_dir()]
overview = pathlib.Path("docs/architecture.md").read_text()
missing = [name for name in services if f"`{name}`" not in overview]
for name in missing:
    print(f"FAIL {name} is not on the architecture page")
sys.exit(1 if missing else 0)

Mermaid example

C4Container
  title Example Shop containers
  Person(shopper, "Shopper")
  System_Ext(psp, "Payment provider")
  Container(web, "Web app", "Node.js", "Pages and checkout")
  ContainerDb(db, "Database", "PostgreSQL", "Orders and stock")
  Rel(shopper, web, "Browses and buys", "HTTPS")
  Rel(web, db, "Reads and writes orders", "SQL")
  Rel(web, psp, "Creates payments", "HTTPS")

How to check

A script reads the list of deployable services, such as the services in the Compose file or the folders under services/. Each name appears in docs/architecture.md, and the page names no service that no longer exists. The same script compares the containers in the diagram with the services in the deploy files, such as Compose or Kubernetes manifests.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/documentation/readme-and-docs-as-code/architecture-overview">Agent Wranglers documentation playbook</a>. In code you write, add a comment next to it with the same link.