# Notebooks Hub Developing This section documents the local deployment for the Notebooks Hub application, including the mongo database, the API, and the UI. ## Local Mongo Setup Start the Mongo database with mongo:6.0.4 on port 27017, and provide generic credentials. ``` docker run -p 27017:27017 -eMONGO_INITDB_ROOT_USERNAME= -eMONGO_INITDB_ROOT_PASSWORD= mongo:6.0.4 ``` ## Local API Setup Prerequisite: - notebooksHub mongoDb database on port 27017 - Jupyterhub deployment URL 1. Navigate to the package/API directory, and create the packages/API/.env file according to the variables found in the [Values.yaml](../../../deploy/Helm/notebooks-hub-api/values.yaml) file within the associated [Helm Deployment](../../../deploy/Helm/notebooks-hub-api/) script. ```BASH JUPYTERHUB_URL = JUPYTER_URL JUPYTERHUB_API_KEY = JUPYTER_API_KEY MODULE_LOCATION = 'opt/modules/' JUPYTERHUB_TOKEN_FILE = 'opt/jupyterhubToken/' DB_USER = '' DB_PASS = '' DB_HOST = localhost DB_PORT = 27017 AUTH_SOURCE = 'admin' ``` Further, the Jupyterhub API key can be found within the corresponding Jupyterhub Secret on our Kubernetes Cluster. 2. Set node version to 18.20.3 with nvm with npm version set to 10.7.0 and angular CLI version set to 9.1.15 (Note: Angular CLI version may be a newer version) ``` source ~/.nvm/nvm.sh nvm install 18.20.3 node -v ``` 3. Install node modules and the global Angular CLI ``` npm install ``` ``` npm install -g @angular/cli@17 ``` 4. Set the environment variables ``` set -a source .env ``` 5. Build application with npm run build with the root packages/API/package.json Using this command will create the necessary files and folders on the filesystem for `/opt/` to mimic the volume mounts for when `mockFiles='false'`. This command will not affect anything when mocking the filesystem via `mockFiles=true`. ``` npm run build:dev ``` If the dist folder does not get generated, delete 'tsconfig.tsbuildinfo' and 'node_modules', install node modules and build again 6. Start application with npm run start ``` npm run start ``` 7. View your OpenAPI specification and test service calls at localhost:8002. If testing with postman, 'filter' and 'where' query JSON params are URL-encoded. ``` http://localhost:8002/explorer/ ``` ## Local UI Setup Prerequisite: - notebooksHub mongoDb database on port 27017 - Jupyterhub deployment URL - local API deployment on port 8002 1. Navigate to the package/UI directory, and create the packages/UI/.env file according to the variables found in the [Values.yaml](../../../deploy/Helm/notebooks-hub-ui/values.yaml) file within the associated [Helm Deployment](../../../deploy/Helm/notebooks-hub-ui/) script. ``` RESPONSE_TYPE = 'code' URL = AUTH_URL REDIRECT_URL = 'http://localhost:4200' TENANT = 'polus-qa' BACKEND_URL = 'http://127.0.0.1:8002' JUPYTERHUB_URL = JUPYTER_URL CLIENT_ID = 'test' CLIENT_SECRET = CLIENT_SECRET ``` 2. Request labshare npm access, and authenticate npm via the following command. ``` npm login ``` 3. Set node version to 18.20.3 with nvm with npm version set to 10.7.0 and angular CLI version set to 17.3.8 (Note: Angular CLI version may be a newer version) ``` source ~/.nvm/nvm.sh nvm install 18.20.3 node -v ``` 4. Install node modules ``` npm install ``` 5. Build the library and the main app, then run it ``` npm run build:lib npm run build npm run start ```