Architecture Documenter
Expert skill for analyzing codebases, documenting application architectures, and generating accurate Mermaid diagrams grounded in actual source code.
Which doc skill?
When to Use
- Generate a high-level architecture overview of the system or a subsystem
- Produce component diagrams showing entity relationships
- Create sequence diagrams that are true-to-code (reflect actual call chains)
- Explain how a complex subsystem works in plain language
- Answer questions about the existing architecture
- Suggest architectural improvements that would simplify the code
- Onboard new contributors by explaining system structure
Core Principles
- Code-grounded: Every diagram and explanation must be derived from actual source code, not assumptions. Read the code before documenting it.
- Progressive depth: Start with high-level overviews, then drill into details only when asked.
- Accuracy over aesthetics: A correct simple diagram beats an elaborate wrong one.
- Human-readable output: Distill complex code concepts into clear, jargon-minimal prose. Use diagrams to complement text, not replace it.
Procedure
Step 1: Scope the Request
Determine what the user wants documented:
| Request Type |
Output |
| "How does X work?" |
Prose explanation + optional diagram |
| "Show me the architecture of X" |
Component diagram + brief description |
| "Show me the flow when X happens" |
Sequence diagram + step-by-step narrative |
| "What are the relationships between X, Y, Z?" |
Entity-relationship / component diagram |
| "How could X be improved?" |
Current-state diagram + improvement suggestions |
| "Give me an overview" |
High-level system diagram + component summary |
Step 2: Gather Context from Code
This is the most critical step. Do not generate diagrams from memory or assumptions.
- Identify entry points: Find
main() functions, server setup, route registration, or handler initialization relevant to the scope.
- Trace the call chain: Follow function calls from entry points through layers (frontend → backend → data). Read interfaces and their implementations.
- Map package structure: Understand how packages relate to each other. Pay attention to
doc.go files for package-level documentation.
- Identify key types: Find the core structs, interfaces, and their methods that define the architecture.
- Note patterns: Identify design patterns in use (controller pattern, resource provider pattern, middleware chains, async operations, etc.).
Go-Specific Investigation Techniques
- Find interface implementations: Search for methods matching interface signatures. Use
grep for receiver types.
- Trace dependency injection: Look at constructor functions (
New...()) and setup packages to understand how components are wired together.
- Follow the handler chain: For HTTP services, start at route registration and follow middleware → handler → controller → backend flow.
- Check for code generation: Look for generated files (
zz_generated_*.go, files with generation comments) to understand what is hand-written vs. generated.
- Read test files: Tests often reveal the expected behavior and interaction patterns between components.
Step 3: Generate the Diagram
Choose the appropriate Mermaid diagram type based on the request. See Mermaid Diagram Reference for templates.
| Situation |
Diagram Type |
| System / subsystem overview |
graph TD (top-down flowchart) |
| Request/response flow |
sequenceDiagram |
| Entity relationships |
classDiagram or erDiagram |
| State transitions |
stateDiagram-v2 |
| Component dependencies |
graph LR (left-right flowchart) |
| Deployment topology |
graph TD with subgraphs |
Diagram Quality Checklist
Step 4: Write the Explanation
Pair every diagram with a prose explanation that:
- Summarizes what the diagram shows in 1-2 sentences
- Walks through the key components and their responsibilities
- Highlights important architectural decisions or patterns
- Notes any non-obvious aspects (error handling paths, async behavior, retries)
Writing Style
- Use short paragraphs (3-4 sentences max)
- Lead with the "what" and "why" before the "how"
- Use bullet lists for component responsibilities
- Bold key terms on first use
- Reference specific file paths so readers can find the code
Step 5: Suggest Improvements (When Asked)
When the user asks for architectural improvements:
- Identify pain points: Look for code smells — excessive coupling, god packages, circular dependencies, duplicated patterns, inconsistent abstractions.
- Propose specific changes: Name the packages/types involved and describe the refactoring.
- Show before/after: Use a current-state diagram and a proposed-state diagram to illustrate the improvement.
- Assess trade-offs: Every change has a cost. Note migration effort, risk, and what gets simpler vs. more complex.
Radius Project Context
This skill is tailored for the Radius project. Key architectural knowledge:
High-Level Components
| Component |
Location |
Purpose |
| UCP (Universal Control Plane) |
pkg/ucp/, cmd/ucpd/ |
Core control plane, resource routing, proxy |
| Applications RP (Applications.Core) |
pkg/corerp/, cmd/applications-rp/ |
Resource provider for core Radius resources (environments, applications, containers, gateways) |
| Dynamic RP |
pkg/dynamicrp/, cmd/dynamic-rp/ |
Resource provider for user-defined resource types that have no dedicated RP implementation |
| Dapr RP |
pkg/daprrp/ |
Resource provider for Dapr portable resources (state stores, pub/sub, secret stores) |
| Datastores RP |
pkg/datastoresrp/ |
Resource provider for datastore portable resources (MongoDB, Redis, SQL) |
| Messaging RP |
pkg/messagingrp/ |
Resource provider for messaging portable resources (RabbitMQ) |
| Portable Resources (shared) |
pkg/portableresources/ |
Shared backend, handlers, processors, and renderers used by Dapr/Datastores/Messaging RPs |
| Controller |
pkg/controller/, cmd/controller/ |
Kubernetes controller for deployment reconciliation |
| CLI (rad) |
pkg/cli/, cmd/rad/ |
Command-line interface |
| ARM RPC Framework |
pkg/armrpc/ |
Shared framework for building ARM-compatible resource providers |
| Recipes Engine |
pkg/recipes/ |
Recipe execution engine for provisioning infrastructure via Terraform and Bicep |
| SDK |
pkg/sdk/ |
Client SDK for connecting to and interacting with the Radius control plane |
| Shared Components |
pkg/components/ |
Shared infrastructure: database, message queue, secrets, metrics, tracing |
| RP Commons |
pkg/rp/ |
Shared packages used by corerp and the portable resource providers |
Common Patterns
- Frontend/Backend split: Resource providers have
frontend/ (HTTP handlers, API validation) and backend/ (async operations, deployment) packages.
- Data models: Each RP defines data models in
datamodel/ with versioned API types in api/.
- ARM RPC controllers: HTTP handlers implement the
armrpc controller interfaces.
- Async operations: Long-running operations use the async operation framework in
pkg/armrpc/asyncoperation/.
- Recipes: Infrastructure provisioning via Terraform/Bicep recipes in
pkg/recipes/.
Design Notes
Architecture design documents are available in the design-notes/architecture/ directory of the radius-project/design-notes repository. Reference these for historical context on architectural decisions.
Output Directory
When generating architecture documentation files, place them in docs/architecture/ within the Radius repository. This folder is for living architecture documentation derived from the current codebase.
Output Format
Always structure output as:
## [Title — what is being documented]
[1-2 sentence summary]
```mermaid
[diagram]
```
### Key Components
[Bulleted list of components and responsibilities]
### How It Works
[Prose walkthrough of the flow/architecture]
### Notable Details
[Any non-obvious aspects worth calling out]
1---2name: radius-architecture-documenter-23description: Document application architectures with Mermaid diagrams. Use for: generating architecture overviews, component diagrams, sequence diagrams from code, explaining complex Go codebases, answering architecture questions, suggesting architectural improvements, producing entity-relationship diagrams, and distilling code into human-readable descriptions. For step-by-step contributor how-to docs, use radius-author-doc.4---56# Architecture Documenter78Expert skill for analyzing codebases, documenting application architectures, and generating accurate Mermaid diagrams grounded in actual source code.910## Which doc skill?1112| You want to… | Use |13|----------------------------------------------------------------------|----------------------------------------------------------------------------------|14| **Create** a new contributing doc | [radius-author-doc](../radius-author-doc/SKILL.md) |15| **Fix** an existing doc that drifted from code | [radius-update-doc](../radius-update-doc/SKILL.md) |16| **Find** missing or stale docs, or assess a code change's doc impact | [radius-contributing-docs-updater](../radius-contributing-docs-updater/SKILL.md) |17| **Diagram** a subsystem / write an architecture doc | **this skill** |1819## When to Use2021- Generate a high-level architecture overview of the system or a subsystem22- Produce component diagrams showing entity relationships23- Create sequence diagrams that are true-to-code (reflect actual call chains)24- Explain how a complex subsystem works in plain language25- Answer questions about the existing architecture26- Suggest architectural improvements that would simplify the code27- Onboard new contributors by explaining system structure2829## Core Principles30311. **Code-grounded**: Every diagram and explanation must be derived from actual source code, not assumptions. Read the code before documenting it.322. **Progressive depth**: Start with high-level overviews, then drill into details only when asked.333. **Accuracy over aesthetics**: A correct simple diagram beats an elaborate wrong one.344. **Human-readable output**: Distill complex code concepts into clear, jargon-minimal prose. Use diagrams to complement text, not replace it.3536## Procedure3738### Step 1: Scope the Request3940Determine what the user wants documented:4142| Request Type | Output |43|-----------------------------------------------|-------------------------------------------------|44| "How does X work?" | Prose explanation + optional diagram |45| "Show me the architecture of X" | Component diagram + brief description |46| "Show me the flow when X happens" | Sequence diagram + step-by-step narrative |47| "What are the relationships between X, Y, Z?" | Entity-relationship / component diagram |48| "How could X be improved?" | Current-state diagram + improvement suggestions |49| "Give me an overview" | High-level system diagram + component summary |5051### Step 2: Gather Context from Code5253This is the most critical step. **Do not generate diagrams from memory or assumptions.**54551. **Identify entry points**: Find `main()` functions, server setup, route registration, or handler initialization relevant to the scope.562. **Trace the call chain**: Follow function calls from entry points through layers (frontend → backend → data). Read interfaces and their implementations.573. **Map package structure**: Understand how packages relate to each other. Pay attention to `doc.go` files for package-level documentation.584. **Identify key types**: Find the core structs, interfaces, and their methods that define the architecture.595. **Note patterns**: Identify design patterns in use (controller pattern, resource provider pattern, middleware chains, async operations, etc.).6061#### Go-Specific Investigation Techniques6263- **Find interface implementations**: Search for methods matching interface signatures. Use `grep` for receiver types.64- **Trace dependency injection**: Look at constructor functions (`New...()`) and `setup` packages to understand how components are wired together.65- **Follow the handler chain**: For HTTP services, start at route registration and follow middleware → handler → controller → backend flow.66- **Check for code generation**: Look for generated files (`zz_generated_*.go`, files with generation comments) to understand what is hand-written vs. generated.67- **Read test files**: Tests often reveal the expected behavior and interaction patterns between components.6869### Step 3: Generate the Diagram7071Choose the appropriate Mermaid diagram type based on the request. See [Mermaid Diagram Reference](./references/mermaid-patterns.md) for templates.7273| Situation | Diagram Type |74|-----------------------------|-----------------------------------|75| System / subsystem overview | `graph TD` (top-down flowchart) |76| Request/response flow | `sequenceDiagram` |77| Entity relationships | `classDiagram` or `erDiagram` |78| State transitions | `stateDiagram-v2` |79| Component dependencies | `graph LR` (left-right flowchart) |80| Deployment topology | `graph TD` with subgraphs |8182#### Diagram Quality Checklist8384- [ ] Every node in the diagram corresponds to a real package, type, or component in the code85- [ ] Relationships reflect actual code dependencies (imports, function calls, interface implementations)86- [ ] Labels use the actual names from the codebase (type names, package names, function names)87- [ ] The diagram is not overcrowded — split into multiple diagrams if >15 nodes88- [ ] Subgraphs are used to group related components89- [ ] Arrow labels describe the nature of the relationship (e.g., "implements", "calls", "sends")9091### Step 4: Write the Explanation9293Pair every diagram with a prose explanation that:94951. **Summarizes** what the diagram shows in 1-2 sentences962. **Walks through** the key components and their responsibilities973. **Highlights** important architectural decisions or patterns984. **Notes** any non-obvious aspects (error handling paths, async behavior, retries)99100#### Writing Style101102- Use short paragraphs (3-4 sentences max)103- Lead with the "what" and "why" before the "how"104- Use bullet lists for component responsibilities105- Bold key terms on first use106- Reference specific file paths so readers can find the code107108### Step 5: Suggest Improvements (When Asked)109110When the user asks for architectural improvements:1111121. **Identify pain points**: Look for code smells — excessive coupling, god packages, circular dependencies, duplicated patterns, inconsistent abstractions.1132. **Propose specific changes**: Name the packages/types involved and describe the refactoring.1143. **Show before/after**: Use a current-state diagram and a proposed-state diagram to illustrate the improvement.1154. **Assess trade-offs**: Every change has a cost. Note migration effort, risk, and what gets simpler vs. more complex.116117## Radius Project Context118119This skill is tailored for the Radius project. Key architectural knowledge:120121### High-Level Components122123| Component | Location | Purpose |124|-------------------------------------|---------------------------------------|------------------------------------------------------------------------------------------------|125| UCP (Universal Control Plane) | `pkg/ucp/`, `cmd/ucpd/` | Core control plane, resource routing, proxy |126| Applications RP (Applications.Core) | `pkg/corerp/`, `cmd/applications-rp/` | Resource provider for core Radius resources (environments, applications, containers, gateways) |127| Dynamic RP | `pkg/dynamicrp/`, `cmd/dynamic-rp/` | Resource provider for user-defined resource types that have no dedicated RP implementation |128| Dapr RP | `pkg/daprrp/` | Resource provider for Dapr portable resources (state stores, pub/sub, secret stores) |129| Datastores RP | `pkg/datastoresrp/` | Resource provider for datastore portable resources (MongoDB, Redis, SQL) |130| Messaging RP | `pkg/messagingrp/` | Resource provider for messaging portable resources (RabbitMQ) |131| Portable Resources (shared) | `pkg/portableresources/` | Shared backend, handlers, processors, and renderers used by Dapr/Datastores/Messaging RPs |132| Controller | `pkg/controller/`, `cmd/controller/` | Kubernetes controller for deployment reconciliation |133| CLI (rad) | `pkg/cli/`, `cmd/rad/` | Command-line interface |134| ARM RPC Framework | `pkg/armrpc/` | Shared framework for building ARM-compatible resource providers |135| Recipes Engine | `pkg/recipes/` | Recipe execution engine for provisioning infrastructure via Terraform and Bicep |136| SDK | `pkg/sdk/` | Client SDK for connecting to and interacting with the Radius control plane |137| Shared Components | `pkg/components/` | Shared infrastructure: database, message queue, secrets, metrics, tracing |138| RP Commons | `pkg/rp/` | Shared packages used by corerp and the portable resource providers |139140### Common Patterns141142- **Frontend/Backend split**: Resource providers have `frontend/` (HTTP handlers, API validation) and `backend/` (async operations, deployment) packages.143- **Data models**: Each RP defines data models in `datamodel/` with versioned API types in `api/`.144- **ARM RPC controllers**: HTTP handlers implement the `armrpc` controller interfaces.145- **Async operations**: Long-running operations use the async operation framework in `pkg/armrpc/asyncoperation/`.146- **Recipes**: Infrastructure provisioning via Terraform/Bicep recipes in `pkg/recipes/`.147148### Design Notes149150Architecture design documents are available in the `design-notes/architecture/` directory of the `radius-project/design-notes` repository. Reference these for historical context on architectural decisions.151152### Output Directory153154When generating architecture documentation files, place them in `docs/architecture/` within the Radius repository. This folder is for living architecture documentation derived from the current codebase.155156## Output Format157158Always structure output as:159160````markdown161## [Title — what is being documented]162163[1-2 sentence summary]164165```mermaid166[diagram]167```168169### Key Components170171[Bulleted list of components and responsibilities]172173### How It Works174175[Prose walkthrough of the flow/architecture]176177### Notable Details178179[Any non-obvious aspects worth calling out]180````