# stranger6667/jsonschema architecture

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

- Interactive diagram: https://gitdiagram.com/stranger6667/jsonschema
- Repository: https://github.com/stranger6667/jsonschema

## Overview

This workspace centers on a Rust JSON Schema validator. The main workflow is to provide a schema and instance, build a reusable validator, then validate or evaluate the instance and inspect errors or structured output. The graph also preserves documented capabilities and language targets. Relationships are based on the README and the shown source index; unsampled implementation details are not treated as inspected.

Main entry points: [`crates/jsonschema/src/lib.rs`](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/lib.rs) (Validator API), [`crates/jsonschema/src/compiler.rs`](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/compiler.rs) (Schema compiler), [`crates/jsonschema-macros-core/src/codegen.rs`](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen.rs) (Validator codegen), [`crates/jsonschema-macros-core/src/codegen/emit.rs`](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit.rs) (Value emitter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_validation["Validation engine"]
  node_validator_api["Validator API<br/>[lib.rs]"]
  node_options["Validator options<br/>[options.rs]"]
  node_compiler["Schema compiler<br/>[compiler.rs]"]
  node_keyword_checks["Keyword checks<br/>[mod.rs]"]
  node_validator["Reusable validator<br/>[validator.rs]"]
  node_evaluation["Evaluation and errors<br/>[evaluation.rs]"]
  node_output["Structured output<br/>[output.rs]"]
end

subgraph group_schema["Schema lifecycle"]
  node_referencing["Reference registry<br/>[build.rs]"]
  node_retriever["Remote retrieval<br/>[retriever.rs]"]
  node_bundler["Schema bundling<br/>[bundler.rs]"]
  node_dereferencer["Reference dereferencing<br/>[dereferencer.rs]"]
  node_canonical["Canonicalization<br/>[mod.rs]"]
end

subgraph group_codegen["Compile-time generation"]
  node_macro_entry["Validator macro<br/>[lib.rs]"]
  node_codegen["Validator codegen<br/>[codegen.rs]"]
  node_codegen_context["Codegen context<br/>[context.rs]"]
  node_codegen_dispatch["Keyword dispatch<br/>[dispatch.rs]"]
  node_codegen_emit["Value emitter<br/>[emit.rs]"]
  node_emit_rust["Serde emitter<br/>[emit_root.rs]"]
  node_emit_python["Python emitter<br/>[emit_pyo3.rs]"]
  node_emit_ruby["Ruby emitter<br/>[emit_magnus.rs]"]
end

subgraph group_interfaces["User interfaces"]
  node_cli["Command line<br/>[main.rs]"]
  node_python_binding["Python binding<br/>[lib.rs]"]
  node_ruby_binding["Ruby binding<br/>[lib.rs]"]
  node_wasm["WebAssembly interface<br/>[lib.rs]"]
end

subgraph group_representations["Representations"]
  node_regex["Regex support<br/>[lib.rs]"]
  node_jsonb["Postgres jsonb<br/>[mod.rs]"]
  node_jsonb_encode["jsonb encoding<br/>[encode.rs]"]
end

node_caller(("Rust application"))
node_cli_user(("CLI user"))
node_schema_input["Schema and instance"]

node_caller -->|"builds or validates"| node_validator_api
node_schema_input -->|"provides inputs"| node_validator_api
node_validator_api -->|"compiles schema"| node_compiler
node_validator_api -.->|"configures"| node_options
node_compiler -.->|"compiles keywords"| node_keyword_checks
node_compiler -->|"builds"| node_validator
node_validator -->|"validates and evaluates"| node_evaluation
node_evaluation -->|"reports structured output"| node_output
node_compiler -.->|"resolves references"| node_referencing
node_referencing -.->|"retrieves resources"| node_retriever
node_caller -->|"bundles schemas"| node_bundler
node_caller -->|"dereferences schemas"| node_dereferencer
node_caller -->|"canonicalizes schema"| node_canonical
node_caller -->|"declares known schema"| node_macro_entry
node_macro_entry -.->|"generates validator"| node_codegen
node_codegen -->|"uses compilation context"| node_codegen_context
node_codegen -->|"dispatches keywords"| node_codegen_dispatch
node_codegen -->|"emits code through"| node_codegen_emit
node_codegen_emit -.->|"supports serde output"| node_emit_rust
node_codegen_emit -.->|"supports Python output"| node_emit_python
node_codegen_emit -.->|"supports Ruby output"| node_emit_ruby
node_cli_user -->|"runs validation"| node_cli
node_cli -->|"uses validator"| node_validator_api
node_caller -->|"uses Python binding"| node_python_binding
node_caller -->|"uses Ruby binding"| node_ruby_binding
node_caller -->|"uses playground"| node_wasm
node_keyword_checks -.->|"matches patterns"| node_regex
node_caller -->|"validates in place"| node_jsonb
node_jsonb -->|"encodes values"| node_jsonb_encode

click node_validator_api "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/lib.rs"
click node_options "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/options.rs"
click node_compiler "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/compiler.rs"
click node_keyword_checks "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/keywords/mod.rs"
click node_validator "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/validator.rs"
click node_evaluation "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/evaluation.rs"
click node_output "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/output.rs"
click node_referencing "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-referencing/src/registry/build.rs"
click node_retriever "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/retriever.rs"
click node_bundler "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/bundler.rs"
click node_dereferencer "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/dereferencer.rs"
click node_canonical "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/canonical/mod.rs"
click node_macro_entry "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros/src/lib.rs"
click node_codegen "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen.rs"
click node_codegen_context "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/context.rs"
click node_codegen_dispatch "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/dispatch.rs"
click node_codegen_emit "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit.rs"
click node_emit_rust "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit_root.rs"
click node_emit_python "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit_pyo3.rs"
click node_emit_ruby "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit_magnus.rs"
click node_cli "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-cli/src/main.rs"
click node_python_binding "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-py/src/lib.rs"
click node_ruby_binding "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-rb/src/lib.rs"
click node_wasm "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-wasm/src/lib.rs"
click node_regex "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-regex/src/lib.rs"
click node_jsonb "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-value/src/jsonb/mod.rs"
click node_jsonb_encode "https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-value/src/jsonb/encode.rs"

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_validator_api,node_options,node_compiler,node_keyword_checks,node_validator,node_evaluation,node_output,node_cli_user toneBlue
class node_referencing,node_retriever,node_bundler,node_dereferencer,node_canonical toneAmber
class node_macro_entry,node_codegen,node_codegen_context,node_codegen_dispatch,node_codegen_emit,node_emit_rust,node_emit_python,node_emit_ruby toneMint
class node_cli,node_python_binding,node_ruby_binding,node_wasm toneRose
class node_regex,node_jsonb,node_jsonb_encode,node_caller,node_schema_input toneIndigo
```

## Components

### Validation engine

- [Validator API](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/lib.rs): `crates/jsonschema/src/lib.rs`
- [Validator options](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/options.rs): `crates/jsonschema/src/options.rs`
- [Schema compiler](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/compiler.rs): `crates/jsonschema/src/compiler.rs`
- [Keyword checks](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/keywords/mod.rs): `crates/jsonschema/src/keywords/mod.rs`
- [Reusable validator](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/validator.rs): `crates/jsonschema/src/validator.rs`
- [Evaluation and errors](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/evaluation.rs): `crates/jsonschema/src/evaluation.rs`
- [Structured output](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/output.rs): `crates/jsonschema/src/output.rs`

### Schema lifecycle

- [Reference registry](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-referencing/src/registry/build.rs): `crates/jsonschema-referencing/src/registry/build.rs`
- [Remote retrieval](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/retriever.rs): `crates/jsonschema/src/retriever.rs`
- [Schema bundling](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/bundler.rs): `crates/jsonschema/src/bundler.rs`
- [Reference dereferencing](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/dereferencer.rs): `crates/jsonschema/src/dereferencer.rs`
- [Canonicalization](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema/src/canonical/mod.rs): `crates/jsonschema/src/canonical/mod.rs`

### Compile-time generation

- [Validator macro](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros/src/lib.rs): `crates/jsonschema-macros/src/lib.rs`
- [Validator codegen](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen.rs): `crates/jsonschema-macros-core/src/codegen.rs`
- [Codegen context](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/context.rs): `crates/jsonschema-macros-core/src/context.rs`
- [Keyword dispatch](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/dispatch.rs): `crates/jsonschema-macros-core/src/codegen/dispatch.rs`
- [Value emitter](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit.rs): `crates/jsonschema-macros-core/src/codegen/emit.rs`
- [Serde emitter](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit_root.rs): `crates/jsonschema-macros-core/src/codegen/emit_root.rs`
- [Python emitter](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit_pyo3.rs): `crates/jsonschema-macros-core/src/codegen/emit_pyo3.rs`
- [Ruby emitter](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-macros-core/src/codegen/emit_magnus.rs): `crates/jsonschema-macros-core/src/codegen/emit_magnus.rs`

### User interfaces

- [Command line](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-cli/src/main.rs): `crates/jsonschema-cli/src/main.rs`
- [Python binding](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-py/src/lib.rs): `crates/jsonschema-py/src/lib.rs`
- [Ruby binding](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-rb/src/lib.rs): `crates/jsonschema-rb/src/lib.rs`
- [WebAssembly interface](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-wasm/src/lib.rs): `crates/jsonschema-wasm/src/lib.rs`

### Representations

- [Regex support](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-regex/src/lib.rs): `crates/jsonschema-regex/src/lib.rs`
- [Postgres jsonb](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-value/src/jsonb/mod.rs): `crates/jsonschema-value/src/jsonb/mod.rs`
- [jsonb encoding](https://github.com/stranger6667/jsonschema/blob/master/crates/jsonschema-value/src/jsonb/encode.rs): `crates/jsonschema-value/src/jsonb/encode.rs`

### Other components

- **Rust application**
- **CLI user**
- **Schema and instance**

## Connections

- Rust application → Validator API: builds or validates
- Schema and instance → Validator API: provides inputs
- Validator API → Schema compiler: compiles schema
- Validator API → Validator options: configures
- Schema compiler → Keyword checks: compiles keywords
- Schema compiler → Reusable validator: builds
- Reusable validator → Evaluation and errors: validates and evaluates
- Evaluation and errors → Structured output: reports structured output
- Schema compiler → Reference registry: resolves references
- Reference registry → Remote retrieval: retrieves resources
- Rust application → Schema bundling: bundles schemas
- Rust application → Reference dereferencing: dereferences schemas
- Rust application → Canonicalization: canonicalizes schema
- Rust application → Validator macro: declares known schema
- Validator macro → Validator codegen: generates validator
- Validator codegen → Codegen context: uses compilation context (evidence: `crates/jsonschema-macros-core/src/codegen.rs`)
- Validator codegen → Keyword dispatch: dispatches keywords (evidence: `crates/jsonschema-macros-core/src/codegen.rs`)
- Validator codegen → Value emitter: emits code through (evidence: `crates/jsonschema-macros-core/src/codegen.rs`)
- Value emitter → Serde emitter: supports serde output
- Value emitter → Python emitter: supports Python output
- Value emitter → Ruby emitter: supports Ruby output
- CLI user → Command line: runs validation
- Command line → Validator API: uses validator
- Rust application → Python binding: uses Python binding
- Rust application → Ruby binding: uses Ruby binding
- Rust application → WebAssembly interface: uses playground
- Keyword checks → Regex support: matches patterns
- Rust application → Postgres jsonb: validates in place
- Postgres jsonb → jsonb encoding: encodes values (evidence: `crates/jsonschema-value/src/jsonb/mod.rs`)
