Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Intro to Development

deltasquare4 edited this page May 29, 2012 · 5 revisions

Technologies

The application consists currently of the following stack:

Server:

  • Node.js (server side javascript server)
  • Express (middleware)
  • Socket.io (advanced sockets connectivity/streaming)
  • MongoDB (Mongoose ODM) (nosql database)
  • Jade (templating language, similar to HAML)
  • redis / connect-redis (real-time in memory database for session management)
  • log4js (logging library)
  • LESS (css superset - adds features such as mixins and variables etc)
  • http-proxy (used here to reroute calls to localhost/forum to localhost:9000 which is where the OSQA forum software is running on apache)

For those who are fairly new to Node.js and Async programming:

External server software:

  • MongoDB
  • Redis
  • Apache
  • OSQA Discussion forum software

Client software:

  • Javascript
  • HTML 5
  • CSS 3 Plans are being made to put a MVC framework in place, either Backbone.js, Railway.js, Flatiron.js etc) to give one page ajax like functionality

Note: Google Chrome is considered the first browser. If something works on lastest Chrome, but doesn't work on another browser, log a browser compatibility issue.

Structure of the code

Bootstrap code resides in /server.js, which initializes the application, loads all the required modules and starts the server(s).

The main files that you will interact with during development are:

  • /**
    1. server.js (main server file)
    2. configLocal.js (configuration file)
    3. app/ (application code)
      • routes/ (URL Routes)
      • models/ (Mongoose Models)
      • middleware/ (Express middleware)
      • views/ (Jade views)
    4. public/ ( client side code)
      • img/ (client side images)
      • javascripts/ (third party javascript)
      • ace/ (ace editor)
      • jplayer/ (video player)
      • stylesheets/ (compiled from twitter bootstrap less files and third party stylesheets)
      • views/ (jade templates rendered by the node.js server into html which are sent to the client) (partial view fragments start with an "_" and will be loaded in by ajax etc as needed in future, currently used to keep the views of a manageable size)
    5. test/ (Unit tests written using Mocha)

A few notes related to the structure:

  1. All the routes are consolidated in routes/index.js. Routes are categorized according to their access object (e.g. course, admin, chapter etc.) and are stored in a separate file in app/routes directory. Each operation is described using a function in its specific route file.
  2. Models are initialized using Mongoose and are stored into their own file in app/models directory. They are initialized in server.js database section (e.g. load.init_model() calls)
  3. There is a global load object, which can be used to access models, controllers, helpers, middleware etc. from anywhere in the application.
  • Initialize Model - load.init_model('<filename>')
  • Load Model - load.model('<modelName>')
  • Load Controller/Routes Object - load.controller('<filename>')
  • Load Helper - load.helper('<filename>')
  • Load Middleware - load.middleware('<filename>')