This document gives a quick overview over the development setup process of the Demo Facility of the LOGwear project.

Overview

The Demo Facility consists of a backend and frontend which are both kept in their corresponding folder in this repository. The backend is a node-based application utilizing the Express framework for creating the RESTful API and Mongoose as the database driver connecting to the MongoDB. The whole backend is written in Typescript. The frontend is an Angular 7 application.

Quick development setup guide

To setup your machine to develop on the Demo Facility project, you need to have the following things installed:

  • NodeJS (the LTS versions are recommended)

  • MongoDB

  • Docker (and Docker Compose)

  • An editor supporting Typescript (VSCode is recommended, Configuration files can be found in the repository)

For macOS users with Homebrew installed:

brew install node
brew install mongo
brew cask install docker
brew cask install visual-studio-code

When everything is installed, make sure that you install Typescript globally using npm as it is not declared as a dependency in the package.json.

npm install -g typescript ts-node

Before you can run the Demo Facility backend make sure to install all dependencies with

npm install

To run the backend cd to the backend folder and run npm run dev. For more information regarding the frontend see the section below. Make sure that MongoDB is running.

Backend structure

The backend’s project has the following folder structure:

  • config

  • controllers (Process the incoming requests)

  • middlewares (Can be intercepted in a request, e.g. for authentication)

  • routing (declares the routing)

  • seeder (Predefined data sets)

  • services (Business logic, used by controllers)

Connecting the frontend to the backend

Connecting the frontend while developing locally does not require further configuration. Just run the Angular application with the built-in ng serve command and it will connect to the backend on localhost:3000/api.

For production use, the backend API url needs to be declared in the src/environments/environment.prod.ts file.

Testing

The backend project has unit testing built-in with Jest as the testing framework. Some unit tests can be found in the tests folder. If you create new test, make sure that they end with test.ts as tests are only run when this pattern is matching. To run the tests run npm run test. For some tests a running database might be required.

Installing jest globally might be required:

npm install -g jest

Deployment

The Demo Facility is deployed using Docker. Therefore, the backend and frontend have their own Dockerfile. This Dockerfile specifies how the images are build. To run the frontend, backend together with a mongoDB, a docker-compose.yml file is set up in the repository root.

To run the Demo Facility in prodcution using Docker just run the following commands:

docker-compose build --pull
docker-compose up -d

Depdending on you machine the build process might take a while.

Network configuration

For the hardware part of the Demo Facility, two iMac Pros, one MacBook Pro and two Wifi routers are available. The iMac Pros are configured on 192.168.0.2 and 192.168.0.3 and the MacBook Pro also on 192.168.0.2. Make sure you dont run the MacBook together with the stationary Demo Facility.