Skip to content
This repository was archived by the owner on Apr 18, 2020. It is now read-only.

Application structure

Rand McKinney edited this page Apr 7, 2014 · 8 revisions

A full-stack LoopBack application follows the model-view-controller application pattern.

  • Models are LoopBack models, defined in the application's /models directory.
  • Views are defined in the application's /web/views and /html5/views directories. Why are there two views directories? What is the diff?
  • Controllers are defined in /html5/controllers.

A full-stack LoopBack application has four sub-directories:

  • The /api directory contains code for a "standard LoopBack" app.
    • app.api.js - main app file
    • configure.js - configuration settings, for example hostname and port, database logins, and so on.
    • package.json
  • The /models directory contains "standard LoopBack" model definitions.
    • index.js - Defines each model using the JS files in this directory, for example: exports.Todo = require('./todo');
    • One JS file to define each model with loopback.DataModel.extend(); for example todo.js.
    • package.json - (Not sure why this is needed here?)
  • The /html5 directory contains:
    • app.html5.js - main file
    • configure.js - gulp build file (?)
    • package.json - (Not sure why this is needed here?)
    • /controllers directory
      • app.ctrl.js - main application controller
      • One .ctrl.js file for each model; for example, user.ctrl.js.
    • /views directory - contains .html files, including one for each model; for example, user.html.
    • /build directory - output of build process? Is this gulp output?
    • /bower_components directory contains files that Bower uses to manage dependencies for front-end packages.
  • The /web directory contains: ** app.js - defines routes (what else?) ** run.js - Used to run the application (?) ** /views directory - contains template files, such as .ejs. ** package.json

NOTES: For simplicity, I did not include test directories. These can be described in an addendum.

Questions

Why are there three package.json files? Could it be done with one?

Clone this wiki locally