Make a quick vote 🗳 ️How do you refer to SuiteCRM extensions: add-ons or plug-ins? Click here to have your say 👈

Need Help understanding Module Build Process and what's the correct way to write module files

I wrote a Package/Module and wrote the code in the module folder. Then I had a miss hap where I ended up removing and re-deploying the module. I found out that some of the code was missing. I also noticed that some fields in my table were missing after re-deploying.

When a package is created, a folder is created in custom/packages with the name of the package.
When modules are added to the package, folders icons, language and modules are created in the packages/ folder. Each of these folders have files automatically generated in them.
When deploying the package the module files are created in the modules folder.

What is the correct file location that one should use when developing a module?
If I need to modify files in my module or even add additional files what is the correct way of doing this? Which are the correct files to modify? Do you modify the ones in the custom/package or custom/module folders or do modify the files in the root module folder? If you modify the files in the root module folder what is the correct way to make sure the package is updated?

I have ran into a couple of situations where I lost a lot of work and had to recreate and really need to understand how modules are to be written and modified?

On the other end of this, when I uninstall a module and delete the package I would expect to see the files removed from the modules folder but it does not. How is this supposed to be handled?

Thanks,

Tony