RDF export¶
The architecture model behind the explorer is also an RDF graph: every element, relationship, use case, scenario step, state transition and image is a resource you can query, and so are the data's schemas, tables, fields and the references between them. The terms come from the plugin's own C4 architecture ontology, and the graph is complete: a page recreated from it draws exactly the same diagrams, the Data view included.

Downloads¶
The explorer's export menu downloads the graph as:
- JSON-LD or Turtle, generated in the browser.
.rete, a single-file RDF graph you can host anywhere and query with SPARQL without a database server. It is built in the browser with rete; this one button needs a network connection, as does the preview of the Mermaid panel; the rest of the page does not.
In edit mode the tool rail's download menu offers the same downloads for the edited model.
The build also writes architecture.jsonld and architecture.ttl next to the page, and architecture.rete when
the rete CLI or the rete-graph npm package is installed. Otherwise:
Elsewhere: the MCP server exports Turtle, JSON-LD, N-Triples and .rete and runs SPARQL over a model
(export_rdf, query_sparql), and the architecture history writes every version of a model as a named
graph in one RDF 1.2 dataset (TriG, N-Quads, .rete).
The data in the graph¶
With a data layer, the graph describes it in the data module (c4d:): each schema and the element it lives in, each
entity with its fields in order, and each reference down to the field it points at. From the example's graph
(architecture.ttl, 5,037 triples), trimmed:
:dataschema:pg a c4d:Schema ;
rdfs:label "PostgreSQL schema" ;
c4d:schemaKind "relational" ;
c4d:livesIn :postgres .
:field:tasks.image_id a c4d:DataItem, c4d:Field ;
c4d:inEntity :entity:tasks ;
schema:position 2 ;
rdfs:label "image_id" ;
c4d:declaredType "INTEGER" ;
c4d:references :field:images.id ;
c4d:onDelete "cascade" .
:step:upload:17 c4d:writes :field:images.thumbnail_key, :field:images.width, :field:images.height .
Schemas and data has a query and its result on the example.
Icons in the graph¶
Icons are presentation, so they are in the view module: c4v:icon holds the reference as
the model writes it, and c4v:iconColor its colour (brand or a tone). A library icon (tabler:<name>, si:<slug>)
is named by its reference alone; its SVG is not in the graph, and a page built from the graph resolves it again. The
model's own icons (MODEL.icons) are c4v:IconDefinition resources with their SVG, key, source and licence, so a
page recreated from the graph draws them offline; c4v:iconStyle and c4v:showIcons keep the page's default. From
the example:
:postgres c4v:icon "si:postgresql" .
:rel:50 c4v:icon "sql" . # models → postgres, "SQL (SQLAlchemy)"
:dataschema:pg c4v:icon "si:postgresql" .
An icon says nothing that c4:technology does not: query the technology, not the logo. The terms are on the
view terms page.
Deployment in the graph¶
A model's deployment is in the graph too: each environment is a c4:DeploymentEnvironment (part of
the model), each deployment node a c4:DeploymentNode nested with c4:deployedIn, each instance a
c4:ContainerInstance or c4:SoftwareSystemInstance with c4:instanceOf the element it runs (and c4:instances
for ×N), each infrastructure node a c4:InfrastructureNode, and the relationships only the deployment has
c4:DeploymentRelationship (c4:deploymentSource, c4:deploymentTarget). The SHACL shapes check them, and the way
back rebuilds the same deployment. From the example:
:dnode:local:docker-host a c4:DeploymentNode ;
rdfs:label "Docker host" ; c4:technology "Docker Engine · Docker Compose" ;
c4:environment :env:local ; c4:path "docker-compose.yml" ; c4:line 1 .
:instance:local:api a c4:ContainerInstance ;
c4:instanceOf :api ; c4:deployedIn :dnode:local:docker-host ;
c4:technology "python:3.12-slim image built from api/Dockerfile · uvicorn · port 8000" .
User stories in the graph¶
The user stories can be a graph too, linked into this one: each story's actor is the architecture's person, its journey the scenario's steps, and each screen points at the step where it is seen. It is optional:
build-stories.mjs … --rdfwritesstories.jsonldandstories.ttl(andstories.retewhen a builder is found) next to the stories page, andstories-rdf.mjsdoes the same for a page already built. Both check that every link into the architecture graph resolves.- The stories page's Download ▾ has Stories as an RDF graph (JSON-LD, made in the browser).
- Readers' feedback goes in only when asked (
--with-feedback,extract-feedback.mjs --rdf, or Stories and feedback as an RDF graph), into files of their own: notes are people's words. The audio of a voice note never goes in, only that there is one and its file name.
The terms are the user stories module (c4us:). Load both graphs and ask, for example,
which stories touch the API service:
PREFIX c4: <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4#>
PREFIX c4us: <https://caviri.github.io/c4-model-agentic-plugin/ontology/c4-stories#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT DISTINCT ?title WHERE {
?story a c4us:UserStory ; rdfs:label ?title ; c4us:coversStep ?step .
?step c4:source|c4:target ?el .
?el dcterms:isPartOf* ?box .
?box dcterms:identifier "api" .
} ORDER BY ?title
The stories as an RDF graph has the mapping, the IRIs and more queries.
Back from the graph¶
build-explorer.mjs accepts a graph in place of model.js and rebuilds the page from it, and model-from-rdf.mjs
turns a graph back into an editable model.js. check-roundtrip.mjs proves, for a model, that its graph in each
serialisation gives the model back and that the recreated page looks the same.
Try it on the example¶
The example's graph is published with these docs:
architecture.ttl
and
architecture.jsonld
on GitHub, or use the export menu in the live explorer. Its user stories as a graph:
stories.ttl
and
stories.jsonld.
Vocabulary, shapes and queries¶
- The ontology: core terms (
c4:), data terms (c4d:), view terms (c4v:, icons included), history terms (c4h:), user stories terms (c4us:), SHACL shapes, and how to extend it with terms of your own, which a model carries through itsrdfhook. - The RDF graph reference: the IRIs, the mapping from each model field, the extension hook, validation, recreating a page, and tested SPARQL queries (containers and their technologies, everything that depends on one element, what an element uses, the steps of a scenario, use cases, state transitions, elements nothing points at, the layout of a box; and for the data, where each schema lives, which steps write a column of a table, which entities store an ontology class, every soft reference across stores, the fields whose values are a lifecycle's states, and where the tables are defined in the code).