Skip to content
structurizr-architecture-sync logo

Structurizr Architecture Synchronization

structurizr-architecture-sync

Maintain Structurizr C4 architecture diagrams in sync with code changes. Use when adding components, modifying relationships, changing architectural boundaries, or implementing new patterns. Ensures workspace.dsl accurately reflects the current system architecture.

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Structurizr Architecture Synchronization

Context (Input)

Use this skill when:

  • Adding new components (controllers, handlers, services, repositories)
  • Creating new entities or aggregates
  • Modifying component relationships or dependencies
  • Implementing new architectural patterns (CQRS, events, subscribers)
  • Adding infrastructure components (databases, caches, message brokers)
  • Refactoring that changes component structure
  • After fixing Deptrac violations (may indicate architecture drift)
  • Creating new bounded contexts or modules
  • Implementing new API endpoints with significant handlers

Task (Function)

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 components
  • Component relationships match actual code dependencies
  • Layer groupings (Application/​Domain/​Infrastructure) are accurate
  • Component descriptions reflect current purpose
  • All infrastructure dependencies are documented
  • C4 diagrams render without errors (check at http://localhost:${STRUCTURIZR_PORT:-8080})

Quick Start: Update Architecture in 5 Steps

Complete Template: See reference/​workspace-template.md for full workspace.dsl structure.

Step 1: Identify Architectural Changes

Determine if your code changes are architecturally significant:

✅ DO update workspace.dsl when adding:

  • Processors (HTTP/​GraphQL handlers)
  • Command Handlers (CQRS pattern)
  • Event Subscribers (event-driven patterns)
  • Entities (core domain objects)
  • Domain Events (significant business events)
  • Repositories (data access)
  • Event Bus or infrastructure services
  • External dependencies (DB, Cache, Message Broker)

❌ DON'T update for:

  • Factory classes
  • Transformer classes (unless critical)
  • Value objects (unless architecturally significant)
  • Interface definitions (except hexagonal ports)
  • Base classes
  • DTOs and input/​output objects
  • Utility classes and helpers

Target: 15-25 components per diagram for clarity.

Step 2: Add Component to Appropriate Group

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, Subscribers
  • group "Domain" - Entities, Domain Events
  • group "Infrastructure" - Repositories, Event Bus, Infrastructure services

External dependencies (database, cache, messageBroker) go OUTSIDE groups at container level.

See: reference/​dsl-syntax.md for complete syntax.

Step 3: Define Relationships

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

Step 4: Verify Diagram Renders

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:

  • No syntax errors displayed
  • New component appears
  • Relationships are visible
  • Component is in correct layer group

Step 5: Position and Commit

  1. Drag components in the UI to improve layout
  2. Click "Save workspace" button (saves to workspace.json)
  3. Commit both files:
git add workspace.dsl workspace.json
git commit -m "feat: update architecture with new processor"

Diagram as Code Workflow

Setup (Already Configured)

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)

Standard Development Flow

  1. Implement code changes → Add handler, entity, repository
  2. Update workspace.dsl → Add component + relationships
  3. View locally → Refresh browser at configured port
  4. Position components → Drag in UI, click "Save workspace"
  5. Commit together → Code + workspace.dsl + workspace.json in same PR

Manual Positioning in UI

Automatic layout doesn't work well - use manual positioning:

  1. Open Structurizr UI in browser
  2. Navigate to "Diagrams" → "Components_All"
  3. Drag components to arrange (left-to-right flow recommended)
  4. Click "Save workspace" button in top-right
  5. Positions saved to workspace.json in project root
  6. Commit workspace.json with workspace.dsl

Layout best practices:

  • Processors/​Controllers on the left (entry points)
  • Command Handlers in the middle (business logic)
  • Repositories to the right of handlers
  • Database/​Cache/​Message Broker on far right (external)

Common mistakes: See reference/​common-mistakes.md for complete guide.


Reference Documentation

Detailed Guides

Examples


Critical Principles

What Makes a Good Architecture Diagram

Clarity over Completeness:

  • 15-25 components (optimal readability)
  • Focus on architectural significance
  • Clear left-to-right or top-to-bottom flow
  • External dependencies clearly visible

Layer Separation:

  • Application: Entry points and orchestration
  • Domain: Business logic and entities
  • Infrastructure: Technical implementation

Meaningful Relationships:

  • Show actual code dependencies
  • Use descriptive labels
  • Avoid circular dependencies

Alignment with Deptrac

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.


Integration with Other Skills

Use this skill after:

Use this skill before:


Troubleshooting

Common Issues

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:

  1. Check balanced braces {}
  2. Verify all components are defined before relationships
  3. Ensure no duplicate variable names
  4. Compare with workspace-template.md

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.

External Resources

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View