TJ HollowayChuck (creator of Express)
"personally I find large rails-style structure difficult to work with for large applications (great for small ones however). A more modular approach like Drupal is a big win as far as management goes but it can complicate some things (layout templates) so you kind of need compromise sometimes.
We're going more towards being a bit less DRY but high lots of modularity, duplicating the odd template here and there isn't a show-stopper, but in general I think the typical rails style ./{views,models,controllers} is a bad way to structure big apps, I prefer something like:
./modules/{student,teacher,admin}/{views,routes} "
So essentially he is suggesting a student module (instead of model) and then tying that to views / routes... Interesting... We shall see...
Maybe all the controller stuff goes in routes/index.js. Or all the controller stuff goes in one file?
I like having the model stuff separate.
I also like having the routes/config stuff separate from the app.js.
Essentially use approach #3 but keep the routes/controller flat.
To do that have FAT models, and helper functions (in /helpers/) as needed.
Skinny controller.
//modeled after the Rails file strucuture
http://guides.rubyonrails.org/getting_started.html#the-mvc-architecture
http://itsignals.cascadia.com.au/?p=7/
Like this: http://stackoverflow.com/questions/5778245/expressjs-how-to-structure-an-application
TODO: Make this markdown
FAT MODELS, SKINNY Controllers, Views that have (almost) no business logic in them.
/config/
/config/db.js
/config/environment.js
/config/routes.js
views/shared (if they are meant to be shared across views. it not, just in the same folder as the others.)
http://stackoverflow.com/questions/6550103/a-folder-where-to-put-global-shared-partial-templates
http://killswitchcollective.com/articles/13_best_practices_for_rails_partials
partial names should also start with an '_'
For a given profile:
profiles (plural)
model (this file contains the mongoose schema). This should contain the bulk of the business logic. Bulk of data manipulation / db interaction.
models/profile.js (singular)
controller - This is the glue that binds the model & view together. With express the controller is in app.js. I like abstracting that out more.
controllers/profiles_controller.js (plural)
/helper/ /config/ /db/
OR put config.js db.js in the same folder as app.js?