# bruju/shacled-turtle architecture

> Architecture diagram of the GitHub repository bruju/shacled-turtle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bruju/shacled-turtle
- Repository: https://github.com/bruju/shacled-turtle

## Overview

SHACLed Turtle is a CodeMirror 6 extension for Turtle editing, combining syntax highlighting, schema-driven completion, and basic error display. The main workflow is to load RDF/JS schema quads, derive inference and suggestion models, then use the editor’s parsed Turtle context and current triples to offer completions. The repository also includes a standalone syntax-highlighting package and demos. Some links reflect only the README or SOURCE INDEX; unsampled implementation details are not expanded into unsupported call chains.

Main entry points: [`shacled-turtle/index.ts`](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/index.ts) (CodeMirror extension), [`shacled-turtle/src/schema/builder/index.ts`](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/index.ts) (Schema builder), [`shacled-turtle/src/autocompletion-solving.ts`](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/autocompletion-solving.ts) (Completion dispatcher), [`shacled-turtle/src/triples-autocompletion.ts`](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/triples-autocompletion.ts) (Triple completion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editor["Editor integration"]
  node_demo["Demo editor<br/>[index.ts]"]
  node_extension["CodeMirror extension<br/>[index.ts]"]
  node_state["Editor schema state<br/>[StateField.ts]"]
end

subgraph group_turtle["Turtle processing"]
  node_basic["Turtle syntax support<br/>[index.ts]"]
  node_parser["Turtle parser<br/>[Parser.ts]"]
  node_fullparser["Document parser<br/>[FullParser.ts]"]
end

subgraph group_schema["Schema modeling"]
  node_schema["Schema facade<br/>[index.ts]"]
  node_schema_builder["Schema builder<br/>[index.ts]"]
  node_rdfs["RDFS support<br/>[rdfs.ts]"]
  node_shacl["SHACL support<br/>[shacl.ts]"]
  node_inference_builder["Inference rules builder"]
  node_inference["Inference engine<br/>[InferenceEngine.ts]"]
  node_suggestion_builder["Suggestion builder"]
  node_suggestion["Suggestion engine"]
end

subgraph group_completion["Completion and feedback"]
  node_solver["Completion dispatcher"]
  node_triples["Triple completion"]
  node_current["Current document triples<br/>[CurrentTriples.ts]"]
  node_debug["Completion diagnostics"]
  node_errors["Error detection<br/>[error-detection.ts]"]
  node_prefixes["Prefix suggestions"]
end

node_user(("Editor user"))
node_schema_data[("Schema RDF data")]

node_user -->|"edits Turtle"| node_demo
node_demo -.->|"configures"| node_extension
node_extension -->|"enables syntax"| node_basic
node_extension -->|"installs state"| node_state
node_extension -->|"registers completion"| node_solver
node_extension -->|"enables lint"| node_errors
node_schema_data -.->|"loads schema"| node_state
node_state -->|"uses schema"| node_schema
node_schema_data -->|"builds models"| node_schema
node_schema -->|"creates builder"| node_schema_builder
node_schema_builder -->|"adds RDFS"| node_rdfs
node_schema_builder -->|"adds SHACL"| node_shacl
node_schema_builder -->|"builds rules"| node_inference_builder
node_schema_builder -->|"builds suggestions"| node_suggestion_builder
node_inference_builder -->|"creates engine"| node_inference
node_suggestion_builder -->|"creates engine"| node_suggestion
node_solver -->|"dispatches triples"| node_triples
node_solver -->|"uses prefixes"| node_prefixes
node_solver -->|"reports context"| node_debug
node_triples -->|"reads document"| node_current
node_triples -->|"queries suggestions"| node_schema
node_fullparser -->|"uses parser"| node_parser
node_fullparser -->|"uses completion logic"| node_triples
node_user -->|"uses extension"| node_extension

click node_demo "https://github.com/bruju/shacled-turtle/blob/master/demo/src/index.ts"
click node_extension "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/index.ts"
click node_basic "https://github.com/bruju/shacled-turtle/blob/master/lang-turtle/src/index.ts"
click node_parser "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/Parser.ts"
click node_fullparser "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/FullParser.ts"
click node_state "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/StateField.ts"
click node_schema "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/index.ts"
click node_schema_builder "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/index.ts"
click node_rdfs "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/rdfs.ts"
click node_shacl "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/shacl.ts"
click node_inference_builder "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/InferenceEngineBuilder.ts"
click node_inference "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/InferenceEngine.ts"
click node_suggestion_builder "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/SuggestionEngineBuilder.ts"
click node_suggestion "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/SuggestionEngine.ts"
click node_solver "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/autocompletion-solving.ts"
click node_triples "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/triples-autocompletion.ts"
click node_current "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/CurrentTriples.ts"
click node_debug "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/DebugInformation.ts"
click node_errors "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/error-detection.ts"
click node_prefixes "https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/existing-prefixes.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_demo,node_extension,node_state,node_user toneBlue
class node_basic,node_parser,node_fullparser,node_schema_data toneAmber
class node_schema,node_schema_builder,node_rdfs,node_shacl,node_inference_builder,node_inference,node_suggestion_builder,node_suggestion toneMint
class node_solver,node_triples,node_current,node_debug,node_errors,node_prefixes toneRose
```

## Components

### Editor integration

- [Demo editor](https://github.com/bruju/shacled-turtle/blob/master/demo/src/index.ts): `demo/src/index.ts`
- [CodeMirror extension](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/index.ts): `shacled-turtle/index.ts`
- [Editor schema state](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/StateField.ts): `shacled-turtle/src/StateField.ts`

### Turtle processing

- [Turtle syntax support](https://github.com/bruju/shacled-turtle/blob/master/lang-turtle/src/index.ts): `lang-turtle/src/index.ts`
- [Turtle parser](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/Parser.ts): `shacled-turtle/src/Parser.ts`
- [Document parser](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/FullParser.ts): `shacled-turtle/src/FullParser.ts`

### Schema modeling

- [Schema facade](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/index.ts): `shacled-turtle/src/schema/index.ts`
- [Schema builder](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/index.ts): `shacled-turtle/src/schema/builder/index.ts`
- [RDFS support](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/rdfs.ts): `shacled-turtle/src/schema/builder/rdfs.ts`
- [SHACL support](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/shacl.ts): `shacled-turtle/src/schema/builder/shacl.ts`
- [Inference rules builder](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/InferenceEngineBuilder.ts): `shacled-turtle/src/schema/builder/InferenceEngineBuilder.ts`
- [Inference engine](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/InferenceEngine.ts): `shacled-turtle/src/schema/InferenceEngine.ts`
- [Suggestion builder](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/builder/SuggestionEngineBuilder.ts): `shacled-turtle/src/schema/builder/SuggestionEngineBuilder.ts`
- [Suggestion engine](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/schema/SuggestionEngine.ts): `shacled-turtle/src/schema/SuggestionEngine.ts`

### Completion and feedback

- [Completion dispatcher](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/autocompletion-solving.ts): `shacled-turtle/src/autocompletion-solving.ts`
- [Triple completion](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/triples-autocompletion.ts): `shacled-turtle/src/triples-autocompletion.ts`
- [Current document triples](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/CurrentTriples.ts): `shacled-turtle/src/CurrentTriples.ts`
- [Completion diagnostics](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/DebugInformation.ts): `shacled-turtle/src/DebugInformation.ts`
- [Error detection](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/error-detection.ts): `shacled-turtle/src/error-detection.ts`
- [Prefix suggestions](https://github.com/bruju/shacled-turtle/blob/master/shacled-turtle/src/existing-prefixes.ts): `shacled-turtle/src/existing-prefixes.ts`

### Other components

- **Editor user**
- **Schema RDF data**

## Connections

- Editor user → Demo editor: edits Turtle (evidence: `README.md`)
- Demo editor → CodeMirror extension: configures (evidence: `README.md`)
- CodeMirror extension → Turtle syntax support: enables syntax (evidence: `shacled-turtle/index.ts`)
- CodeMirror extension → Editor schema state: installs state (evidence: `shacled-turtle/index.ts`)
- CodeMirror extension → Completion dispatcher: registers completion (evidence: `shacled-turtle/index.ts`)
- CodeMirror extension → Error detection: enables lint (evidence: `shacled-turtle/index.ts`)
- Schema RDF data → Editor schema state: loads schema
- Editor schema state → Schema facade: uses schema (evidence: `shacled-turtle/src/StateField.ts`)
- Schema RDF data → Schema facade: builds models (evidence: `shacled-turtle/src/schema/index.ts`)
- Schema facade → Schema builder: creates builder (evidence: `shacled-turtle/src/schema/index.ts`)
- Schema builder → RDFS support: adds RDFS (evidence: `shacled-turtle/src/schema/builder/index.ts`)
- Schema builder → SHACL support: adds SHACL (evidence: `shacled-turtle/src/schema/builder/index.ts`)
- Schema builder → Inference rules builder: builds rules (evidence: `shacled-turtle/src/schema/builder/index.ts`)
- Schema builder → Suggestion builder: builds suggestions (evidence: `shacled-turtle/src/schema/builder/index.ts`)
- Inference rules builder → Inference engine: creates engine (evidence: `shacled-turtle/src/schema/builder/InferenceEngineBuilder.ts`)
- Suggestion builder → Suggestion engine: creates engine (evidence: `shacled-turtle/src/schema/builder/SuggestionEngineBuilder.ts`)
- Completion dispatcher → Triple completion: dispatches triples (evidence: `shacled-turtle/src/autocompletion-solving.ts`)
- Completion dispatcher → Prefix suggestions: uses prefixes (evidence: `shacled-turtle/src/autocompletion-solving.ts`)
- Completion dispatcher → Completion diagnostics: reports context (evidence: `shacled-turtle/src/autocompletion-solving.ts`)
- Triple completion → Current document triples: reads document (evidence: `shacled-turtle/src/triples-autocompletion.ts`)
- Triple completion → Schema facade: queries suggestions (evidence: `shacled-turtle/src/triples-autocompletion.ts`)
- Document parser → Turtle parser: uses parser (evidence: `shacled-turtle/src/FullParser.ts`)
- Document parser → Triple completion: uses completion logic (evidence: `shacled-turtle/src/FullParser.ts`)
- Editor user → CodeMirror extension: uses extension (evidence: `README.md`)
