architecture - samuelchen/gagein-web-new GitHub Wiki

We leverage NodeJS as the language runtime (VM), express as the app engine. Python as an alternative language runtime (VM) because python 3rd party community is bigger, longer and more stable.

We use npm as the package management tool. (PIP & easy_install for python).

The application meta such as version, dependencies are kept in /approot/package.json. When deploy, we just need run npm install in command line. It will install all the dependencies we defined in package.json.

NodeJS supports single process deployment. We may deploy several app server on a single machine. The express framework is used to create the app server. The port could be specified in argument.

The app servers should be behind Nginx(http://nginx.org) http server. It's the high performance web server widely used in all internet companies. It has the features of load balance, HA proxy and etc. (Sure we could use Apache & HAProxy). We config nginx as the L7 proxy. It redirects requests to different app servers as configured.

The app server will route the request to corresponding controllers. And the template engine express renders the web contents (html/css/js) to browser as requested. Static contents are served from app server. They could be on CDN.

When rendering the contents, we call back-end API with an module in app server. It wraps the call and generate the data & layout. Browser-side JS could call directly to the app server. We expose the API wrapper as REST api. It could be treat as the proxy to real API. It leverage the none-blocking NodeJS to provide high performance invoking.

Contents are hosted in folders. One page/widget per folder. They are well organized physically. When rendering a page, we pick out the page and the widgets on this page and response to browser in combination. Generally a widget has .tpl, .css, .js 3 files. These 3 files will reference the common global/module level files as well.