I haven't looked into it much so not really sure... Might be worth looking at GM9 I suppose, though it's not always very similar so dunno. fwTool 2.0 is also able to dump the 3DS NAND, I think the only DS homebrew to do so, but it's closed source so not much help...
Yeah, it loads from TWiLight or making CIAs of DSi apps is very simple just make_cia --srl="NTM.dsi"
. (linux and usually windows builds of make_cia can be found in most repos that make CIAs, not actually sure the original source of it, there's also a macOS build in Forwarder3-DS and pkmn-chest's repo)
Edit: Oh, just remembered I think the b9s installer is a TWL mode app and writes to NAND and is open source, so might be worth looking at that. Not so much useful for NTM, but would be nice to have in TWiLight Menu++ so it can dump Download Play and the couple other NAND things it does.