Source Code organization

If I would like to create a larger application with various categories such as contact form, user management or other elements.

How should the source code be organized. I know I can exclude type definitions from the main.mo file to a Types.mo file e.g. Or I can outsource some functions to a module util.mo e.g.

I’m wondering, can a part like the hole user management be completely outsourced to a module including the data handling?

What ways are there for Motoko to divide the source code so that at the end +1000 lines of code don’t remain in one file?

2 Likes

You can put most things out into modules. I mainly declare my stable variables and public methods in the main file, and then break out all the logic and types into other files.

This also helps a lot for unit testing!