# metosin/malli architecture

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

- Interactive diagram: https://gitdiagram.com/metosin/malli
- Repository: https://github.com/metosin/malli

## Overview

Malli is a data-driven schema library for Clojure and ClojureScript. A user defines a schema, then can validate or transform values, obtain errors, or generate sample values; schemas also support registries, persistence, and conversion to other schema formats. Function schemas add collection, checking, and runtime instrumentation, while development and visualization tools support schema-driven programming. The README documents the major capabilities; only instrumentation and development source was sampled, so other links below reflect documented behavior rather than inspected calls.

Main entry points: [`src/malli/core.cljc`](https://github.com/metosin/malli/blob/master/src/malli/core.cljc) (Schema core), [`src/malli/dev.clj`](https://github.com/metosin/malli/blob/master/src/malli/dev.clj) (Development mode), [`src/malli/instrument.clj`](https://github.com/metosin/malli/blob/master/src/malli/instrument.clj) (JVM instrumentation), [`src/malli/generator.cljc`](https://github.com/metosin/malli/blob/master/src/malli/generator.cljc) (Value generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_schema["Schema Model"]
  node_core["Schema core<br/>[core.cljc]"]
  node_registry["Schema registries<br/>[registry.cljc]"]
  node_edn["Schema persistence<br/>[edn.cljc]"]
end

subgraph group_runtime["Value Operations"]
  node_validate["Validation<br/>[validate.cljc]"]
  node_transform["Value transformation<br/>[transform.cljc]"]
  node_errors["Error reporting<br/>[error.cljc]"]
  node_generator["Value generation<br/>[generator.cljc]"]
end

subgraph group_interop["Schema Interop"]
  node_describe["Schema description<br/>[describe.cljc]"]
  node_json["JSON Schema<br/>[json_schema.cljc]"]
  node_swagger["Swagger output<br/>[swagger.cljc]"]
  node_dot["DOT visualization<br/>[dot.cljc]"]
  node_plantuml["PlantUML visualization<br/>[plantuml.cljc]"]
end

subgraph group_functions["Function Schemas"]
  node_instrument["JVM instrumentation<br/>[instrument.clj]"]
  node_cljsinstrument["CLJS instrumentation<br/>[cljs.clj]"]
  node_dev["Development mode<br/>[dev.clj]"]
end

subgraph group_tools["Developer Tools"]
  node_provider["Schema inference<br/>[provider.cljc]"]
  node_destructure["Schema destructuring<br/>[destructure.cljc]"]
  node_cljkondo["clj-kondo support<br/>[clj_kondo.cljc]"]
end

node_user(("Schema author"))

node_user -->|"defines schemas"| node_core
node_core -->|"validates values"| node_validate
node_core -->|"transforms values"| node_transform
node_core -->|"generates values"| node_generator
node_core -->|"explains failures"| node_errors
node_core -->|"supports registries"| node_registry
node_core -->|"persists schemas"| node_edn
node_core -->|"transforms schemas"| node_json
node_core -->|"transforms schemas"| node_swagger
node_core -->|"describes schemas"| node_describe
node_core -->|"visualizes schemas"| node_dot
node_core -->|"visualizes schemas"| node_plantuml
node_user -->|"infers schemas"| node_provider
node_user -->|"uses schemas"| node_destructure
node_instrument -->|"instruments functions"| node_core
node_instrument -->|"checks functions"| node_generator
node_cljsinstrument -->|"instruments functions"| node_core
node_dev -->|"starts instrumentation"| node_instrument
node_dev -->|"emits annotations"| node_cljkondo
node_dev -->|"captures failures"| node_core

click node_core "https://github.com/metosin/malli/blob/master/src/malli/core.cljc"
click node_registry "https://github.com/metosin/malli/blob/master/src/malli/registry.cljc"
click node_edn "https://github.com/metosin/malli/blob/master/src/malli/edn.cljc"
click node_validate "https://github.com/metosin/malli/blob/master/src/malli/experimental/validate.cljc"
click node_transform "https://github.com/metosin/malli/blob/master/src/malli/transform.cljc"
click node_errors "https://github.com/metosin/malli/blob/master/src/malli/error.cljc"
click node_generator "https://github.com/metosin/malli/blob/master/src/malli/generator.cljc"
click node_describe "https://github.com/metosin/malli/blob/master/src/malli/experimental/describe.cljc"
click node_json "https://github.com/metosin/malli/blob/master/src/malli/json_schema.cljc"
click node_swagger "https://github.com/metosin/malli/blob/master/src/malli/swagger.cljc"
click node_dot "https://github.com/metosin/malli/blob/master/src/malli/dot.cljc"
click node_plantuml "https://github.com/metosin/malli/blob/master/src/malli/plantuml.cljc"
click node_provider "https://github.com/metosin/malli/blob/master/src/malli/provider.cljc"
click node_destructure "https://github.com/metosin/malli/blob/master/src/malli/destructure.cljc"
click node_instrument "https://github.com/metosin/malli/blob/master/src/malli/instrument.clj"
click node_cljsinstrument "https://github.com/metosin/malli/blob/master/src/malli/instrument/cljs.clj"
click node_dev "https://github.com/metosin/malli/blob/master/src/malli/dev.clj"
click node_cljkondo "https://github.com/metosin/malli/blob/master/src/malli/clj_kondo.cljc"

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_core,node_registry,node_edn toneBlue
class node_validate,node_transform,node_errors,node_generator toneAmber
class node_describe,node_json,node_swagger,node_dot,node_plantuml toneMint
class node_instrument,node_cljsinstrument,node_dev toneRose
class node_provider,node_destructure,node_cljkondo,node_user toneIndigo
```

## Components

### Schema Model

- [Schema core](https://github.com/metosin/malli/blob/master/src/malli/core.cljc): `src/malli/core.cljc`
- [Schema registries](https://github.com/metosin/malli/blob/master/src/malli/registry.cljc): `src/malli/registry.cljc`
- [Schema persistence](https://github.com/metosin/malli/blob/master/src/malli/edn.cljc): `src/malli/edn.cljc`

### Value Operations

- [Validation](https://github.com/metosin/malli/blob/master/src/malli/experimental/validate.cljc): `src/malli/experimental/validate.cljc`
- [Value transformation](https://github.com/metosin/malli/blob/master/src/malli/transform.cljc): `src/malli/transform.cljc`
- [Error reporting](https://github.com/metosin/malli/blob/master/src/malli/error.cljc): `src/malli/error.cljc`
- [Value generation](https://github.com/metosin/malli/blob/master/src/malli/generator.cljc): `src/malli/generator.cljc`

### Schema Interop

- [Schema description](https://github.com/metosin/malli/blob/master/src/malli/experimental/describe.cljc): `src/malli/experimental/describe.cljc`
- [JSON Schema](https://github.com/metosin/malli/blob/master/src/malli/json_schema.cljc): `src/malli/json_schema.cljc`
- [Swagger output](https://github.com/metosin/malli/blob/master/src/malli/swagger.cljc): `src/malli/swagger.cljc`
- [DOT visualization](https://github.com/metosin/malli/blob/master/src/malli/dot.cljc): `src/malli/dot.cljc`
- [PlantUML visualization](https://github.com/metosin/malli/blob/master/src/malli/plantuml.cljc): `src/malli/plantuml.cljc`

### Function Schemas

- [JVM instrumentation](https://github.com/metosin/malli/blob/master/src/malli/instrument.clj): `src/malli/instrument.clj`
- [CLJS instrumentation](https://github.com/metosin/malli/blob/master/src/malli/instrument/cljs.clj): `src/malli/instrument/cljs.clj`
- [Development mode](https://github.com/metosin/malli/blob/master/src/malli/dev.clj): `src/malli/dev.clj`

### Developer Tools

- [Schema inference](https://github.com/metosin/malli/blob/master/src/malli/provider.cljc): `src/malli/provider.cljc`
- [Schema destructuring](https://github.com/metosin/malli/blob/master/src/malli/destructure.cljc): `src/malli/destructure.cljc`
- [clj-kondo support](https://github.com/metosin/malli/blob/master/src/malli/clj_kondo.cljc): `src/malli/clj_kondo.cljc`

### Other components

- **Schema author**

## Connections

- Schema author → Schema core: defines schemas (evidence: `README.md`)
- Schema core → Validation: validates values (evidence: `README.md`)
- Schema core → Value transformation: transforms values (evidence: `README.md`)
- Schema core → Value generation: generates values (evidence: `README.md`)
- Schema core → Error reporting: explains failures (evidence: `README.md`)
- Schema core → Schema registries: supports registries (evidence: `README.md`)
- Schema core → Schema persistence: persists schemas (evidence: `README.md`)
- Schema core → JSON Schema: transforms schemas (evidence: `README.md`)
- Schema core → Swagger output: transforms schemas (evidence: `README.md`)
- Schema core → Schema description: describes schemas (evidence: `README.md`)
- Schema core → DOT visualization: visualizes schemas (evidence: `README.md`)
- Schema core → PlantUML visualization: visualizes schemas (evidence: `README.md`)
- Schema author → Schema inference: infers schemas (evidence: `README.md`)
- Schema author → Schema destructuring: uses schemas (evidence: `README.md`)
- JVM instrumentation → Schema core: instruments functions (evidence: `src/malli/instrument.clj`)
- JVM instrumentation → Value generation: checks functions (evidence: `src/malli/instrument.clj`)
- CLJS instrumentation → Schema core: instruments functions (evidence: `src/malli/instrument/cljs.clj`)
- Development mode → JVM instrumentation: starts instrumentation (evidence: `src/malli/dev.clj`)
- Development mode → clj-kondo support: emits annotations (evidence: `src/malli/dev.clj`)
- Development mode → Schema core: captures failures (evidence: `src/malli/dev.clj`)
