feat(c4): add @c4 system level + system-context diagram - #8
Open
nightscape wants to merge 1 commit into
Open
nightscape wants to merge 1 commit into
nightscape wants to merge 1 commit into
Conversation
Adds the top of the C4 model (previously C4Level had only Container/ Component/Unknown — no way to declare the system in focus or external systems). - archidoc-types: C4Level::System variant (+ Display "system"). - archidoc-rust: extract_c4_level() parses `@c4 system`. - archidoc-engine/plantuml: generate_context() renders one System() per `@c4 system` node plus its `@c4 uses` relationships → c4-context.puml (emitted only when a system node exists). Container diagram now renders system nodes as System_Ext() so container→system arrows resolve. - CLI render plantuml emits the context diagram alongside container/component. - Tests: extract_c4_level covers all four levels. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds first-class support for @c4 system annotations and uses them to generate a C4 system-context diagram and improve container diagram rendering when containers relate to external systems.
Changes:
- Introduces
C4Level::Systemand updates string formatting/serialization expectations. - Updates Rust adapter parsing to recognize
@c4 systemand adds tests for all C4 levels. - Adds PlantUML generation for a new
c4-context.pumldiagram and renders system nodes in the container diagram; wires the new generator into the CLI.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| core/archidoc-types/src/ir.rs | Adds System to the C4 level enum and display mapping. |
| core/archidoc-engine/src/plantuml.rs | Generates system-context diagram; renders system externals in container diagram. |
| core/archidoc-cli/src/main.rs | Calls the new context diagram generator in PlantUML rendering flow. |
| adapters/archidoc-rust/src/parser.rs | Parses @c4 system and adds a test covering all level markers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+105
to
+115
| let mut rel_defs = String::new(); | ||
| for dir in &systems { | ||
| let from_id = to_puml_id(&dir.path); | ||
| for rel in &dir.relationships { | ||
| let to_id = to_puml_id(&rel.target); | ||
| rel_defs.push_str(&format!( | ||
| "Rel({}, {}, \"{}\", \"{}\")\n", | ||
| from_id, to_id, rel.label, rel.protocol | ||
| )); | ||
| } | ||
| } |
Comment on lines
+34
to
+42
| for dir in systems_of(ir) { | ||
| let id = to_puml_id(&dir.path); | ||
| let name = to_title_case(&dir.name); | ||
| let desc = dir.description.as_deref().unwrap_or(""); | ||
| system_defs.push_str(&format!( | ||
| "System_Ext({}, \"{}\", \"{}\")\n", | ||
| id, name, desc | ||
| )); | ||
| } |
Comment on lines
+76
to
+81
| fn systems_of(ir: &ArchitectureIR) -> Vec<&DirNode> { | ||
| ir.annotated_dirs() | ||
| .into_iter() | ||
| .filter(|d| d.c4_level == Some(C4Level::System)) | ||
| .collect() | ||
| } |
Comment on lines
+99
to
+102
| system_defs.push_str(&format!( | ||
| "System({}, \"{}\", \"{}\")\n", | ||
| id, name, desc | ||
| )); |
Comment on lines
+110
to
+113
| rel_defs.push_str(&format!( | ||
| "Rel({}, {}, \"{}\", \"{}\")\n", | ||
| from_id, to_id, rel.label, rel.protocol | ||
| )); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the top of the C4 model.
C4Levelpreviously had onlyContainer/Component/Unknown— no way to declare the system in focus or the external systems it talks to.archidoc-types:C4Level::System(+Display"system").archidoc-rust:extract_c4_level()parses@c4 system.archidoc-engine/plantuml:generate_context()renders oneSystem(...)per@c4 systemnode plus its@c4 usesrelationships →c4-context.puml(emitted only when a system node exists). The container diagram now renders system nodes asSystem_Ext()so container→system arrows resolve.render plantumlemits the context diagram alongside container/component.Example
→
c4-context.pumlwithSystem(...)nodes andRel(...)arrows between them.Notes
Independent of the other branches (no file overlap beyond the
C4Levelenum and the render dispatcher). Test added covering all four levels.🤖 Generated with Claude Code