Skip to content

Templates

Koine ships a set of example domains as templates. The templates/ directory is the single, CI-validated source of truth for every example: the demo project, Koine Studio’s template gallery, and the website’s inline playground all read from it. There is no second copy to drift.

A template is a folder containing:

  • one or more .koi files — the domain model itself; and
  • a template.json manifest describing it (display name, difficulty, the contexts it defines, and the concepts it teaches).

Single-file starters hold one .koi file; larger domains spread several .koi files across bounded contexts and compile together in directory mode (so imports, the context map, and integration events resolve across files — see Multi-file, imports & modules).

Validation: a green build proves every template

Section titled “Validation: a green build proves every template”

Every template is exercised by TemplatesValidationTests, which on each build:

  • compiles every template green — so a passing dotnet test proves all templates emit compiling C#; and
  • validates every template.json against the JSON Schema below — so each one stays well-described, with its id matching the folder name and its entryFile pointing at a real .koi file.

Templates carry one of four difficulty levels — starter, beginner, intermediate, advanced — used to order and badge them in listings. (All four are valid schema values; beginner is reserved for future templates and unused today.)

TemplateDifficultyWhat it models
starters/billingstarterMoney, orders, and invariants — the canonical Koine starter
starters/orderingstarterAn aggregate with a state machine — renders as a diagram
starters/contextmapstarterTwo bounded contexts and the relationship between them
starters/valuesstarterSmart enums with data, quantities, ranges, and derived fields
ticketingintermediateA help-desk workflow with a ticket lifecycle and a cross-context SLA policy
pizzeriaintermediateA six-context pizza shop (menu, ordering, kitchen, delivery, payment, promotions) plus an external Gateway
libraryintermediateA lending library across five contexts — the Book-vs-BookCopy distinction, loans, reservations, fines
saas-subscriptionadvancedMulti-tenant subscriptions with trials, metered quotas, dunning, and a payment-provider ACL

The pizzeria template is also the one the demo compiles in place and the one the site’s generated domain reference is built from.

Each template folder carries a template.json validated against templates/template.schema.json. All fields are required:

FieldTypeMeaning
idstringStable identifier — must equal the folder name.
namestringHuman-readable display name (e.g. "Billing").
taglinestringOne-line summary shown in template listings.
descriptionstringA paragraph describing what the template models and demonstrates.
difficultyenumstarter · beginner · intermediate · advanced — relative complexity, used to order and badge.
tagsstring[]Free-form keywords for search and filtering.
contextsstring[]The names of the bounded contexts the template defines.
coreAggregatestringThe headline aggregate that anchors the template.
entryFilestringThe primary .koi file to open first — must name a file present in the folder.
teachesstring[]The Koine concepts / DDD patterns a learner picks up from this template.
iconstringAn icon identifier (an emoji or icon name) for the template card.
{
"id": "billing",
"name": "Billing",
"tagline": "Money, orders, and invariants — the canonical Koine starter.",
"description": "A single Billing context with Money, an Order aggregate, and the invariants that keep them honest.",
"difficulty": "starter",
"tags": ["value-objects", "invariants", "aggregate"],
"contexts": ["Billing"],
"coreAggregate": "Order",
"entryFile": "billing.koi",
"teaches": ["value objects", "invariants", "aggregates"],
"icon": "💶"
}