Templating system

Templates are the foundation of structured information in Smallworld. They define how data is shaped, secured, validated, and related — all enforced directly at the protocol level.

Much like how traditional databases use table definitions, Smallworld uses templates to define schemas. But unlike those static definitions, templates in Smallworld are programmable, relational, and deeply integrated with rights and identity. They form the backbone of the global, decentralized database.

Structured information by default

Every piece of data in Smallworld is defined through a template. These templates describe what data looks like, how it behaves, and who controls it.

A template is more than a schema — it is an active, self-aware object that:

  • Defines fields and value types
  • Embeds validation logic
  • Establishes ownership and permissions
  • Enables relationships to other data across domains

Each domain (like repertoire.com/repertoire-db) can define its own collection of templates, forming modular, interoperable databases. Together, these create a global network of structured, linked, and governed data.

Supported value types include:

  • Base types: string, integer, boolean, date, datetime
  • Cryptographic formats: pubkey-hash, uint128, uint256
  • Complex structures: reference, weak-reference, domain-reference, included-template, composite
  • Organizational tools: list, object, map

Rights and ownership embedded

Templates aren’t just data definitions — they carry embedded rights logic that governs how they and their instances can be used.

  • Templates can define who is allowed to create or modify them.

  • Instances created from a template inherit rights rules, including field-level permissions.

  • Rights can be conditional, dynamic, and group-specific, supporting use cases like:

    “Only this group can create entries, but any user can view them.”
    “A user can create an instance, but cannot edit it afterward.”
    “Only the third item in a list can be modified — and only if it matches a known address.”

Rights are first-class objects in Smallworld — they can be queried, composed, transferred, and enforced natively across the system.

Templates as contracts

In Smallworld, templates are tightly integrated with the information contract system.
Validation, references, and rights enforcement happen within the template itself — turning the schema into a living agreement.

Every template can define:

  • Required and optional fields
  • Regex patterns or custom rules per field
  • Cross-field dependencies
  • Conditional validation paths
  • Referential integrity across templates and domains

This allows Smallworld to enforce logic at the data layer, eliminating the need for external application logic or middleware.

Instances and domains

A template becomes powerful when instantiated. Each instance is a structured, rights-aware object — akin to a row in a traditional database, but with its own identity, ownership, and permission model.

Domains act as containers, grouping related templates together. A domain for music metadata might include templates for:

  • artist
  • song
  • recording
  • publishing rights
  • contract

Each with specific behaviors, validation rules, and relationships — creating a decentralized, composable database for that domain.

Declarative and evolvable

Templates are written in a declarative format, meaning that their structure, behavior, and rules are all readable and introspectable. They’re also dynamic — templates can be:

  • Created by any authorized party
  • Modified with version control
  • Composed from other templates
  • Used as components in larger workflows

Need to add support for a new document type? Create a template.
Need to enforce ISO standards? Bake it into the schema.
Need to modify how access is granted? Change the rules — not the app.

This makes Smallworld a system where governance and evolution happen at the data layer.

Programmable primitives for the global network

Templates are the building blocks of every database, every application, every interaction in Smallworld. They encapsulate structure, validation, ownership, and contract logic — all in one self-contained unit.

This makes them perfect for defining:

  • Interoperable supply chains
  • Public registries
  • Legal agreements
  • Identity records
  • Collaborative software
  • Dynamic, real-time marketplaces

In Smallworld, templates are infrastructure, governance and programmable law for structured data.