--- id: wiki-2026-0508-c4-modeling-framework title: C4 Modeling Framework category: 10_Wiki/Topics status: verified canonical_id: self aliases: [C4 Model, C4 Diagrams, Simon Brown C4] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [architecture, c4, diagram, structurizr, documentation] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: DSL framework: Structurizr --- # C4 Modeling Framework ## 매 한 줄 > **"매 software architecture = 4 zoom levels (Context → Container → Component → Code)."**. 매 Simon Brown 이 2006년경 제안한 lightweight visualization framework. 매 2026 현재 Structurizr DSL + Mermaid C4 plugin 으로 diagram-as-code 가 standard, 매 audience-specific abstraction level 이 핵심 가치. ## 매 핵심 ### 매 4 levels - **L1 — System Context**: 매 system + users + external systems. 매 non-technical stakeholder 용. - **L2 — Container**: 매 deployable unit (web app, API, DB, queue). 매 technical lead 용. - **L3 — Component**: 매 container 내부 logical grouping (controller, service, repo). 매 dev team 용. - **L4 — Code**: 매 class diagram (UML). 매 거의 안 그림 — IDE 가 대신. ### 매 supplementary diagrams - **Deployment diagram**: 매 container → infrastructure node mapping. - **Dynamic diagram**: 매 runtime sequence/collaboration. - **System landscape**: 매 enterprise-wide multi-system view. ### 매 응용 1. **Onboarding doc**: 매 새 dev 의 codebase orientation. 2. **ADR illustration**: 매 architecture decision record 의 visual aid. 3. **Stakeholder communication**: 매 PM/exec 에게 system scope 설명. 4. **Compliance audit**: 매 data flow / boundary 시각화. ## 💻 패턴 ### Structurizr DSL (canonical) ```dsl workspace "Banking System" { model { customer = person "Customer" bankSystem = softwareSystem "Internet Banking" { webApp = container "Web Application" "Spring Boot" "Java" mobileApp = container "Mobile App" "React Native" "TypeScript" api = container "API" "Spring Boot" "Java" db = container "Database" "PostgreSQL" "RDBMS" webApp -> api "uses" "JSON/HTTPS" mobileApp -> api "uses" "JSON/HTTPS" api -> db "reads/writes" "JDBC" } mainframe = softwareSystem "Mainframe" "External" customer -> bankSystem "uses" bankSystem -> mainframe "fetches account data" "MQ" } views { systemContext bankSystem { include * autolayout } container bankSystem { include * autolayout } theme default } } ``` ### Mermaid C4 (in-repo markdown) ```mermaid C4Context title System Context — Banking Person(customer, "Customer") System(bank, "Internet Banking", "Allows customers to view accounts") System_Ext(mainframe, "Mainframe", "Legacy core banking") Rel(customer, bank, "Uses") Rel(bank, mainframe, "Fetches data", "MQ") ``` ### Component-level decomposition ```dsl api = container "API" { signInController = component "SignIn Controller" "Spring MVC" accountsController = component "Accounts Controller" "Spring MVC" authService = component "Auth Service" "Spring Bean" accountsRepo = component "Accounts Repository" "Spring Data JPA" signInController -> authService "uses" accountsController -> accountsRepo "reads" authService -> db "verifies credentials" } ``` ### Deployment view ```dsl deploymentEnvironment "Production" { deploymentNode "AWS us-east-1" { deploymentNode "EKS Cluster" { containerInstance webApp containerInstance api } deploymentNode "RDS" { containerInstance db } } } ``` ### Generated docs pipeline ```bash # CI step — render diagrams from DSL docker run --rm -v $PWD:/usr/local/structurizr structurizr/cli \ export -workspace workspace.dsl -format plantuml/c4plantuml plantuml -tsvg *.puml mv *.svg docs/architecture/ ``` ### ADR + C4 link ```markdown # ADR-007: Move auth to dedicated service **Status**: Accepted **Context**: See [Container diagram](../diagrams/banking-containers.svg) **Decision**: Extract `authService` component into its own container. **Consequences**: New diagram in `diagrams/v2-containers.svg`. ``` ## 매 결정 기준 | 상황 | Diagram level | |---|---| | Pitch to exec / new joiner intro | L1 Context | | Tech selection / deployment plan | L2 Container | | Code review / refactor discussion | L3 Component | | Inheritance question | IDE (skip L4) | | Multi-system enterprise view | System Landscape | **기본값**: L1 + L2 (둘만 있어도 90% communication 충족). ## 🔗 Graph - 부모: [[Software_Architecture]] · [[Architecture_Documentation]] - 변형: [[arc42]] - 응용: [[ADR]] · [[Structurizr]] - Adjacent: [[Mermaid]] · [[PlantUML]] · [[DDD]] ## 🤖 LLM 활용 **언제**: greenfield architecture 문서화, legacy reverse-engineering, ADR illustration. **언제 X**: real-time runtime monitoring (observability tool 영역). ## ❌ 안티패턴 - **All 4 levels for every system**: 매 L4 거의 무의미 — IDE 대체. - **Mixing levels in one diagram**: 매 abstraction 깨짐 → audience 혼란. - **No legend / inconsistent shapes**: 매 reader 가 element type 못 구분. - **Diagram drift**: 매 DSL 없이 manual draw → 6개월 후 stale. ## 🧪 검증 / 중복 - Verified (c4model.com — Simon Brown, Structurizr DSL spec 2024). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — C4 levels, Structurizr DSL, Mermaid C4 examples |