source: Dev/trunk/README.md

Last change on this file was 520, checked in by hendrikvanantwerpen, 11 years ago

Updated README and made syncs more resilient.

File size: 5.5 KB
Line 
1# QED
2
3This document describes how to develop this code base and the source
4code organisation.
5
6## Development, Install and Deploy
7
8Source files are located in `src`. Build and deployment is managed
9with _Grunt_, a node based task runner.
10
11First make sure _node_, _npm_, _couchdb_, _heroku_, _formena_, _git_
12and _svn_ are installed. To run _grunt_, you'll have to install the
13commandline client with `npm install -g grunt-cli`.
14
15QED can run in two modes, _dev_ and _production_. This is controlled
16by the environment variable `QED_ENV`. If it is not present, _dev_ is
17the assumed mode. In development mode, QED runs agains another
18database than in production. So, to run the production server, you
19must use `QED_ENV=production grunt run`. Usually when developing you
20will use the dev mode and you can omit the QED_ENV variable. The value
21of QED_ENV on heroku is already set to production (this can be done
22with `heroku config:set QED_ENV=production --app quod-erat` and is
23persisent).
24
25From source to a deployable version goes in few steps.
26 1. Develop in `src`. You can run `grunt` (or `grunt compile`) to do
27    compiling of Coffee and LESS sources and linting of Javascript,
28    HTML etc.
29 1. Run a server with `grunt run` and test. If client sources are
30    changed, you only have to run `grunt compile` and reload the
31    browser, for server sources you have to restart it.
32 1. You can create a _Dojo_ build with `grunt build`, which will merge
33    and compress sources. You can also run `grunt run-build`, which
34    will do the build and start it locally for testing.
35 1. When you feel your changes are production ready, you can deploy to
36    Heroku by running `grunt deploy`. The heroku app must know about
37    _quod-erat_ already, so you might have to add it by hand the first
38    time.
39
40## Database management
41
42There are _grunt_ tasks to push local database to Cloudant, pull the
43oter way or make a backup of the Cloudant database. Which database is
44used (dev or production) is again controlled by `QED_ENV`.
45
46In `src/server/bin` are some scripts to check if all database
47documents are valid and to upload the latest version of the design
48documents. Both the design documents and the database schema are
49versioned and QED won't start if the versions don't match.
50
51If an update required changes to (normally) immutable documents, you
52can disable the modification check with
53`config-db-for-upgrade.js`. It's usually a good idea to write and
54update script instead of doing things by hand. Don't forget to restore
55the check with `config-db.js`, although a server restart will also do
56that for you.
57
58Synchronisation doesn't ignore validation checks, so if you had to
59disable the validation to do an upgrade, you also have to disable
60validation on the database that you synchronize to. Currently this is
61not automated, so you have to run the scripts yourself in a sane
62order.
63
64If you want to test locally but with the Cloudant database instead of
65localhost, run like `CLOUDANT_URL=<ur> QED_ENV=dev grunt run`. You can
66get the url by running `heroku config:get CLOUDANT_URL --app
67quod-erat`.
68
69## File organisation
70
71 * _/_ Project root
72   * _build/_ Builds go here
73     * _development/_ Uncompressed build
74     * _production/_ Minified build
75   * _docs/_ Project documentation, design documents etc
76   * _src/_ Source code
77     * _client/_ Dojo web client
78     * _server/_ Node/Express server
79     * _Procfile_ Heroku process description
80
81```
82client/
83  The web application for QED.
84  routes.js
85    Contains the mapping from URLs to pages.
86  run.js
87    The script for starting the web application (the researchers part).
88  stddeps.js
89    Contains many dependencies that are used declarativly in the
90    templates. Maybe it can be deprecated with Dojo 1.8+'s auto require
91    if the build scans templates as well.
92  store.js
93    Module that returns a fully configured store for the rest of the
94    application to use for database access. Handles caching and exposes
95    some common serialization functions.
96  view.js
97    Script that starts the survey part (the respondent part).
98  data/
99    Apache proxy configuration for transparant access to CouchDB.
100  dijit/
101    Dijit library (UI components)
102  dojo/
103    Dojo library (Dojo JS framework)
104  dojox/
105    DojoX library (contrib library for Dojo and Dijit)
106  qed/
107    Sourcecode of the QED application
108    app/
109      Small app framework for handling pages, content, notifications
110      and URL history. Our application is build on this.
111    css/
112      Contains all CSS of the application. Should be distributed better
113      with the widgets. The styling is based on LESS, although a copy
114      of the CSS is still there.
115    model/
116      Contains all code dependent on our model, that is, the concrete
117      representation of our database documents.
118      classes/
119        Smart classes on top of the database documents, to help with
120        creating and validating objects.
121      widgets/
122        All widgets that are specific for objects of our model.
123    pages/
124      The pages in the application. Are wired up to URLs in the routes.js
125      file.
126    store/
127      Dojo Store implementations for Couch and Elastic.
128    ui/
129      Deprecated. Used to contain all widgets, but these are now split
130      between general and model specific widgets. Contains a few widgets
131      that were not yet refactored.
132    widgets/
133      Contains general widgets that are used in our application but do
134      not depend on our model.
135  util/
136    Dojo utils (e.g. build infrastructure)
137```
Note: See TracBrowser for help on using the repository browser.