On this page

Compose an Application๏ƒ

Architecture and design home

Reader Question๏ƒ

What is the smallest complete Melder application shape?

Short Answer๏ƒ

Create a spellbook, bind ordinary Python objects, conjure once, then meld from the resulting conduit. The application keeps its own entry point and domain classes; Melder owns the compiled dependency world and the instances created inside it.

Bind, conjure, and meld sequence

Editable diagram source

Representative Shape๏ƒ

import melder as md

book = md.Spellbook()
book.bind(spell=Config, existence="unique")
book.bind(spell=Repository, existence="unique")
book.bind(spell=Service, existence="unique_per_conduit")

conduit = book.conjure()
service = conduit.meld("Service")

Constructor annotations or explicit SpellMap values define dependency edges. Conjure compiles and validates the graph; meld resolves or creates the requested object according to its lifetime.

Why This Design Is Strong๏ƒ

  • User classes remain normal Python classes.

  • Graph validation is concentrated before steady-state resolution.

  • The conduit is an explicit runtime scope rather than a hidden global locator.

  • Cleanup belongs to the same owner that created the objects.

Tradeoffs๏ƒ

Registration is explicit and a spellbook produces one root conduit. Those restrictions make graph boundaries and root ownership unambiguous; additional scopes are represented as lesser conduits or separate spellbooks rather than repeated implicit construction.

Where to Go Next๏ƒ

Evidence:


Canonical source ยท Full contents