I'm following a tutorial on the MEAN stack and I'd like to have a clean folder structure to work with. I've read plenty of articles that say to have a folder for each (let's call it) module of the application with the views/models/controllers/etc.. grouped together.
I like this approach and I've already started doing this, however I'd like some assistance.
right now, my directory structure looks something like this:
up till now, I have a main index
view with its angular controller, so what I did is, make a new folder under public
and named it index
anything with an asterisk is a folder (*)
first question is, is this good so far? does all of this belong in the public folder?
my second has to do with the back end. I'm starting to build some models and the tutorial is saying to put them in the models
folder. However, I'd rather keep models with their respective "module", so the index model I'd rather put in the folder where the index view lives. probably create a new folder under index called models
and add it in there:
but this doesn't seem to be the right place to put a model file since this is the public folder, and a model is back-end code. Is there a better approach to what I'm doing? or should I have the models just be in the main models folder? and just have the front end be grouped by 'module' while the models all just sit together in the models folder?
The new MEAN js stack follows a different approach and they no longer have separate server side folder and client side folder. Now the separation is at the module level
You can see that each module has client, server and test folder. For more info you can check out their latest repository.
I came up with my own structure. This helped me during a project.
Each *
marks a folder.
app
folder is for the Backend and public
for the Frontend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With