- 3 minutes to read
L3 Component Diagram Example
The L3 Component diagram zooms into a single container and reveals its internal modules, classes, and interactions. It is the most detailed diagram in the C4 zoom hierarchy and is intended for developers implementing or maintaining the container.
See Example C4 Diagrams for an overview of all diagram types and when to use each.
When to Use
- Onboarding developers to a codebase
- Documenting the internal structure of a complex service or API
- Planning refactoring or identifying excessive coupling
- Not typically shared with non-technical audiences
Example: Order API Components
| Preview | Mermaid Code |
|---|---|
|
C4Component
title Order API - L3 Component Diagram
Person(client, "API Client", "Web app, mobile app, or admin portal")
Container_Boundary(order_api, "Order API") {
Component(api_gateway, "API Gateway", "ASP.NET Core", "Handles HTTP routing, authentication, rate limiting")
Component(order_controller, "Order Controller", "ASP.NET Core MVC", "REST endpoints for CRUD operations on orders")
Component(payment_controller, "Payment Controller", "ASP.NET Core MVC", "Payment processing endpoints")
Component(order_logic, "Order Service", "C#", "Business logic for order validation, calculation, and workflow")
Component(payment_logic, "Payment Service", "C#", "Encapsulates payment gateway integration")
Component(inventory_logic, "Inventory Service", "C#", "Manages inventory allocation and calculation")
Component(order_repo, "Order Repository", "C# + Entity Framework", "Data access for orders")
Component(customer_repo, "Customer Repository", "C# + Entity Framework", "Data access for customers")
Component(mapper, "Mapper", "C# + AutoMapper", "DTO to Domain object mapping")
Component(order_validator, "Order Validator", "FluentValidation", "Validates order syntax and business rules")
}
System_Ext(payment_gateway, "Payment Gateway", "Processes credit card payments")
Rel(client, api_gateway, "Makes HTTP requests", "REST/JSON")
Rel(api_gateway, order_controller, "Routes to", "In-process")
Rel(api_gateway, payment_controller, "Routes to", "In-process")
Rel(order_controller, mapper, "Uses", "In-process")
Rel(order_controller, order_validator, "Uses", "In-process")
Rel(order_controller, order_logic, "Delegates to", "In-process")
Rel(payment_controller, payment_logic, "Delegates to", "In-process")
Rel(order_logic, inventory_logic, "Uses", "In-process")
Rel(order_logic, order_repo, "Uses", "In-process")
Rel(payment_logic, customer_repo, "Uses", "In-process")
Rel(payment_logic, payment_gateway, "Calls", "HTTPS")
|
|
Next Step
Back to the hub — Example C4 Diagrams — to explore the supplementary diagram types: System Landscape, Dynamic, and Deployment.
Related Topics
- Example C4 Diagrams — Overview of all diagram types
- L2: Container Diagram Example — The container this diagram zooms into
- What is C4 Diagrams?