Maintain Structurizr C4 architecture diagrams in sync with code changes. Use when adding components, modifying relationships, changing architectural boundaries, or implementing new patterns...
Use this skill when:
Keep the Structurizr workspace (workspace.dsl) synchronized with codebase changes, ensuring C4 model diagrams accurately represent the current system architecture.
Success Criteria:
workspace.dsl contains all significant componentshttp://localhost:${STRUCTURIZR_PORT:-8080})Complete Template: See reference/workspace-template.md for full workspace.dsl structure.
Determine if your code changes are architecturally significant:
✅ DO update workspace.dsl when adding:
❌ DON'T update for:
Target: 15-25 components per diagram for clarity.
Edit workspace.dsl and add component in the correct layer group:
group "Application" {
newProcessor = component "NewProcessor" "Handles new requests" "RequestProcessor" {
tags "Item"
}
}
Layers:
group "Application" - Controllers, Processors, Handlers, Subscribersgroup "Domain" - Entities, Domain Eventsgroup "Infrastructure" - Repositories, Event Bus, Infrastructure servicesExternal dependencies (database, cache, messageBroker) go OUTSIDE groups at container level.
See: reference/dsl-syntax.md for complete syntax.
Add relationships showing how your component interacts:
// After all component definitions
newProcessor -> commandHandler "dispatches NewCommand"
commandHandler -> repository "uses"
repository -> database "accesses data"
Common patterns: See reference/relationship-patterns.md
View the updated diagram:
# Refresh browser (Structurizr Lite auto-reloads)
# Port is configurable via STRUCTURIZR_PORT in .env (default: 8080)
open http://localhost:${STRUCTURIZR_PORT:-8080}
# Navigate to "Diagrams" → "Components_All"
Check for:
workspace.json)git add workspace.dsl workspace.json
git commit -m "feat: update architecture with new processor"
Docker: Structurizr Lite runs in docker-compose.override.yml:
structurizr:
image: structurizr/lite:2024.07.02
ports:
- '${STRUCTURIZR_PORT}:8080'
volumes:
- ./:/usr/local/structurizr
Access: http://localhost:${STRUCTURIZR_PORT:-8080} (port configurable via .env)
Automatic layout doesn't work well - use manual positioning:
workspace.json in project rootworkspace.json with workspace.dslLayout best practices:
Common mistakes: See reference/common-mistakes.md for complete guide.
Clarity over Completeness:
Layer Separation:
Meaningful Relationships:
Layer groupings in workspace.dsl MUST match Deptrac configuration:
group "Application" ↔ Application layer in deptrac.yaml
group "Domain" ↔ Domain layer in deptrac.yaml
group "Infrastructure" ↔ Infrastructure layer in deptrac.yaml
This ensures architecture documentation matches enforced boundaries.
Use this skill after:
Use this skill before:
Issue: Structurizr UI shows "Element does not exist" error
Solution: Check component variable names in relationships match the component definitions exactly. See common-mistakes.md.
Issue: Diagram shows components in wrong positions after pull
Solution: Ensure workspace.json is committed along with workspace.dsl. The JSON file stores manual positions.
Issue: DSL syntax validation fails
Solution:
{}Issue: Too many components (30+), diagram is cluttered
Solution: Follow component-identification.md - aim for 15-25 components. Omit DTOs, utilities, and factories.
Issue: Can't determine if component should be documented
Solution: Use the decision matrix in component-identification.md or the TL;DR section.