# Setting up your local development environment

## Gitlab

The required code can be downloaded from our gitlab repositories:

gitlab.com/hybrix-public

To download (clone) the code from gitlab please use:

`git clone https://gitlab.com/hybrix-public/node.git`

Enter the newly created folder

`cd node`

To setup and install development dependencies run:

`./scripts/npm/setup.sh`

This will also automatically clone several other repositories that are required. Once this is done an online connection is no longer needed for development. An overview of the folder structure that will be created follows:

## Folder structure

The development environment expects all repositories to be cloned into a common base folder, you can choose any name. Here we will use `$HYBRIXD` as a placeholder ($ are shell variable prefixes)

### Required

- `$HYBRIXD/node` : contains the hybrixd deamon (required for all development) gitlab.com/hybrix-public/hybrixd
- `$HYBRIXD/common` : files that are used by several of the above projects (required) gitlab.com/hybrix-public/common
- `$HYBRIXD/node_modules` : the node_modules (required) gitlab.com/hybrix-public/node_modules
- `$HYBRIXD/hybrix-jslib` : contains what is needed to compile the hybrix javascript interface client libraries (required) gitlab.com/hybrix-public/hybrix-jslib

### Optional

- `$HYBRIXD/web-wallet` : contains everything required to compile the web-wallet module (required for front-end development)
- `$HYBRIXD/deterministic` : contains everything required to compile deterministic client modules (required for determistic development) gitlab.com/hybrix-public/deterministic
- `$HYBRIXD/node` : NodeJS run times for various architectures (independent setup) gitlab.com/hybrix-public/nodejs

### Per project

- `$HYBRIXD/$PROJECT/node_binaries` : A symbolic link to `$HYBRIXD/nodejs/$SYSTEM` where `$SYSTEM` depends on your system architecture (Linux, Mac, 32 or 64 bit)
- `$HYBRIXD/$PROJECT/node_modules` : The node modules needed for this project
- `$HYBRIXD/$PROJECT/common` : A symbolic link to `$HYBRIXD/common`
- `$HYBRIXD/$PROJECT/scripts` : Tools and scripts
- `$HYBRIXD/$PROJECT/scripts/main` : main and/or npm command scripts
- `$HYBRIXD/$PROJECT/docs` : Documentation
- `$HYBRIXD/$PROJECT/dist` : The compiled distributable files if applicable
- `$HYBRIXD/$PROJECT/package.json` : The npm package file.

## Scripts and common commands

For hybrix npm (Node Package Manager) is used to manage the node packages per project (located in the `$HYBRIXD/$PROJECT/node_modules` directories). The configuration for each project is stored in `$HYBRIXD/$PROJECT/package.json` .

Important! When working with node packages please do not use global npm but the one located in `$HYBRIXD/$PROJECT/scripts/main/npm.sh` . This ensures version compatibility.

The following commands can be used from the `$HYBRIXD/$PROJECT` project folders:

- `./scripts/main/setup.sh` : Run all tasks to setup the dev environment for this project. For example link dependencies and implement git hooks.
- `./scripts/main/compile.sh` : Run all tasks to compile the project into the `$HYBRIXD/$PROJECT/dist` distributables folder.
- `./scripts/main/dist.sh` : Distribute the compiled files to the Node.
- `./scripts/main/clean.sh` : Clean the `$HYBRIXD/$PROJECT/dist` distributables folder.
- `./scripts/main/build.sh` : Run the setup, compile and dist commands sequentially.
- `./scripts/docs/docs.sh` : Compile documentation.
- `./scripts/main/diag.sh` : Run a diagnostic on all project folders to check linkage and git status.

## Troubleshooting

- Run `./scripts/main/diag.sh` to validate all components and linkage.
- Run `./scripts/main/setup.sh` to correct project symbolic link problems.

## node

The following extra commands can be used from the `$HYBRIXD/node`project folder:

- `./hybrixd` : Start hybrix
- `./qrtz yourFile.qrtz` : Run your your own Qrtz script (see example.qrtz)

## web-wallet

The following extra commands can be used from the `$HYBRIXD/web-wallet` project folder:

- `./scripts/main/compile.sh en` : Compile the web-wallet and translate to English.
  Results are located in the `dist` directory and available via symbolic link at `$HYBRIXD/node/modules/web-wallet`