Structuring Code

Meteor makes it easy to get started quickly with it's simple file structure. This works great for small projects, but when creating a larger project it is helpful to provide more of a structure. Meteor will automatically separate and compile all file in the client directory for use on the client and all files in the server directory for use on the server. Any file that is nested in the client directory will only be available to the client. To take advantage of this feature we will use the following folder structure.

client/
  lib/          # shared js files that we will be using
                # on the client
  routes.js     # client routes
  views/        # template files
    app.html    # the base app html / handlebars template
    app.js      # the base app template events and helpers
lib/            # for scripts that should be run on both the client and
                # the server
models/         # models that are available to both the `client` and the
                # `server`
server/
  startup.js    # auto start scripts for the server
styles/
  app.css       # base css files
tests/          # a place for tests will be ignored by both the `client`
                # and the `server`

Comments