UNOPS / ICAT.PmuPortalService

Backend service for ICAT Climate Action Assessment Tool for Transport Sector - TraCAD.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TraCAD - PMU Portal Service

Backend service for ICAT Climate Action Assessment Tool for Transport Sector - TraCAD.

Supported by Initiative for Climate Action Transparency - ICAT.

Built using Node.js 16 and Nest framework.

Database Configuration

This application uses a MySQL Database. The ICAT-PMU.sql configuration file containing the database schema and some dummy data is provided in the root folder. This database is also used by the PMUScheduler application.

Manual Installation

  1. Download and install the Node.js 16 LTS version for your operational system.

  2. Download or clone this repository.

  3. In the terminal, go to this repository's main folder.

  4. Install the NPM dependencies (including Nest) with the command:

$ npm install --force
  1. Set up the Environment Variables

    • In the machine:

      • Windows: using the set command in the terminal
      • Linux/MacOS: using the export command in the terminal
    • Or creating a .env file using .env.example as base

  2. Run the app:

$ npm run start

Google Cloud Installation with Docker

This is an example cloud installation using Docker and Google Cloud Plataform. The provided Dockerfile can be used for local or cloud installation with different services.

  1. In GCP Console, go to Artifact Registry and enable the Artifact Registry API

  2. In the Artifact Registry, create a new repository:

    • Format: Docker
    • Type: Standard
    • Location: desired application location
    • Encryption: Google-managed key
  3. Download and install gcloud CLI.

  4. Download or clone this repository.

  5. In the terminal, go to this repository's main folder.

  6. Build your container in the Artifacts Register using the provided Dockerfile. The container path can be found on the Artifact Registry's repository page.

$ gcloud builds submit --tag [CONTAINER PATH]
  1. Go to Cloud Run and create a New Service:
    • Choose the option Deploy one revision from an existing container image and select the container image updated in the previous step
    • Add a service name
    • Select the application region
    • Select Allow unauthenticated invocations in the Authentication option
    • In the Container section:
      • Select Container port 8083
      • Add the Environment Variables
      • Add the Cloud SQL connections

Noticed that some special permissions in GCP can be necessary to perform these tasks.

Environment Variables

The environment variables should be declared as follow:

Variable name Description
PORT Application Port
DATABASE_HOST Database Host(*)
SOCKET_PATH Database Socket Path(*)
DATABASE_PORT Database Port
DATABASE_USER Database Socket User
DATABASE_PASSWORD Database Password
DATABASE_NAME Database Name
BASE_URL Current Application URL
CLIENT_URL PMU Service Web URL
PMU_LOGIN_URL PMU Service Web URL + /login
COUNTRY_LOGIN_URL Country Service Web URL + /login
PMU_RESET_PASSWORD_URL PMU Service Web URL + /reset-password
COUNTRY_RESET_PASSWORD_URL Country Service Web URL + /reset-password

(*) Can be used the Database Host or the Database Socket Path depending of the database configuration

API Documentation

After the application installation, the API Documentation is available in the application URL + /api/ with Swagger.

Default Users

Some default users are provided for the application test. The Admin user can create, edit or delete new users.

We recommend deleting the default users before deploying the application to production.

Role Username Password Description
PMU Admin pmu_admin pmu1234 User with administrative permissions
PMU User pmu_user pmu1234 Normal user

Dependencies

This application provides API service to PMUPortalWeb and CountryScheduler application.

The complete dependency diagram of TraCAD Country and PMU applications:

TraCAD Diagram

License

TraCAD - CountryPortalService is Affero GPL licensed.

About

Backend service for ICAT Climate Action Assessment Tool for Transport Sector - TraCAD.

License:GNU Affero General Public License v3.0


Languages

Language:TypeScript 76.7%Language:HTML 21.9%Language:Dockerfile 1.1%Language:JavaScript 0.3%