Learning Complex Addon Development
This isn't really the sort of question that is readily answerable on this forum.

If you have a problem with a specific script that you are working on then we can help but the subject you refer to is overly broad.

In an attempt to provide you with a useful answer, the best way to learn is to look at the source cod eof the add-ons to which you refer.  You will learn far more from that than anybody will be able to provide you with here.

The beauty of open-source is that you are able to both learn from and adpt existing code for your own purpose.  I hope this helps.