Purpose of moddle in diagram-js

I’m trying to create my own custom diagram modeler based on diagram-js (not on bpmn-js, since I’ll not be using BPMN notation at all).
I’ve a problem to catch idea behind moddle, how it should works and what is the purpose?
BTW: I’m going to read and write JSON file, not XML. Do I still need moddle?
Thanks in advance.

Whether or not you need moddle depends on the complexity of your meta model. Is it going to be simple?

Moddle solves two problems: Having a meta-model (including inheritance) and an instance of it (run-time object graph). You can use it during import to validate the input file, during modeling to implement rules and conditional interactions conveniently and during export to to serialize your diagram in a controled fashion.

It may be tempting to not consider having it if you start small. However, while JSON and an object graph have certain similarities JSON documents are trees, not graphs and you likely want to interact with a graph based structure as you model. Moddle backed object graphs are inspectable (what properties does my model element have, and what are their types?) and navigatable (i.e. $parent to traverse up the tree).

Even if you do not use bpmn-js it does make sense to follow the bpmn-js walkthrough for a primer on some of the things I’ve mentioned.

Hope that makes sense.

1 Like

No, rather will not be simple, I’ll go for moddle.

Yes, it make sense. I’ll study it and try to apply. Get back if have some problems.