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.
Expert skill for analyzing codebases, documenting application architectures, and generating accurate Mermaid diagrams grounded in actual source code.
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 |
This is the most critical step. Do not generate diagrams from memory or assumptions.
main() functions, server setup, route registration, or handler initialization relevant to the scope.doc.go files for package-level documentation.grep for receiver types.New...()) and setup packages to understand how components are wired together.zz_generated_*.go, files with generation comments) to understand what is hand-written vs. generated.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 |
Pair every diagram with a prose explanation that:
When the user asks for architectural improvements:
This skill is tailored for the Radius project. Key architectural knowledge:
| 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 |
frontend/ (HTTP handlers, API validation) and backend/ (async operations, deployment) packages.datamodel/ with versioned API types in api/.armrpc controller interfaces.pkg/armrpc/asyncoperation/.pkg/recipes/.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.
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.
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]