Skip to content

CAWI App

It is proposed that in CAWI v3, a survey is deployed as a standalone node application. It can be run locally (using a tool such as Nodemon to automatically update and restart the app based on DSC file changes) or deployed via Docker.

Workflow

Note

This is a proposed workflow - it has not yet been implemented

Create a new project

To create a new project, run the npx @gide/create-cawi-app script.

After (possibly) answering some questions, a new directory will be created and populated as follows:

p2312gid002_example # root directory of your project
├── package.json
├── .gitignore
├── README.md
├── cawi
│   ├── p2312opi002.dsc
│   ├── p2312opi002.ini
│   └── ... other files and directories containing project assets
└── app.js

You then need to run npm install to download the dependencies listed in package.json. This will create a "node_modules" directory containing those modules:

p2312opi002_example # root directory of your project
├── package.json
├── .gitignore
├── README.md
├── config.yaml    # Config file for overall project, includes the list of "surveys" (DSC files)
├── node_modules
│   ├── .bin
│   │   ├── cawic -> ../@gide/cawi-language/bin/cawic
│   │   ├── cawi2json -> ../@gide/cawi-language/bin/cawi2json.js
│   │   ├── cawi2engine -> ../@gide/cawi-engine/bin/cawi2engine.js
│   │   ├── ... binaries provided by generic NPM packages
│   ├── @gide
│   │   ├── cawi-language
│   │   ├── cawi-engine
│   │   └── cawi-display
│   └── ... various generic NPM packages
├── cawi
│   ├── p2312opi002a
│   │   ├── p2312opi002a.dsc
│   │   ├── p2312opi002a.yaml
│   │   └── ... other directories for p2312opi002a
│   ├── p2312opi002b
│   │   ├── p2312opi002b.dsc
│   │   ├── p2312opi002b.yaml
│   │   └── ... other directories for p2312opi002b
│   └── ... common files, CAPMI tab application, ... ??? TO BE DECIDED
├── src
│   ├── lib/
│   └── app.mts

Overview of project structure

  • package.json contains the metadata about the project, including name, version number and the lists of NPM packages required to run the application (dependencies and devDependencies).

  • .gitignore lists files to be ignored by git (which includes node_modules)

  • README.md - a template README.md file describing the project

  • p2312opi002.dsc a boilerplate DSC, perhaps with PROLOG pre-populated

  • p2312opi002.ini - a default ini file (ini files to be reviewed in CAWI v3)

  • app.js - a simple nodejs application using the @gide/cawi-* modules to deploy the questionnaire. For most surveys this will not need to be changed, but is part of the project's git repository to allow advanced customisations.

Proposal from Cyril:

  • npm create @gide/cawi-app or something like that

  • An interactive shell to choose some modules and configuration => project's name ? CAWI or CAPMI ? Classic UI or chat UI ? Styling template ? etc...

  • Build a package.json with the right modules (cawi-language, cawi-server, cawi-display...) + some default config files (.env, yaml...) + a basic project's directory structure (for assets, includes, etc).

  • The CAWI programmer run npm i once.

  • Then he runs npm run dev => it compiles the DSC then starts 2 local development servers : one for the cawi-server and one for the cawi-display.

  • The cawi-server dev process uses something like tsx watch (or nodemon or nitro bin) in view to auto-compile DSC and auto-restart the server process.

  • The cawi-display dev process uses vite bin (from cawi-app devDependencies) in view to provide HMR.

  • The CAWI programmer will be able to fix packages versions through his project's package.json. He can sometimes use npm upgrade --save then check his project.

He also have some more commands available in view to build and deploy his project.