TEMPLATE / FREE / MIT EXAMPLE SOURCE
Acme Inc.
Care for customers and their animals
A fictional veterinary directory with editable customer and animal records, search, owner relationships, and persistent archiving.

Take it for a spin.
Choose Customers or Animals. Select a record, edit its fields, and Save. New record creates a draft; Archive/Restore changes its lifecycle. Up/Down scroll the directory. Customer IDs link animals to owners.
Extract the Windows download to a writable folder and open acme-vet.exe. Escape closes it. Database examples keep their local data in the working folder.
See how it works.
DynaCapDB canonical records, properties, relationships, validation, durable commits, and reopen checks.
Synthetic data and a local single-user workflow. No authentication, multi-user scheduling, billing, or production clinical workflow.
READ / CHANGE / UNDERSTAND
The whole example is yours.
These are the exact files in the source download. Start with the model, then follow the window’s event loop. Comments explain the decisions.
using dynacap.storage
using dynacap.model
// Canonical customer and animal records are linked with an owned-by edge.
// This is fake demonstration data in a local single-user application.
Property(text key,text value) returns dynacapProperty
{
dynacapProperty p
p.key=key
p.value=value
return p
}
class Clinic
{
text root
dynacapDatabase database
text message="Ready"
text savedId=""
Clinic(text root)
{
this.root=root
this.database=OpenDynaCapDatabase(root,4194304)
if !this.database.store.healthy
{
this.message=this.database.store.diagnostic
}
}
Save(text id,text kind,text name,text detail,text owner,bool archived=false) returns bool
{
if Text.Length(name)==0
{
this.message="A name is required"
return false
}
if !this.database.store.healthy
{
this.message=this.database.store.diagnostic
return false
}
if kind=="animal"
{
int parent=this.database.FindRecord(owner)
if parent<0
{
this.message="Enter an existing customer ID"
return false
}
if this.database.records[parent].kind!="customer" or this.database.records[parent].lifecycle=="archival"
{
this.message="Choose an active customer"
return false
}
}
if id==""
{
id=Text.Format("{0}-{1}",kind,this.database.records.count+1)
}
dynacapRecord record
record.id=id
record.tenant="acme-demo"
record.space="clinic"
record.container="directory"
record.kind=kind
record.content=name
record.createdAt=1
record.updatedAt=this.database.store.commitVersion+2
record.classification="public"
record.lifecycle="canonical"
if archived
{
record.lifecycle="archival"
}
record.purpose="demo"
record.properties=[Property("detail",detail),Property("owner",owner)]
record.provenance=["synthetic:acme-template"]
// A model transaction validates records and edges before one durable commit.
dynacapTransaction transaction
if !transaction.AddRecord(record)
{
this.message="Record validation failed"
return false
}
if kind=="animal"
{
dynacapEdge edge
edge.id="owner-"+id
edge.tenant="acme-demo"
edge.fromId=id
edge.toId=owner
edge.kind="owned-by"
edge.createdAt=1
if !transaction.AddEdge(edge)
{
this.message="Relationship validation failed"
return false
}
}
bool saved=CommitDynaCapTransaction(this.database,transaction)
// Reopen after either result; never show an uncommitted draft as durable truth.
this.database=OpenDynaCapDatabase(this.root,4194304)
this.message="Saved "+id
this.savedId=""
if saved
{
this.savedId=id
}
else
{
this.message="Commit failed; reopened saved records"
}
return saved
}
Seed()
{
if this.database.store.healthy and this.database.records.count==0
{
this.Save("customer-1","customer","Morgan Reed","morgan@example.test","",false)
this.Save("customer-2","customer","Alex Rivera","alex@example.test","",false)
this.Save("animal-3","animal","Mochi","Cat / annual wellness","customer-1",false)
this.Save("animal-4","animal","Juniper","Dog / vaccination review","customer-2",false)
this.Save("animal-5","animal","Clover","Rabbit / routine visit","customer-1",false)
}
}
}
