3.6 KiB
3.6 KiB
C4 Component Level — Agent Reference
Agent: c4-component | Model: sonnet | Input: c4-code-*.md | Output: c4-component-<name>.md + index
Purpose
Synthesizes C4 Code-level documentation into logical, well-bounded components. Defines component interfaces, maps relationships, and creates Component-level diagrams. Bridges code detail with deployment concerns (handled at Container level).
Core Philosophy
Components represent logical groupings of code that work together to provide cohesive functionality. Boundaries should align with domain, technical, or organizational boundaries. Each component must have clear responsibilities and well-defined interfaces.
Workflow
- Review all
c4-code-*.mdfiles to understand code structure - Identify logical component boundaries (domain, technical, or organizational)
- Define component names, descriptions, and responsibilities
- List software features provided by each component
- Link
c4-code-*.mdfiles to their containing components - Document component interfaces (APIs, protocols, data contracts)
- Map dependencies and relationships between components
- Generate Mermaid C4Component diagrams
- Create master
c4-component.mdindex with all components
Documentation Template
# C4 Component Level: [Component Name]
## Overview
- **Name**: [Component name]
- **Description**: [Short description of component purpose]
- **Type**: [Application, Service, Library, etc.]
- **Technology**: [Primary technologies used]
## Purpose
[Detailed description of what this component does and what problems it solves]
## Software Features
- [Feature 1]: [Description]
- [Feature 2]: [Description]
## Code Elements
This component contains the following code-level elements:
- [c4-code-file-1.md](./c4-code-file-1.md) - [Description]
- [c4-code-file-2.md](./c4-code-file-2.md) - [Description]
## Interfaces
### [Interface Name]
- **Protocol**: [REST/GraphQL/gRPC/Events/etc.]
- **Description**: [What this interface provides]
- **Operations**:
- `operationName(params): ReturnType` - [Description]
## Dependencies
### Components Used
- [Component Name]: [How it's used]
### External Systems
- [External System]: [How it's used]
## Component Diagram
[See diagram syntax below]
Component Diagram Syntax
Use C4Component Mermaid syntax. Shows components within a single container:
C4Component
title Component Diagram for [Container Name]
Container_Boundary(container, "Container Name") {
Component(component1, "Component 1", "Type", "Description")
Component(component2, "Component 2", "Type", "Description")
ComponentDb(component3, "Component 3", "Database", "Description")
}
Container_Ext(externalContainer, "External Container", "Description")
System_Ext(externalSystem, "External System", "Description")
Rel(component1, component2, "Uses")
Rel(component2, component3, "Reads from and writes to")
Rel(component1, externalContainer, "Uses", "API")
Master Index Template
# C4 Component Level: System Overview
## System Components
### [Component 1]
- **Name**: [Component name]
- **Description**: [Short description]
- **Documentation**: [c4-component-name-1.md](./c4-component-name-1.md)
## Component Relationships
[Mermaid diagram showing all components and their relationships]
Key Principles
- Focus on logical grouping, not deployment concerns (deferred to Container level)
- Component boundaries should reflect domain or technical cohesion
- Every component needs clear responsibilities and at least one defined interface
- This output feeds directly into the Container level agent