Skip to contents

Main Functions

Functions for creating C4 diagrams

c4_context()
Create a C4 System Context Diagram
c4_container_diagram()
Create a C4 Container Diagram
c4_component_diagram()
Create a C4 Component Diagram
c4_demo()
Demo C4 diagrams

Element Constructors

Functions for creating diagram elements

c4_person()
Create a person element for C4 diagrams
c4_system()
Create a system element for C4 diagrams
c4_container()
Create a container element for C4 diagrams
c4_component()
Create a component element for C4 diagrams
c4_external_system()
Create an external system element for C4 diagrams
c4_rel()
Create a relationship for C4 diagrams

Advanced Relationships

Functions for creating advanced relationship types

c4_rel_advanced()
Create an advanced relationship with additional visual properties
c4_rel_async()
Create an asynchronous relationship
c4_rel_bidirectional()
Create a bidirectional relationship

Grouping and Boundaries

Functions for organizing elements with groups and boundaries

c4_group()
Create a visual group/boundary for C4 diagrams
c4_system_boundary()
Create a system boundary group
c4_deployment_boundary()
Create a deployment boundary group

Builder API

Fluent API for building diagrams programmatically

c4_builder()
Create a C4 diagram builder
add_person()
Add a person element to the builder
add_system()
Add a system element to the builder
add_external_system()
Add an external system element to the builder
add_container()
Add a container element to the builder
add_component()
Add a component element to the builder
add_group()
Add a group/boundary to the builder
add_relationship()
Add a relationship to the builder
build_context()
Build a context diagram from the builder
build_container()
Build a container diagram from the builder
build_component()
Build a component diagram from the builder
set_theme()
Set the theme for the diagram
set_title()
Set the title for the diagram

Tibble Input

Functions for creating diagrams from tibble/data frame inputs

c4_persons_from_tibble()
Create person elements from a tibble or data frame
c4_systems_from_tibble()
Create system elements from a tibble or data frame
c4_external_systems_from_tibble()
Create external system elements from a tibble or data frame
c4_containers_from_tibble()
Create container elements from a tibble or data frame
c4_components_from_tibble()
Create component elements from a tibble or data frame
c4_rels_from_tibble()
Create relationship elements from a tibble or data frame

Templates

Functions for working with diagram templates

c4_from_template()
Create a diagram from a template
c4_list_templates()
List available templates
c4_save_template()
Save a custom template

Themes

Functions for customizing diagram appearance

c4_theme()
Create a custom C4 theme
c4_list_themes()
List all built-in themes
c4_load_theme()
Load a custom theme from file
c4_modify_theme()
Modify an existing C4 theme
c4_preview_theme()
Preview a theme's colors
c4_save_theme()
Save a custom theme for later use

Export

Functions for exporting diagrams to various formats

export_c4()
Export C4 diagram to various formats
export_c4_all()
Export C4 diagram to multiple formats
export_c4_dot()
Save DOT notation to file
c4_get_dot()
Get DOT notation from a C4 diagram

YAML Import/Export

Functions for working with YAML diagram definitions

diagram_from_yaml()
Import diagram elements from YAML
diagram_to_yaml()
Export diagram elements to YAML
diagram_to_code()
Generate R code from diagram elements
save_code()
Save generated code to file

Validation and Debugging

Functions for validating diagrams and finding issues

validate_c4()
Validate a C4 diagram for common issues
check_c4_elements()
Check C4 elements for common issues
c4_summary()
Get summary statistics for C4 diagram elements
c4_find_orphaned()
Find unused elements (elements with no relationships)
c4_find_invalid_rels()
Find relationships referencing non-existent elements

R-package toolchain integration

Helpers for integrating c4r with devtools/usethis/pkgdown/knitr/RStudio/GitHub Actions

use_c4r()
Scaffold c4r usage in an R package
use_c4r_vignette()
Add a c4r-powered vignette to a package
use_c4r_pkgdown()
Add a c4r article entry to _pkgdown.yml
use_c4r_readme()
Add a c4r chunk to README.Rmd
use_c4r_action()
Add a GitHub Actions workflow that renders c4r diagrams
c4_from_package()
Build a C4 diagram from an R package
pkgdown_diagram()
Render a C4 diagram tuned for pkgdown sites
c4_render_dsl()
Render a c4 DSL body into a diagram
c4_knitr_engine()
Knitr engine for declarative C4 chunks
insert_c4_chunk()
Insert a c4 chunk at the cursor (RStudio addin)
insert_c4_template()
Insert a c4 template chunk at the cursor (RStudio addin)