# Bootstrap users & data

Kazana app has built-in support for bootstrapping raw data reports, entities
and users.

Give you already created a Kazana app, create a `bootstrap` folder and set the
[bootstrap option](../api/kazana-manifest.md#bootstrap) to `"bootstrap"`.

## Bootstrap demo users

Create 3 test users: one admin, one data provider and one analyst.

1. admin user

   create `bootstrap/_users/org.couchdb.user_test-admin@example.com.js`

   ```js
   module.exports = {
     _id: 'org.couchdb.user:test-admin@example.com',
     type: 'user',
     name: 'test-admin@example.com',
     roles: [
       'kazana-id:testadmin',
       'kazana-data-provider',
       'kazana-data-reviewer',
       'kazana-analyst',
       'kazana-admin'
     ],
     password: process.env.TEST_USER_PASSWORD || 'secret',
     createdAt: '2016-01-01T00:00:00.000Z'
   }
   ```

2. data provider

   create `bootstrap/_users/org.couchdb.user_test-data-provider@example.com`

   ```js
   module.exports = {
     _id: 'org.couchdb.user:test-data-provider@example.com',
     type: 'user',
     name: 'test-data-provider@example.com',
     roles: [
       'kazana-id:testdataprovider',
       'kazana-data-provider'
     ],
     password: process.env.TEST_USER_PASSWORD || 'secret',
     createdAt: '2016-01-01T00:00:00.000Z'
   }
   ```

3. data analyst

   create `bootstrap/_users/org.couchdb.user_test-analyst@example.com.json`

   ```js
   module.exports = {
     _id: 'org.couchdb.user:test-analyst@example.com.json',
     type: 'user',
     name: 'test-analyst@example.com.json',
     roles: [
       'kazana-id:testanalyst',
       'kazana-analyst'
     ],
     password: process.env.TEST_USER_PASSWORD || 'secret',
     createdAt: '2016-01-01T00:00:00.000Z'
   }
   ```

You can now start your app with `npm start`, and you should see your users
at http://l:4999/_utils/#/database/_users/_all_docs. You can now sign in
as `test-analyst@example.com`, `test-data-provider@example.com` and
`test-admin@example.com` with the password `secret`. To change the password,
run `TEST_USER_PASSWORD=othersecret npm start`. That will set the password to
`othersecret`.

## Bootstrap demo raw data report

Create `bootstrap/raw-data/bookkeeping_2016-1.json` with the content below

```json
{
  "_id": "bookkeeping_2016-1",
  "sourceId": "bookkeeping",
  "scope": {
    "id": "2016-1",
    "year": "2016",
    "quarter": "1"
  },
  "name": "integration-test1",
  "data": "+444.55 test-transform-grinder\n+111.11 test-transform-batmobile",
  "type": "dataReport",
  "version": "1.0.0",
  "createdAt": "2016-01-01T00:00:00.000Z",
  "updatedAt": "2016-01-01T00:00:00.000Z",
  "createdBy": {
    "login": "kazana-admin@example.com",
    "id": "testadmin"
  }
}
```

Now everytime you start the app with `npm start`, the `bookkeeping_2016-1` raw
data report gets created. If it already exists, it gets reset and picked up
for [transformation](transform.md), which will delete all indicators from
`integrated-data` belonging to `bookkeeping_2016-1` and re-create them.
