How To Organize A Meteor App
code | 3-6-2014
If you are confused about what any of these directories should contain, don't worry. Let me break it down:
appThis is where the entire application lives
clientThis is where put any code that you only want to be used on the client-side and not the server-side. This will typically include:
stylesheetsYour css files go here
libAnything in this folder will be executed first. You will want to put things such as shared libraries and things here. Inside of this directory, you may want to split things up a little more, such as:
meteorThe application core. This might include the router.js and a startup.js files
vendorClient-side libraries, etc...
viewsYour views and templates can go in this folder. I typically arrange them as modules such as:
collectionsMeteor collections should be shared, so they go here
meteorAny application-specific code
modelsMeteor doesn't really have a concept of models, but it's pretty simple to set them up as an extension of the collections
packagesMeteor packages. You shouldn't need to touch this directly.
privateAny static files that you only want to be available to the server
publicThe /public root for the client-side. This would typically have images and any other static assets.
serverThis is the code that only gets executed on the server-side
apiIf you need to have an http api, it can go here
modelsModels that you only want to be available on the server
publicationsMessaging for the server-side to the client
testsI've found that it is easier to put the tests completely outside of the app itself because the build process can be problematic
integrationSelenium or Webdriver tests
specMocha or QUnit tests
It's taken a lot of trail and error to get to the structure above, and every application will have different needs, but it serves as a good reference for me. How do you organize your Meteor apps?