Before proceeding any further, read the following documents:
While Node.js applications are mostly platform-agnostic, we assume you're developing using a Unix system. Should some development script, tool, etc. not run in your windows (etc.) machine and you know how to make it compatible, consider sending a pull request.
Table of Contents
- application architecture
- starting the application
- data entry
- bundling for the browser
- deployment
- news
The directory structure of the code repository:
.
|-- config/ # configurations
|-- data/ # data files, particularly for the different networks
|-- engine/ # business logic (the "heavy-lifting")
|-- routes/ # routing logic
|-- schema/ # JSON Schema files for our data-file specification
|-- test/ # our tests
|-- web/ # web interface (whatever you see in the browser)
`-- app.js # main entry point, with bootstrap code
The application is built using, mainly:
- express: THE web framework
- node-config: handles application configuration
- nunjucks: for page templating
- ajv: JSON schema validator
- showdown: Markdown converter
Usually, before starting the application, you'll need to build some files:
$ npm run build
The application can be started in either development or production mode:
$ npm start # start in production mode
$ npm run start-dev # start in development mode
Data entry is a one-off task, that is crucial to this application, so as to ensure the data used does not end up being stale and inaccurate. This is one of the most simple yet cumbersome development task. No extensive programming knowledge is required.
To get started:
- read the existing data files in
data/
- understand thee Data File Specification being used
We are not re-implementing the cost calculation module (engine/math.js
)
and other necessary modules to support calculations on browser
(client-side). Instead, we bundle the modules, using
browserify, producing web/js/engine.js
. This script allows
us to re-use the same code, on server and browser.
However, there are some significant variations. In particular, we:
- require the data-file to be available on the browser; this is
injected by
nunjucks
. - do not have access to the elaborate error classes; all errors are
basically just instances of
Error
- developer-in-charge: GochoMugo
Feel free to contact the developer, should you want to submit sensitive information concerning the hosting server, etc. Also, CC the information to we@forfuture.co.ke, with a suitable subject line.
You can find major news concerning the application at http://mmtc.forfuture.co.ke/news/.
Since we are avoiding restarting the application, just to reflect any recently-added news, the developer in-charge of deployment handles this process:
- a new branch, from the develop branch is created with a name
in a format, similar to
news/2016-04-23
. - new news are added to the beginning of
web/_raw/news.md
- while the new branch is reviewed and merged back, the updated news.md should be uploaded to the server, using SSH or similar tool.
News are now updated!
HAPPY HACKING!