The Code Codex
Theme
← Notes / Architecture

note · text29 Sep 2024 · 2 min

Software documentation

The goal of documentation is that the system doesn’t depend on specific people to be understood. Too much documentation goes stale and nobody reads it; too little, and knowledge leaves with whoever leaves the team. Three practices cover most cases.

C4 model: diagrams in levels

Created by Simon Brown, it organizes diagrams like a map with zoom: each level shows more detail to a different audience.

1 · Context

the system and who uses it

2 · Containers

apps, APIs, databases

3 · Components

parts of a container

4 · Code

classes (rarely)

1 · Context

the system and who uses it

2 · Containers

apps, APIs, databases

3 · Components

parts of a container

4 · Code

classes (rarely)

LevelShowsFor whom
ContextThe system as a box, users and external systemsEveryone, including business
ContainersApplications, services and databases, and how they communicateTech team, operations
ComponentsThe main parts inside a containerDevelopers
CodeClasses and relationshipsRarely worth drawing; the code already is that

In most projects, the first two levels are enough.

ADR: decision records

An Architecture Decision Record is a short text, one per important decision, kept in the repository:

# 7. Use PostgreSQL as the main database
Status: accepted (2026-03-10)
Context: we need transactions and flexible queries; the team already knows SQL.
Decision: managed PostgreSQL in the cloud.
Consequences: we give up simple horizontal scaling; revisit above 5 TB.

The value is in the context: two years from now, nobody remembers why the decision was made. ADRs are not edited; a new decision supersedes the old one.

Documentation next to the code
  • A README with how to run, test and release.
  • Diagrams as code (Mermaid, Structurizr), versioned and reviewed in the same pull request that changes the system.
  • API contracts generated from the code (OpenAPI).

See also: Software architecture fundamentals.